RE: [xsl] loop in creation of table

Subject: RE: [xsl] loop in creation of table
From: "Zwetselaar M. van (Marco)" <Marco.van.Zwetselaar@xxxxxxxxxxxxx>
Date: Wed, 26 Sep 2001 16:11:45 +0200
Praveen,

> elements like this- <subsystem_id> value1</subsystem_id>.
> now i have to design a table like the one shown BELOW..  we 
> have total of 16 columns and 4 rows. 

You could do this at follows, but there will surely be more elegant
solutions:

<xsl:template match="/">
	<xsl:call-template name="make-row">
		<xsl:with-param name="elements"
select="//subsystem_id[position() mod 4 = 1]" />
	</xsl:call-template>
	<xsl:call-template name="make-row">
		<xsl:with-param name="elements"
select="//subsystem_id[position() mod 4 = 2]" />
	</xsl:call-template>
	<xsl:call-template name="make-row">
		<xsl:with-param name="elements"
select="//subsystem_id[position() mod 4 = 3]" />
	</xsl:call-template>
	<xsl:call-template name="make-row">
		<xsl:with-param name="elements"
select="//subsystem_id[position() mod 4 = 0]" />
	</xsl:call-template>
</xsl:template>

<xsl:template name="make-row">
	<xsl:param name="elements" />
	<tr>
		<xsl:for-each select="$elements">
			<td><xsl:value-of select="." /></td>
		</xsl:for-each>
		<td colspan="{16-count($elements)}" />
	</tr>
</xsl:template>

Regards,
Marco

DISCLAIMER: sorry about the following disclaimer, it's outside of my
control.


***************************DISCLAIMER***********************************
Deze e-mail is uitsluitend bestemd voor de geadresseerde(n). 
Verstrekking aan en gebruik door anderen is niet toegestaan.
Fortis sluit iedere aansprakelijkheid uit die voortvloeit uit
electronische verzending.

This e-mail is intended exclusively for the addressee(s), and may
not be passed on to, or made available for use by any person 
other than the addressee(s).
Fortis rules out any and every liability resulting from any
electronic transmission.
************************************************************************

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread