[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Having same number of rows in table irrespective o

Subject: Re: Having same number of rows in table irrespective of number of data rows
From: Brian Chrisman <incubus@xxxxxxxxxxxxxx>
Date: Tue, 12 Apr 2005 00:32:42 -0700
xsl empty rows
On Tue, Apr 12, 2005 at 07:58:14AM +0100, Steve W wrote:
> 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>

not the easiest of tasks... 
You probably want to make a recursive 'xsl:call-template' passing a
parameter specifying how many additional rows to create.
might try this...

... inside yer <table>...
<xsl:call-template name="blank-rows">
	<xsl:with-param name="count" select="5 - count(INITIALVALUES/INITIALVALUE)"/>
</xsl:call-template>


<xsl:template name="blank-rows">
	<xsl:param name="count"/>
	<!-- blank row stuff here -->
	<xsl:if test="$count &gt; 0">
		<xsl:call-template name="blank-rows">
			<xsl:with-param name="count" select="$count - 1"/>
		</xsl:call-template>
	</xsl:if>
</xsl:template>

xslt is great at transforming data... not quite so convenient (at least 1.0,
not sure about 2.0) when yer not transforming data.. :-)

> 
> Thanks
> 
> Steve

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.