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

RE: Are variables allowed in XPATHs?

Subject: RE: Are variables allowed in XPATHs?
From: "Roger Glover" <glover_roger@xxxxxxxxx>
Date: Mon, 3 Feb 2003 00:19:39 -0600
variable xpaths xslt
Harry Ohlsen wrote:

> > It might help if you gave us a look at the exact pattern 
> > to which XMLSpy was objecting.
> 
> Sorry, I thought the problem was pretty generic 
> and didn't want to muddy things by being too 
> specific.  Ie, is it legal to use a variable in an 
> XPATH?

The problem is that the situation is not that simple.  In
XSLT XPath *Expressions*, it certainly is legal to have
variable values.  You can verify this with examples from the
following sections of the spec:
    http://www.w3.org/TR/xslt#attribute-value-templates
    http://www.w3.org/TR/xslt#variable-values
    http://www.w3.org/TR/xslt#message
not to mention many, many other examples from the XSL FAQ:
    http://www.dpawson.co.uk/xsl/xslfaq.html

However, XSLT XPath *PATTERNS* (often?) may not contain
variable values. Patterns are the more restricted XPath
syntax used in xsl:template/@match, xsl:key/@match,
xsl:number/@count, and xsl:number/@from.  See the spec here:
    http://www.w3.org/TR/xslt#section-Defining-Template-Rules

I say "(often?)" above since the section on patterns says
nothing about disallowing variables, and while the spec
specifically prohibits variable and parameter values in the
two "match" attributes above, it is silent about any such
restriction on the "count" and "from" attributes of
xsl:number.


> Here's the code it's complaining about (apologies 
> for the line wrapping):
> 
> <xsl:template name="delete-section" 
> match="/main/document/item[property[(name='report') 
> and (value=$sectionToDelete)]]">
>      </xsl:template>

So, it is very useful to see your specific case, since it
falls into this latter category of patterns that cannot use
variable values.  Xalan should have flagged this as an error.


-- Roger Glover
   glover_roger@xxxxxxxxx


 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.