This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: generate unknow table
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] generate unknow table
- From: "John Wang" <jwang at mincron dot com>
- Date: Mon, 11 Jun 2001 15:26:27 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi, All
I have posted this question few days ago. It seems no body
even give a try to answer this question. Could someone tell
me this is impossible in XSLT? Or my question is not clear?
Thanks a lot in advance.
Here is my xml:
<?xml version="1.0"?>
<display>
<title>
<field id="sflbr">Br</field>
<field id="sflcyc">Cycle</field>
<field id="sfsts">P/I Status Description</field>
<field id="pidate">P/I Date</field>
</title>
<data>
<record>
<sel>12</sel>
<sflbr>001</sflbr>
<sflcyc>200</sflcyc>
<sfsts>This is a description</sfsts>
<pidate>06-02-01</pidate>
</record>
<record>
<sel>11</sel>
<sflbr>002</sflbr>
<sflcyc>210</sflcyc>
<sfsts>This is a description too</sfsts>
<pidate>06-11-01</pidate>
</record>
</data>
</display>
Here is my xsl:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<table border="1">
<xsl:apply-templates select="display/title"/>
<xsl:apply-templates select="display/data"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="title">
<tr>
<xsl:for-each select="field">
<td>
<xsl:value-of select="."/>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="data">
<xsl:for-each select="record">
<tr>
<td>
<xsl:value-of select="sflbr"/>
</td>
<td>
<xsl:value-of select="sflcyc"/>
</td>
<td>
<xsl:value-of select="sfsts"/>
</td>
<td>
<xsl:value-of select="pidate"/>
</td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
If you do the XSL transform, you will get the result I want to get.
The problem is, when I write the XSL, I don't know the columns I want to
display, until I read the coming XML. How can I get the field name
such as sflbr, sflcyc, sfsts, pidata from the display/title/field@id?
Thanks a lot.
-John
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list