xsl-list
[Top] [All Lists]

Re: [xsl] Generate a table in nested form

2010-12-07 21:49:18
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="&quot;Application Usage&quot;"></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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>