Different result in BaseX 8.1 vs. 8.2.3 for path starting with slash

Thursday, 17 September 2015 · 3 messages · last reply 18 Sep 2015
AG
Amanda Galtman17 Sep 2015 20:33 #
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
CG
Christian Grün18 Sep 2015 10:45 #
Hi Amanda, Thanks for the elaborate report. I can confirm it is/was a bug (which got introduced by some path caching optimizations), and it is fixed in the latest snapshot [1]. Best, Christian [1] http://files.basex.org/releases/latest/
Quoted text · Amanda Galtman · 42 lines
On Thu, Sep 17, 2015 at 8:33 PM, Amanda Galtman <Amanda.Galtman at mathworks.com> wrote: > 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 > > >
AG
Amanda Galtman18 Sep 2015 14:11 #
That was fast. Thanks for the fix! Regards, Amanda
Quoted text · Christian Grün · 65 lines
> -----Original Message----- > From: Christian Grün [mailto:christian.gruen at gmail.com] > Sent: Friday, September 18, 2015 4:46 AM > To: Amanda Galtman <Amanda.Galtman at mathworks.com> > Cc: basex-talk at mailman.uni-konstanz.de > Subject: Re: [basex-talk] Different result in BaseX 8.1 vs. 8.2.3 for path > starting with slash > > Hi Amanda, > > Thanks for the elaborate report. I can confirm it is/was a bug (which got > introduced by some path caching optimizations), and it is fixed in the latest > snapshot [1]. > > Best, > Christian > > [1] http://files.basex.org/releases/latest/ > > > > On Thu, Sep 17, 2015 at 8:33 PM, Amanda Galtman > <Amanda.Galtman at mathworks.com> wrote: > > 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 > > > > > >

⚡Generated with XQuery