[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] First item of a for-each
Subject: RE: [xsl] First item of a for-each From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx> Date: Mon, 16 Feb 2004 15:37:55 -0000 |
> When using a .. > > <xsl:for-each select="item[***]"> > > </xsl:for-each> > > How can I work out when Im in the first loop. My node set has > a predicate on it so I don't know where I am in the sequence > but want to do something special in the first loop?? You aren't in a loop, you are iterating over a set of nodes that you have selected to process. So, if you have the xml: <item/> <something_else/> <item/> <something_else/> And you do xsl:for-each select="node" you will get a list of <item> nodes to process: <item/> <item/> You have 'pulled' two nodes to process. You can find out which <item> you are currently processing by using the position() function. So if you wanted to do something special to the first <item> node, you could do: <xsl:for-each select="item"> <xsl:if test="position() = 1"> do something special </xsl:if> </xsl:for-each> andrew XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] First item of a for-each, David Carlisle | Thread | Re: [xsl] First item of a for-each, G. Ken Holman |
RE: [xsl] First item of a for-each, SHEIKH Sajjad | Date | Re: [xsl] First item of a for-each, David Carlisle |
Month |