We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
As described in the Stack Overflow question XPath: What does the «/» operator at the beginning of a rooted path expression exactly match?, it seems BaseX' behavior regarding predicates and collections is a little bit surprising.
Two files in a folder forming a collection later:
/foo/myDocs/1.xml
<root myAtt="one"/>
/foo/myDocs/2.xml
<root myAtt="two"/>
Running a query
collection('/tmp/myDocs')[/root/@myAtt = 'one']
resulting in
<root myAtt="one"/> <root myAtt="two
to filter the documents still returns both <root/> nodes in BaseX, not in Saxon, which only returns the first document:
<root/>
BaseX is optimizing this to
((db:open-pre("myDocs",0), ...))[((db:open-pre("myDocs",0), ...)/*:root/@*:myAtt = "one")]
and replaces the implicit root(.) call with the internal db-open-pre statement returning the collection. To me, this looks like an optimizer issue.
root(.)
db-open-pre
Considering the / and root() semantics, I would expect this merely to have the meaning of
/
root()
collection('/tmp/myDocs')[root(.)/root/@myAtt = 'one']
with the optimized query
((db:open-pre("myDocs",0), ...))[(root(.)/root/@myAtt = "one")]
returning
which would mean the documents contained in the collection will be tested one by one.
Enforcing an explicit self-step also resolves the issue:
collection('/tmp/myDocs')/self::node()[/root/@myAtt = 'one']
returning the expected
The text was updated successfully, but these errors were encountered:
Thanks for the detailed explanation; I agree.
Sorry, something went wrong.
A command-script to reproduce:
<commands> <create-db name='db'/> <add path='a.xml'><a/></add> <add path='b.xml'><b/></add> <xquery>.[/a]</xquery> <drop-db name='db'/> </commands>
7210714
No branches or pull requests
As described in the Stack Overflow question XPath: What does the «/» operator at the beginning of a rooted path expression exactly match?, it seems BaseX' behavior regarding predicates and collections is a little bit surprising.
Example Input
Two files in a folder forming a collection later:
/foo/myDocs/1.xml
:<root myAtt="one"/>
/foo/myDocs/2.xml
:<root myAtt="two"/>
The Issue
Running a query
resulting in
to filter the documents still returns both
<root/>
nodes in BaseX, not in Saxon, which only returns the first document:BaseX is optimizing this to
and replaces the implicit
root(.)
call with the internaldb-open-pre
statement returning the collection. To me, this looks like an optimizer issue.Using an explicit root call
Considering the
/
androot()
semantics, I would expect this merely to have the meaning ofwith the optimized query
returning
which would mean the documents contained in the collection will be tested one by one.
Enforcing a self-step
Enforcing an explicit self-step also resolves the issue:
returning the expected
The text was updated successfully, but these errors were encountered: