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

Re: loop in creation of table

Subject: Re: loop in creation of table
From: Jörg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 27 Sep 2001 01:33:09 +0200
xsl call template loop
In my eyes there is a better way to reach the same:

<xsl:template match="parent-of-subsystem_id">
 <table border="1">
  <tr><xsl:apply-templates select="subsystem_id[position() mod 4 =
1]"/></tr>
  <tr><xsl:apply-templates select="subsystem_id[position() mod 4 =
2]"/></tr>
  <tr><xsl:apply-templates select="subsystem_id[position() mod 4 =
3]"/></tr>
  <tr><xsl:apply-templates select="subsystem_id[position() mod 4 =
0]"/></tr>
 </table>
</xsl:template>

<xsl:template match="subsystem_id">
 <td><xsl:value-of select="."/></td>
 <xsl:if test="position()=last()">
  <td colspan="{16 - position()}">&#160;</td>
 </xsl:if>
</xsl:template>
</xsl:stylesheet>

I like to avoid <call-template>s ;-)

Joerg

----- Original Message -----
From: Zwetselaar M. van (Marco)
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Sent: Wednesday, September 26, 2001 4:11 PM
Subject: RE:  loop in creation of table

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


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


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.