Subject: Re: [xsl] Usage of Asterisk in XPath expressions From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 22 Mar 2019 16:51:10 -0000 |
As Martin points out, this syntax is legal (as a multiplication operator) in XPath 3.1, but not in XPath 2.0. This should explain why the behaviour has changed from one Saxon version to another. In Saxon 9.7, XPath 3.1 syntax was only available if explicitly requested, but in Saxon 9.8 it became the default. Whether it succeeds or fails at execution time depends on the source document: if there's no ancestor named foo and/or no attribute named a then it will succeed and return an empty sequence, whose effective boolean value is false. Specifying version="2.0" doesn't prevent an XSLT 3.0 processor accepting 3.0 (or 3.1) syntax; it provides a clue that you weren't intending to take advantage of 3.0 syntax, but that's all. Terse languages such as XPath (and regular expressions) do have the disadvantage that when you get the syntax wrong, your expression often means something unintended rather than being invalid. Michael Kay Saxonica > On 22 Mar 2019, at 11:01, Philipp Nanz philipp.nanz@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Hello there, > > due to a typo, we missed the colon between the namespace prefix and the wildcard in a XPath expression. To my surpise, this causes static errors in some version of Saxon and runs flawlessly in others, although I would expect this to be static error. > > Suppose this data: > > <foo:bar xmlns:foo="http://test/ns/foo" a="b">Yadda</foo:bar> > > Then suppose this stylesheet: > > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:foo="http://test/ns/foo" > version="2.0"> > > <xsl:template match="foo:bar"> > <xsl:if test="ancestor-or-self::foo*[@a]"> > <xsl:copy> > <xsl:value-of select="."/> > </xsl:copy> > </xsl:if> > </xsl:template> > > </xsl:stylesheet> > > As you can see the colon is missing after the namespace prefix foo. What baffles me is that different versions of Saxon exhibit different behavious here, and especially newer versions don't seem to treat this as a problem at all. > > * Saxon 9.6: Stops with something that looks like an internal error > * Saxon 9.7: Says I need to enable XPath 3.1 to use this expression?!? > * Saxon 9.8, 9.9: Don't run into an error at all > > That makes me wonder: Is this an error at all? or is there some wildcard feature or something in XPath 3.1 that I cam't find in the docs? > > Thanks in advance for any insights! > > Kind regards, > > Philipp
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Usage of Asterisk in XPat, Liam R. E. Quin liam | Thread | [xsl] Re: Usage of Asterisk in XPat, Philipp Nanz philipp |
Re: [xsl] Usage of Asterisk in XPat, Martin Honnen martin | Date | Re: [xsl] Usage of Asterisk in XPat, Liam R. E. Quin liam |
Month |