position() question

Subject: position() question
From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 17 Nov 1999 12:26:56 +0100 (MET)
Hi there,

I'm a little bit confused about the return value of position().
It should be "the context position from the expression evaluation context".
Hmm ...

Given the following xml fragment:
   <list>
      <item name="one"/>
      <item name="two"/>
      <item name="three"/>
   </list>

And given the following xsl stylesheet fragment:
   <xsl:template match="list">
      <h3><xsl:text>Version a</xsl:text></h3>
      <xsl:apply-templates/>
      <h3><xsl:text>Version b</xsl:text></h3>
      <xsl:for-each select="item">
         <xsl:call-template name="output-position"/>
      </xsl:for-each>
   </xsl:template>

   <xsl:template match="item">
      <xsl:call-template name="output-position"/>
   </xsl:template>

   <xsl:template name="output-position">
      <xsl:value-of select="position()"/>
      <xsl:text>. </xsl:text>
      <xsl:value-of select="@name"/>
      <br/>
   </xsl:template>

I.e. I call a template named "output-position" (which prints the
current position) once from <xsl:template match="item"> and once
within a <xsl:for-each select="item">.

The result (xt or LotusXSL) looks like (newlines added):
   <h3>Version a</h3>
      2. one<br>
      4. two<br>
      6. three<br>
   <h3>Version b</h3>
      1. one<br>
      2. two<br>
      3. three<br>

Why do I get in version a even numbers 2, 4, 6, ... ?

Thanks for any explanation,
Oliver


/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread