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

Re: how to add a </tr> on every position() mod 4 = 0 ?

Subject: Re: how to add a </tr> on every position() mod 4 = 0 ?
From: "Thomas Sandor" <tsandor@xxxxxxxxxxx>
Date: Mon, 11 Nov 2002 13:06:20 +0100
xsl position mod
hi,

one more question. I'm using as in the example my bar[position()] for a
parameter, so when listing I had a number before : 1..9, but now I have
1..4, plus I have a in foo a position() 1..3. I could count the current
position if I could see somehow the foo position in <xsl:template
match="bar"/> but xsl:variable is not overwritten. do you know any method to
find the current bar position() num in the full list?

Thomas

----- Original Message -----
From: <Jarno.Elovirta@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, November 11, 2002 10:11
Subject: RE:  how to add a </tr> on every position() mod 4 = 0 ?


> Hi,
>
> > I have a list in xml, and want to show them in a 4-column
> > table (in at least
> > 2 rows). so I would like to add a closing </tr> tag to every <xsl:if
> > test="position() mod 4 = 0"> but I cannot write a simple
> > closing </tr> tag
> > here, because parser says it's an error. (However a <tr/>
> > works for output,
> > but it's not the clean and sytanctically the best way)
>
> Remember, you're not writing tags with XSLT, but rather building a tree
(see <http://www.w3.org/TR/xpath#data-model>). Try something in the lines of
>
> <xsl:template match="foo">
>   <table>
>     <xsl:for-each select="bar[position() mod 4 = 1]">
>       <tr>
>         <xsl:apply-templates select=". | following-sibling::bar[position()
&lt; 4]" />
>       </tr>
>     </xsl:for-each>
>   </table>
> </xsl:template>
>
> Cheers,
>
> Jarno - Wumpscut: Wreath of Barbs (Album mix)
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 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.