RE: [xsl] invalid xpath expression

Subject: RE: [xsl] invalid xpath expression
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Wed, 28 May 2003 14:19:50 -0400
[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


Current Thread