|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Inserting leaf node names as headers in a table
> I'm trying to insert the leaf node tagnames, of a XML file, as header values in a table using XSLT.
> My XML file looks like this:
>
> <A>
> <B>
> <D>
> <E>
> <E1>e1</E1>
> <E2>e2</E2>
> <E3>e3</E3>
> :
> </E>
> <F>
> <F1>f1</F1>
> <F2>f2</F2>
> <F3>f3</F3>
> :
> </F>
> <G>
> <GG>
> <GGG>ggg1</GGG>
> <GGG>ggg2</GGG>
> </GG>
> <GG>
> <GGG>ggg3<GGG>
> <GGG>ggg4</GGG>
> </GG>
> :
> :
> </G>
> </D>
> <D>
> <D>
> :
> :
> <B>
> <B>
> :
> :
> </A>
>
>
> The output I'm trying to get is a table with different columns having headers as
> (E1, E2, E3....,F1, F2, F3,...., GGG1, GGG2, GGG3, GGG4....) and the values inside
> the table corresponding to the above header as
> (e1, e2, e3,....,f1, f2, f3....ggg1, ggg2, ggg3, ggg4...and so on for each <D>)
>
>
> I was able to create and populate the table with values using <xsl: apply-templates> but
> I'm new to XML and XSL programming and I'm finding it difficult to display the header values
> only once, i mean, i'm trying to put a <xsl:if> condition in a <xsl:for-each> to stop after
> one iteration.
>
> I'm doing something like this in the <xsl:template match="B">, but it didn't work.
>
> <tr>
> <xsl:for-each select="????">
> <xsl:if test="position() < count("????")">
> <th><xsl:value-of select="local-name()"/></th>
> </xsl:if>
> </xsl:for-each>
> </tr>
>
>
> Hope my question is clear. Can someone help me figure out how should I do this?
>
>
>
> Thanks in advance,
> Hemanth
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








