Re: Generate a table in nested form
Rashi Bhardwaj wrote: > I have sample xml in this form: > <a> <b name="Name" value="Test"/> <b name="Identity" value=" 5229"/> <b name="Last Change Date" value="4/26/2010"/> <b name="Last Change Time" value="11:38 AM"/> <b name="Initial Date" value="2/11/2010"/> <b name="Initial Time" value="09:37 AM"/> <b name="Sections 1-1" value=""Application Usage""></b> <b name="QQuestion 1-1" value="how are u"/> <b name="RResponse 1-1" value="2 - Disagree"/> <b name="CComment 1-1" value="fine"/> [snip]> > I want to generate a table columns heads, Name, identity, last > updation date....so on...but for the Questions there will one column > head 'Question' and all the other question should come under this > column Question in different row. [snip]> > i have used is > > <xsl:when test="contains(@name, 'Question')"> > <xsl:choose> > <xsl:when test="contains(@name, 'QQuestion')"> > <td> > <xsl:value-of select="."/> [snip] > But it is not creating nested output. Same I have to do for comments, > response and sections. > > Please tell me where I m wrong. First you use <xsl:value-of select="."/> whereas you want to use <xsl:value-of select="@value"/> And then, I suppose you want the corresponding Section, Question, Response and Comment on one row, is that right? If so, you can't process them separately, you have to process them sequentially otherwise they end up in different rows. Are you using XSLT 2.0? If so, you can group the corresponding entries and process them together, like: <xsl:for-each-group select="a/b" group-starting-with="b[contains(@name,'Section')]"> <tr> <xsl:for-each select="current-group()"> <td><xsl:value-of select="@value"/></td> </xsl:for-each> </tr> </xsl:for-each-group> Of course the first group has to treated special and you need to add a couple of empty cells for the other groups. And it may be easier to process the first Sections with QQuestion etc together in this group. This can be done by changing 'Section' to 'Section ' in the group-starting-with. If you're using 1.0 you could emulate this grouping. -- Piet van Oostrum Cochabamba. URL: http://pietvanoostrum.com/ Nu Fair Trade woonartikelen op http://www.zylja.com
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