[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: invalid xpath expression

Subject: RE: invalid xpath expression
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Wed, 28 May 2003 13:23:33 -0500
invalid xpath expression
> 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"/>?

A variable is only in scope in the element in which it is declared.
So the first n is only in scope within the first <when>.
The second n is only in scope within the <otherwise>.
No n is in scope for your select="$n".

To fix the problem, put the <choose> inside the <variable name="n">:

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


This is a kind of thing that is usually taught in introductory
textbooks for XSLT, such as Jeni Tennison's.

Lars


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.