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

Re: Restrictions on XPath expressions in <xsl:key>

Subject: Re: Restrictions on XPath expressions in <xsl:key>
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 19 Dec 2007 16:59:47 -0500
Re:  Restrictions on XPath expressions in <xsl:key>
At 2007-12-19 16:39 -0500, Nassar, Anthony wrote:
Does someone know a reason why this won't compile:

<xsl:key name="templates"
match="/onm:NetworkModel/onm:Graph/(onm:Nodes|onm:Links)/(onm:Link|onm:N
ode)/onm:Templates/onm:Template" use="@Name" />

Because match= attributes are restricted to be XPath patterns, not all XPath expressions.


...but this will:

<xsl:template match="onm:Graph">
    <xsl:copy>
        <xsl:if
test="(onm:Nodes/onm:Node|onm:Links/onm:Link)/onm:Attributes/onm:Attribu
te">

Because test= is not restricted to only being a pattern.


In other words, why can't an XPath expression in an <xsl:key> element
include parentheses and union operators?

Because patterns are restricted expressions that promote compile-time algorithms for detecting patterns of nodes in the source tree. Not all expressions are like this, so the XPath designers categorized a subset of all XPath expressions, called them patterns, and they are the only ones allowed in a match= attribute.


By the way, what is the order
of precedence between '/' and '|'? I'd understand '\' to have higher
precedence, in which case the latter expression above is actually wrong,
though it's been working for me.

A step separator "/" has higher precedence in the syntax than the expression separator "|", which is why the parentheses are needed to tell a processor that the step is made up of two separate expressions.


Note that in XPath 1.0 the expression separator and parentheses are only allowed in the first step of a multiple-step location path.

I'm using .NET 2.0, so let me know if this is a platform question, in
which case I'll post elsewhere.

It is an XSLT 2.0 question, not a platform-dependent question.


I hope this helps.

. . . . . . . . . . . . . Ken

--
Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

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.