xsl-list
[Top] [All Lists]

RE: [xsl] XPath behaviour

2006-12-28 15:54:50
XPath 2.0 allows a parenthesized expression to appear as a step in a path
expression; XPath 1.0 does not.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Lars Rönnbäck [mailto:lars(_at_)delicate(_dot_)se] 
Sent: 28 December 2006 02:11
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] XPath behaviour

Dear list,

I am having a problem with an XPath expression. The program I 
am using is Stylus Studio 2007 and I am building an XSLT 1.0 
stylesheet. Within the program you have access to an XPath 
Query Editor. I used that together with an XML file to build 
the following:

/calendar/year/month/day[(_at_)month = 3 and index = 
21]/(.|following::day)[(_at_)phase = 
2][1]/(.|following::day)[(_at_)weekday = 6][1]

This path will correctly find easter when I execute it in the 
query editor. However, if I create a simple stylesheet that 
uses the path in a <xsl:value-of select="..."> I get a 
compilation error.

Using the built-in processor I get the message:
Testing.xsl (5, 2): Expected node test in value-of

Using MSXML6 I get the message:
NodeTest expected here.

/calendar/year/month/day[(_at_)month = 3 and index = 
21]/-->(<--.|following::day)[(_at_)phase = 
2][1]/(.|following::day)[(_at_)weekday = 6][1]

Using Saxon 6.5.5 I get the message:
com.icl.saxon.expr.XPathException: Error in expression 
/calendar/year/month/day[(_at_)month = 3 and index = 
21]/(.|following::day)[(_at_)phase = 
2][1]/(.|following::day)[(_at_)weekday = 6][1]:
Unexpected token [(] in path expression

Using the .NET XslTransform I get the message:
System.Xml.Xsl.XsltException: 
'/calendar/year/month/day[(_at_)month = 3 and index = 
21]/(.|following::day)[(_at_)phase = 
2][1]/(.|following::day)[(_at_)weekday = 6][1]' is an invalid 
XPath expression. --->
System.Xml.XPath.XPathException: Expression must evaluate to 
a node-set.

From this I gather that it doesn't like the parenthesis. 
However, if I remove them I do not get the desired behaviour. 
Instead, three days are matched and none of them correctly.

How am I supposed to group the union in such a way that I can 
apply the subset rules (within brackets) to it? It would also 
be interesting to know why this works in the query editor, 
but none of the processors.

Any help is appreciated,
Regards,
Lars Rönnbäck


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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