[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

Subject: Re: How do I set up a counter or sequence number variable
From: "Wolfgang Laun wolfgang.laun@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 4 Nov 2014 11:13:16 -0000
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','&#xa;'"/>
        </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,.,'&#xa;'"/>
  </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 <>)

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.