RE: [xsl] Problem getting position of node

Subject: RE: [xsl] Problem getting position of node
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Tue, 21 Mar 2006 10:46:50 +0200
Hi,

>       Iam attempting to append the position of the current
>node to  the value of each of the node's attributes but Iam
>having problems in achieving this.
>
>Iam getting the following error:
>
>Error at xsl:value-of on line 27 of file:/D:/xamp.xsl:
>  Error in expression concat(., parent::node()/position()):
>Unexpected token [<function>] in path expression
>
>
>The line causing the problem is
>
><xsl:attribute name="{name(.)}">
><xsl:value-of select="concat(., parent::node()/position())"/>

parent::node()/position() is the problem, you can't use a function as a right
side operator in a path expression. Also, position() does not return the
position of a node in it's siblings, but rather the context position. You
want

  <xsl:value-of select="."/>
  <xsl:number count="*"/>

Cheers,

Jarno

Current Thread