[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] position() question
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
|
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
|