Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Templates - basic usage (7/12) >

Current position

The function position() gives position of the item in currently processed sequence.

XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/">
                  <xsl:apply-templates  select="aaa"/>
            </xsl:template>

            <xsl:template  match="aaa">
                  <xxx>
                        <xsl:apply-templates  select="bbb"/>
                  </xxx>
                  <yyy>
                        <xsl:apply-templates  select="bbb[position()>2]"/>
                  </yyy>
            </xsl:template>

            <xsl:template  match="bbb">
                  <zzz>
                        <xsl:value-of  select="position()"/>
                        <xsl:text>. </xsl:text>
                        <xsl:value-of  select="."/>
                  </zzz>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb>A</bbb>
            <bbb>B</bbb>
            <bbb>C</bbb>
            <bbb>D</bbb>
      </aaa>
Output

      <xxx>
            <zzz>1. A</zzz>
            <zzz>2. B</zzz>
            <zzz>3. C</zzz>
            <zzz>4. D</zzz>
      </xxx>
      <yyy>
            <zzz>1. C</zzz>
            <zzz>2. D</zzz>
      </yyy>


Previous chapter: - - -
Next chapter: Sequences
Previous page: Element xsl:apply-templates
Next page: Shared templates for several elements

Kevin Carr in Stanton

Natural Skin Care and European Soaps
TickTalk 5
city of stanton
internetusers


You can also get Organic Skin Care products from Bliss Bath Body and you must check out their Natural Body Lotions and bath soaps

Now if you are looking for the best deals on surf clothing from Quiksilver and Roxy then you have to check these amazing deals here:

Hey, check out this Organic Skin Care European Soaps along with Natural Lavender Body Lotion and shea butter

and we can get surf t shirts surfing shirt and And you must check out this website swim suit swimming suit and swim trunks