[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How do I set up a counter or sequence number varia
In your first posting, there is a for-each over a sequence of nodes, and one line is created for each item. You can number this (as Martin has written - why didn't you follow up on his proposal?) by doing <xsl:template match="/"> <xsl:for-each select="x/y/z/amount"> <xsl:variable name="pos" select="position()"/> <!-- position within the for-each --> <!-- lots of other stuff omitted --> <xsl:value-of select="$pos, LIBPROD','
'"/> </xsl:for-each> </xsl:template> If you match nodes by descending through the input document (using template and apply-templates) you can also establish the ordinal of the currently matched node, this time by calling index-of, e.g. <xsl:template match="amount"> <xsl:variable name="pos" select="index-of( /x/y/z/amount, .)"/> <xsl:value-of select="$pos,.,'
'"/> </xsl:template> BTW, both functions (position, index-of) would have turned up in prominent positions after googling for "XSLT position within sequence". Cheers -W On 3 November 2014 22:56, Catherine Wilbur cwilbur@xxxxxxxxxxx < xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <-list/528976> (by > email <>)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|