Re: [xsl] Fixed value only once in table

Subject: Re: [xsl] Fixed value only once in table
From: omprakash.v@xxxxxxxxxxxxx
Date: Wed, 17 May 2006 15:23:23 +0530
Hi,
        As often suggested on this list, the best approach to this type of
problem is to first create the HTML you want and then proceed to code the
stylesheet. You can do this by adding a rowspan to the first column. Before
writing the first column, you would however need to check if it is the
first one like so:


<table width="100%" border="0">
<tbody>

<xsl:variable name="rows"
select="count(tc:MESSAGE/tc:CUSTOM-ATT/b:empty_cart/b:choice_of_extra)"/>

<xsl:for-each
select="tc:MESSAGE/tc:CUSTOM-ATT/b:empty_cart/b:choice_of_extra">
<tr>
<xsl:if test="position() == 1">
<td width="10%" rowspan="$rows">Extra</td>
</xsl:if>
<td width="10%"><xsl:value-of select="b:code"/></td>
<td width="80%"><xsl:value-of select="b:specification"/></td>
</tr>
</xsl:for-each>
</tbody>
</table>

Hope this helps.

cheers,
prakash





                                                                                                                                
                      "Mattias                                                                                                  
                      Pirmann"                 To:      "xsl-list@xxxxxxxxxxxxxxxxxxxxxx" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>     
                      <Mattias.Pirmann         cc:      (bcc: omprakash.v/Polaris)                                              
                      @lekab.com>              Subject: [xsl] Fixed value only once in table                                    
                                                                                                                                
                      05/17/2006 01:25                                                                                          
                      PM                                                                                                        
                      Please respond                                                                                            
                      to xsl-list                                                                                               
                                                                                                                                
                                                                                                                                




I want to produce a dynamic table which holds three columns. The first
column holds a fixed value (Extra) and should only occur on the first row.
The second and third column holds value from the xml-file and should be
dynamic.

The xml file looks like

<choice_of_extra>
<code>711</code>
<specification>Cleaning</specification>
</choice_of_extra>
<choice_of_extra>
<code>511</code>
<specification>New towels</specification>
</choice_of_extra>

XSL

<table width="100%" border="0">
<tbody>
<xsl:for-each
select="tc:MESSAGE/tc:CUSTOM-ATT/b:empty_cart/b:choice_of_extra">
<tr>
<td width="10%">Extra</td>
<td width="10%"><xsl:value-of select="b:code"/></td>
<td width="80%"><xsl:value-of select="b:specification"/></td>
</tr>
</xsl:for-each>
</tbody>
</table>

Result

Extra  711  Cleaning
Extra  511  New towels

Wanted display

Extra  711  Cleaning
       511  New towels

Any ideas?

Regards

Mattias Pirmann



This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only.  If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polaris.co.in

Current Thread