[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

Subject: Inserting leaf node names as headers in a table
From: Hemanth Singamsetty <hemanth.singamsetty@xxxxxxxxx>
Date: Mon, 13 Sep 2004 18:53:42 -0700
leaf names
> 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() &lt; 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.