xsl-list
[Top] [All Lists]

RE: Having same number of rows in table irrespective of number of data rows

2005-04-12 00:59:55
In XSLT 2.0 you can do

<xsl:for-each select="count(INITIALVALUES/INITIALVALUE)+1 to 5">
  <tr>...</tr>
</xsl:for-each>

In 1.0 the usual approach is to select the first N nodes of some dummy
node-set:

<xsl:for-each select="(//node())[position() &lt;= (5 -
count(INITIALVALUES/INITIALVALUE))]"

Michael Kay
http://www.saxonica.com/
 

-----Original Message-----
From: Steve W [mailto:lsl(_at_)btconnect(_dot_)com] 
Sent: 12 April 2005 07:58
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Having same number of rows in table 
irrespective of number of data rows

I want to create a table that has a set number of rows in it. 
 The XML has
data in it to be shown in the table - in simple terms one 
element of the XML
for each row of the table.  The XML will only have an element 
if there is
data,  so if I have 3 data elements but I want 5 rows in the 
table there
will be 2 'missing' rows and I want to output these 2 rows 
with some set
html in it.

My template looks like this :

<table cellpadding="0" cellspacing="0" border="0" width="100%">
    <xsl:for-each select="INITIALVALUES/INITIALVALUE">
        <tr>
            <td>
                <!-- some html ....  -->
                </td>
            </tr>
    </xsl:for-each>
    <!-- add 'blank' rows to give constant number of rows in table -->
</table>

Thanks

Steve


--~------------------------------------------------------------------
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>
--~--





--~------------------------------------------------------------------
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>