Variables in XPath expressions

Subject: Variables in XPath expressions
From: Emmanuel Pietriga <emmanuel.pietriga@xxxxxxxxxxxxxx>
Date: Wed, 29 Mar 2000 08:17:10 +0200
Hi.

I just want to be sure of something.

I want to select an element wrt its position: el1/*[position()=3], but
the position is extracted from the source document.
So what I thought I would do was put the value of the wanted position in
a xsl:variable
<xsl:variable name="i">
  <xsl:value-of select="el1/aPosition"/>
</xsl:variable>

and then use the value of this variable later in my xpath selector, like
this:
<xsl:value-of select="el1/*[position()={$i}]"/>

But the engine tells me that $ is not allowed.   (I'm using XP+XT)

I've figured out another way of doing what I want just using number(),
but I'd like to be sure that variables aren't allowed in an XPath
expression (I think I read somewhere that variables could be used in
xpath expressions in some cases, depending on the xsl instruction used)

Thanks.

Emmanuel.



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


Current Thread