-
-
Notifications
You must be signed in to change notification settings - Fork 190
self:: axis inside predicate throws XPST0005 #2445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@wolfgangmm as the author of #249 could you chime in here. I can reproduce these errors, but i am not sure what the optimal fix is here, should [1] really return an empty sequence? |
Retested with e2bf08c let $node :=
<test>
<el>test <el1>test</el1> test <el2>test</el2></el>
</test>
return (
$node/el[./self::el1],
$node/el[./descendant::*/self::el1],
$node/el[descendant::*/self::el1],
$node/el[descendant::*/(./self::el1)]
) |
It confirms that the optimisation added in #249 is the culprit. While |
@wolfgang @adamretter Maybe it would be enough to return an empty sequence instead of throwing an error in these two cases? exist/exist-core/src/main/java/org/exist/xquery/LocationStep.java Lines 273 to 281 in 34767fa
|
A simplified test: <foo><bar/></foo>/bar[self::baz] Returns a static error:
The same query returns the empty sequence in BaseX and Saxon. Only eXist raises this error. eXist correctly returns empty sequence for other axes: <foo><bar/></foo>/bar[
ancestor::baz | ancestor-or-self::baz | attribute::baz |
child::baz | descendant::baz | descendant-or-self::baz |
following::baz | following-sibling::baz | parent::baz |
preceding::baz | preceding-sibling::baz
] Introducing |
I have a fix in the making. |
Fixes eXist-db#2445 By definition the following Xpaths must evaluate to an empty sequence - `<a/>[self::b]` - `<a/>/@b/c` - `<a/>/text()/b` Instead of throwing an Exception the staticReturnType of the current step and the contextInfo returnType are set to Type.EMPTY.
The question whether this is a bug or the expected behaviour is a general decision the existdb community has to answer: Do we provide the StaticTyping feature or not. Even if we decide to adhere to provide the StaticTyping feature it is:
|
As discussed during the Community Call, eXist doesn't implement the Static Typing optional feature (https://www.w3.org/TR/xquery-31/#id-static-typing-feature). Next actions:
|
Fixes eXist-db#2445 By definition the following Xpaths must evaluate to an empty sequence - `<a/>[self::b]` - `<a/>/@b/c` - `<a/>/text()/b` Instead of throwing an Exception the staticReturnType of the current step and the contextInfo returnType are set to Type.EMPTY.
Fixes eXist-db#2445 By definition the following Xpaths must evaluate to an empty sequence - `<a/>[self::b]` - `<a/>/@b/c` - `<a/>/text()/b` Instead of throwing an Exception the staticReturnType of the current step and the contextInfo returnType are set to Type.EMPTY.
Fixes eXist-db#2445 By definition the following Xpaths must evaluate to an empty sequence - `<a/>[self::b]` - `<a/>/@b/c` - `<a/>/text()/b` Instead of throwing an Exception the staticReturnType of the current step and the contextInfo returnType are set to Type.EMPTY.
Fixes eXist-db#2445 By definition the following Xpaths must evaluate to an empty sequence - `<a/>[self::b]` - `<a/>/@b/c` - `<a/>/text()/b` Instead of throwing an Exception the staticReturnType of the current step and the contextInfo returnType are set to Type.EMPTY.
Fixes eXist-db#2445 By definition the following Xpaths must evaluate to an empty sequence - `<a/>[self::b]` - `<a/>/@b/c` - `<a/>/text()/b` Instead of throwing an Exception the staticReturnType of the current step and the contextInfo returnType are set to Type.EMPTY.
refs eXist-db#2445 These tests aim to ensure that certain XPath expressions no longer raise error XPST0005 as exist-db does not implement the static typing feature and this feature is even dropped entirely with the next version of XQuery.
refs eXist-db#2445 These tests aim to ensure that certain XPath expressions no longer raise error XPST0005 as exist-db does not implement the static typing feature and this feature is even dropped entirely with the next version of XQuery.
refs eXist-db#2445 These tests aim to ensure that certain XPath expressions no longer raise error XPST0005 as exist-db does not implement the static typing feature and this feature is even dropped entirely with the next version of XQuery.
refs eXist-db#2445 These tests aim to ensure that certain XPath expressions no longer raise error XPST0005 as exist-db does not implement the static typing feature and this feature is even dropped entirely with the next version of XQuery.
What is the problem
When used inside a predicate, the
self::
axis throws error XPST0005 in some cirumstances, even though nothing is wrong with the expression. This happens with the most recent eXist releases 4.5.0 and 5.0.0-RC5 (and earlier releases).What did you expect
I would expect the query to run without errors (confirmed with Saxon).
Describe how to reproduce or add a test
Behaviour is the same for in-memory and stored nodes, so these stand-alone test cases will illustrate the problem.
[1]
This should return an empty result set. Instead following error is being thrown:
Of course, this example is contrived, in order to present a simple test case. It seems, however, that the empty node set returned by the test condition in the predicate is significant. If the
self::
axis does select a node (e.g.$node/el[self::el]
), the query does run without error.[2]
I've found another failing variant XQuery where the
self::
axis occurs inside a predicate and doesn't select a node. Here, parentheses seem to be triggering the same error:This should return the node:
Instead, above error XPST0005 is being thrown.
Here, the parentheses seem to be crucial. Compare with the same predicate without parentheses:
...which does return the correct result:
I've found a reference to this error message in the ML archives (https://sourceforge.net/p/exist/mailman/message/32496312/), and a bug fix in Github. So there's a chance this issue is related to #249.
Context information
Please always add the following information
The text was updated successfully, but these errors were encountered: