Hi,
While debugging a query, I noticed a difference in behavior between BaseX 8.1 and BaseX 8.2.3. I boiled it down to this short example, which I hope is understandable even if you don't have my database at hand.
for $node in collection("DocLibrary")//chapter
return $node/ends-with(/book/title,'Examples')
In version 8.2.3, all the results are false, which is unexpected. In version 8.1, I get a mix of true and false values, which is what I expect based on the documents in the database.
The XQuery 3.0 and 3.1 specs say the following in the "Path Expressions" section:
A "/" at the beginning of a path expression is an abbreviation for the initial step (fn:root(self::node()) treat as document-node())/ (however, if the "/" is the entire path expression, the trailing "/" is omitted from the expansion.) The effect of this initial step is to begin the path at the root node of the tree that contains the context node.
If I make the substitution mentioned in the spec,
for $node in collection("DocLibrary")//chapter
return $node/ends-with((fn:root(self::node()) treat as document-node())/book/title,'Examples')
then I get expected results in both BaseX 8.1 and BaseX 8.2.3. Do my unexpected results with 8.2.3 arise from a bug?
Perhaps the syntax is not that intuitive in either case (my real query is generated rather than coded by hand, so normally no human needs to look at it), but I still wanted to pose this question in case there is a bug.
Thanks,
Amanda