xsl-list
[Top] [All Lists]

RE: invalid xpath expression

2003-05-28 11:19:50
[abbouh]

my xsl file is:

<xsl:choose>
<xsl:when test=".=list">
<xsl:variable name="n" select="12"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="n" select="2"/>
</xsl:otherwise>
</xsl:choose>
-------------------
<xsl:variable name="m" select="$n"/>

i receive the error :invalid xpath expression!
so what the problem in <xsl:variable name="m" select="$n"/>?

The variable $n only exists in the scope of the block in which it is
defined.  It is not known outside that block.  So it is not known
outside the xsl:othewise block.  You just have to put the whole
xsl:choose block inside the variable declaration.  Then the variable
will be visible.

I think you meant select="'12'", did you not? Otherwise  select will be
looking for a node named 12, and there can not be such a node, since it
is an illegal name for an xml element..

Cheers,

Tom P

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



<Prev in Thread] Current Thread [Next in Thread>