erroneous evaluation of position() on descendant axis

Tuesday, 9 November 2010 · 8 messages
MG
Martin Gieseking9 Nov 2010 22:18 #
Hi, while playing around with BaseX, I stumbled over some weird results in conjunction with positional predicates on the descendant axis. As far as I can see, there seems to be a bug in the evaluation of function position(). Example: When I load the following XML document and evaluate the path expression /descendant::c[1], both c element nodes are returned, but only the first one is expected. So, currently the result is identical to that of //c[1].
<a>
   <b>
     <c/>
   </b>
   <b>
     <c/>
   </b>
</a>
Best regards, Martin
JE
Jens Erat9 Nov 2010 22:25 #
Hi Martin, the predicate gets evaluate for each result of the XPath-step. BaseX's output is expected. The query you wanted to perform is (/descendant::c)[1] which only returns the first result over all. Best regards, Jens Erat » web: www.jenserat.de » email: jens.erat at uni-konstanz.de » phone: 0151 56961126 » weitere und aktuelle Kontaktmöglichkeiten: www.jenserat.de/kontakt
Quoted text · Martin Gieseking · 24 lines
Am 09.11.2010 um 22:18 schrieb Martin Gieseking: > Hi, > > while playing around with BaseX, I stumbled over some weird results in conjunction with positional predicates on the descendant axis. As far as I can see, there seems to be a bug in the evaluation of function position(). > > Example: > When I load the following XML document and evaluate the path expression /descendant::c[1], both c element nodes are returned, but only the first one is expected. So, currently the result is identical to that of //c[1]. > > <a> > <b> > <c/> > </b> > <b> > <c/> > </b> > </a> > > > Best regards, > Martin > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
MG
Martin Gieseking9 Nov 2010 22:58 #
Hi Jens, thank you for your immediate reply. Is this kind of evaluation specific to BaseX? All other XQuery/XPath processors I know don't require parenthesis to produce the result I expect. Usually, a predicate is part of the location step. On the descendant axis, all selected nodes are numbered in depth first order and position() evaluates to the number of the context node. Thus, /descendant::c[1] should return the first c node because there is only one node with position number 1. Best regards, Martin
Quoted text · Jens Erat · 54 lines
Am 09.11.2010 22:25, schrieb Jens Erat: > Hi Martin, > > the predicate gets evaluate for each result of the XPath-step. BaseX's > output is expected. > > The query you wanted to perform is (/descendant::c)[1] which only > returns the first result over all. > > Best regards, > *Jens Erat* > > * » *web:* www.jenserat.de <http://www.jenserat.de> > * » *email:* jens.erat at uni-konstanz.de > <mailto:jens.erat at uni-konstanz.de> > * » *phone:* 0151 56961126 <callto:+4915156961126> > > * » weitere und aktuelle *Kontaktmöglichkeiten:* > www.jenserat.de/kontakt <http://www.jenserat.de/kontakt> > > > Am 09.11.2010 um 22:18 schrieb Martin Gieseking: > >> Hi, >> >> while playing around with BaseX, I stumbled over some weird results in >> conjunction with positional predicates on the descendant axis. As far >> as I can see, there seems to be a bug in the evaluation of function >> position(). >> >> Example: >> When I load the following XML document and evaluate the path >> expression /descendant::c[1], both c element nodes are returned, but >> only the first one is expected. So, currently the result is identical >> to that of //c[1]. >> >> <a> >> <b> >> <c/> >> </b> >> <b> >> <c/> >> </b> >> </a> >> >> >> Best regards, >> Martin >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> <mailto:BaseX-Talk at mailman.uni-konstanz.de> >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
JE
Jens Erat9 Nov 2010 23:03 #
Quoted text · Martin Gieseking · 10 lines
Just tried Saxon myself and you're right. If you evaluate > let $doc := <a> > <b> > <c/> > </b> > <b> > <c/> > </b> > </a> > return $doc/descendant::c[1]
only one result node is returned, too. Maybe I've been a bit too fast after a glass of good wine... We will have another opinion soon I think... Jens Erat » web: www.jenserat.de » email: jens.erat at uni-konstanz.de » phone: 0151 56961126 » weitere und aktuelle Kontaktmöglichkeiten: www.jenserat.de/kontakt
Quoted text · Martin Gieseking · 71 lines
Am 09.11.2010 um 22:58 schrieb Martin Gieseking: > Hi Jens, > > thank you for your immediate reply. > Is this kind of evaluation specific to BaseX? All other XQuery/XPath processors I know don't require parenthesis to produce the result I expect. > Usually, a predicate is part of the location step. On the descendant axis, all selected nodes are numbered in depth first order and position() evaluates to the number of the context node. Thus, /descendant::c[1] should return the first c node because there is only one node with position number 1. > > Best regards, > Martin > > > > Am 09.11.2010 22:25, schrieb Jens Erat: >> Hi Martin, >> >> the predicate gets evaluate for each result of the XPath-step. BaseX's >> output is expected. >> >> The query you wanted to perform is (/descendant::c)[1] which only >> returns the first result over all. >> >> Best regards, >> *Jens Erat* >> >> * » *web:* www.jenserat.de <http://www.jenserat.de> >> * » *email:* jens.erat at uni-konstanz.de >> <mailto:jens.erat at uni-konstanz.de> >> * » *phone:* 0151 56961126 <callto:+4915156961126> >> >> * » weitere und aktuelle *Kontaktmöglichkeiten:* >> www.jenserat.de/kontakt <http://www.jenserat.de/kontakt> >> >> >> Am 09.11.2010 um 22:18 schrieb Martin Gieseking: >> >>> Hi, >>> >>> while playing around with BaseX, I stumbled over some weird results in >>> conjunction with positional predicates on the descendant axis. As far >>> as I can see, there seems to be a bug in the evaluation of function >>> position(). >>> >>> Example: >>> When I load the following XML document and evaluate the path >>> expression /descendant::c[1], both c element nodes are returned, but >>> only the first one is expected. So, currently the result is identical >>> to that of //c[1]. >>> >>> <a> >>> <b> >>> <c/> >>> </b> >>> <b> >>> <c/> >>> </b> >>> </a> >>> >>> >>> Best regards, >>> Martin >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> <mailto:BaseX-Talk at mailman.uni-konstanz.de> >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
CG
Christian Grünin reply to Martin Gieseking, 9 Nov 2010, 22:589 Nov 2010 23:04 #
Hi Martin, thanks for your feedback. Indeed that's a (pretty new) bug, which seems to be caused by the query compiler: your query is rewritten to /*:a/*:b/*:c[position() = 1] which should never happen if a position predicate is specified. Kinda surprising that none of the test cases stumbled across this issue. Be sure this will be fixed pretty soon. Best, Christian
Quoted text · Martin Gieseking · 79 lines
On Tue, Nov 9, 2010 at 10:58 PM, Martin Gieseking <martin.gieseking at uos.de> wrote: > Hi Jens, > > thank you for your immediate reply. > Is this kind of evaluation specific to BaseX? All other XQuery/XPath > processors I know don't require parenthesis to produce the result I expect. > Usually, a predicate is part of the location step. On the descendant axis, > all selected nodes are numbered in depth first order and position() > evaluates to the number of the context node. Thus, /descendant::c[1] should > return the first c node because there is only one node with position number > 1. > > Best regards, > Martin > > > > Am 09.11.2010 22:25, schrieb Jens Erat: >> >> Hi Martin, >> >> the predicate gets evaluate for each result of the XPath-step. BaseX's >> output is expected. >> >> The query you wanted to perform is (/descendant::c)[1] which only >> returns the first result over all. >> >> Best regards, >> *Jens Erat* >> >> * » *web:* www.jenserat.de <http://www.jenserat.de> >> * » *email:* jens.erat at uni-konstanz.de >> <mailto:jens.erat at uni-konstanz.de> >> * » *phone:* 0151 56961126 <callto:+4915156961126> >> >> * » weitere und aktuelle *Kontaktmöglichkeiten:* >> www.jenserat.de/kontakt <http://www.jenserat.de/kontakt> >> >> >> Am 09.11.2010 um 22:18 schrieb Martin Gieseking: >> >>> Hi, >>> >>> while playing around with BaseX, I stumbled over some weird results in >>> conjunction with positional predicates on the descendant axis. As far >>> as I can see, there seems to be a bug in the evaluation of function >>> position(). >>> >>> Example: >>> When I load the following XML document and evaluate the path >>> expression /descendant::c[1], both c element nodes are returned, but >>> only the first one is expected. So, currently the result is identical >>> to that of //c[1]. >>> >>> <a> >>> <b> >>> <c/> >>> </b> >>> <b> >>> <c/> >>> </b> >>> </a> >>> >>> >>> Best regards, >>> Martin >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> <mailto:BaseX-Talk at mailman.uni-konstanz.de> >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
MG
Martin Gieseking9 Nov 2010 23:20 #
Hi Christian, thanks for your confirmation. I'm glad to hear you already found the origin of the issue and that you will fix it soon. Best regards, and thank you for the great application. Martin
Quoted text · Christian Grün · 98 lines
Am 09.11.2010 23:04, schrieb Christian Grün: > Hi Martin, > > thanks for your feedback. Indeed that's a (pretty new) bug, which > seems to be caused by the query compiler: your query is rewritten to > > /*:a/*:b/*:c[position() = 1] > > which should never happen if a position predicate is specified. Kinda > surprising that none of the test cases stumbled across this issue. > > Be sure this will be fixed pretty soon. > > Best, > Christian > > > > On Tue, Nov 9, 2010 at 10:58 PM, Martin Gieseking > <martin.gieseking at uos.de> wrote: >> Hi Jens, >> >> thank you for your immediate reply. >> Is this kind of evaluation specific to BaseX? All other XQuery/XPath >> processors I know don't require parenthesis to produce the result I expect. >> Usually, a predicate is part of the location step. On the descendant axis, >> all selected nodes are numbered in depth first order and position() >> evaluates to the number of the context node. Thus, /descendant::c[1] should >> return the first c node because there is only one node with position number >> 1. >> >> Best regards, >> Martin >> >> >> >> Am 09.11.2010 22:25, schrieb Jens Erat: >>> >>> Hi Martin, >>> >>> the predicate gets evaluate for each result of the XPath-step. BaseX's >>> output is expected. >>> >>> The query you wanted to perform is (/descendant::c)[1] which only >>> returns the first result over all. >>> >>> Best regards, >>> *Jens Erat* >>> >>> * » *web:* www.jenserat.de<http://www.jenserat.de> >>> * » *email:* jens.erat at uni-konstanz.de >>> <mailto:jens.erat at uni-konstanz.de> >>> * » *phone:* 0151 56961126<callto:+4915156961126> >>> >>> * » weitere und aktuelle *Kontaktmöglichkeiten:* >>> www.jenserat.de/kontakt<http://www.jenserat.de/kontakt> >>> >>> >>> Am 09.11.2010 um 22:18 schrieb Martin Gieseking: >>> >>>> Hi, >>>> >>>> while playing around with BaseX, I stumbled over some weird results in >>>> conjunction with positional predicates on the descendant axis. As far >>>> as I can see, there seems to be a bug in the evaluation of function >>>> position(). >>>> >>>> Example: >>>> When I load the following XML document and evaluate the path >>>> expression /descendant::c[1], both c element nodes are returned, but >>>> only the first one is expected. So, currently the result is identical >>>> to that of //c[1]. >>>> >>>> <a> >>>> <b> >>>> <c/> >>>> </b> >>>> <b> >>>> <c/> >>>> </b> >>>> </a> >>>> >>>> >>>> Best regards, >>>> Martin >>>> _______________________________________________ >>>> BaseX-Talk mailing list >>>> BaseX-Talk at mailman.uni-konstanz.de >>>> <mailto:BaseX-Talk at mailman.uni-konstanz.de> >>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>> >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >
CG
Christian Grün9 Nov 2010 23:22 #
Hi Martin, we've just fixed the (somewhat embarassing) bug; feel free to tell us if you need a jar snapshot. Otherwise, you'll find the fix in the SVN repository and in the next minor release. Thanks again, Christian
Quoted text · Martin Gieseking · 117 lines
On Tue, Nov 9, 2010 at 11:20 PM, Martin Gieseking <martin.gieseking at uos.de> wrote: > Hi Christian, > > thanks for your confirmation. I'm glad to hear you already found the origin > of the issue and that you will fix it soon. > > Best regards, and thank you for the great application. > Martin > > > Am 09.11.2010 23:04, schrieb Christian Grün: >> >> Hi Martin, >> >> thanks for your feedback. Indeed that's a (pretty new) bug, which >> seems to be caused by the query compiler: your query is rewritten to >> >> /*:a/*:b/*:c[position() = 1] >> >> which should never happen if a position predicate is specified. Kinda >> surprising that none of the test cases stumbled across this issue. >> >> Be sure this will be fixed pretty soon. >> >> Best, >> Christian >> >> >> >> On Tue, Nov 9, 2010 at 10:58 PM, Martin Gieseking >> <martin.gieseking at uos.de> wrote: >>> >>> Hi Jens, >>> >>> thank you for your immediate reply. >>> Is this kind of evaluation specific to BaseX? All other XQuery/XPath >>> processors I know don't require parenthesis to produce the result I >>> expect. >>> Usually, a predicate is part of the location step. On the descendant >>> axis, >>> all selected nodes are numbered in depth first order and position() >>> evaluates to the number of the context node. Thus, /descendant::c[1] >>> should >>> return the first c node because there is only one node with position >>> number >>> 1. >>> >>> Best regards, >>> Martin >>> >>> >>> >>> Am 09.11.2010 22:25, schrieb Jens Erat: >>>> >>>> Hi Martin, >>>> >>>> the predicate gets evaluate for each result of the XPath-step. BaseX's >>>> output is expected. >>>> >>>> The query you wanted to perform is (/descendant::c)[1] which only >>>> returns the first result over all. >>>> >>>> Best regards, >>>> *Jens Erat* >>>> >>>> * » *web:* www.jenserat.de<http://www.jenserat.de> >>>> * » *email:* jens.erat at uni-konstanz.de >>>> <mailto:jens.erat at uni-konstanz.de> >>>> * » *phone:* 0151 56961126<callto:+4915156961126> >>>> >>>> * » weitere und aktuelle *Kontaktmöglichkeiten:* >>>> www.jenserat.de/kontakt<http://www.jenserat.de/kontakt> >>>> >>>> >>>> Am 09.11.2010 um 22:18 schrieb Martin Gieseking: >>>> >>>>> Hi, >>>>> >>>>> while playing around with BaseX, I stumbled over some weird results in >>>>> conjunction with positional predicates on the descendant axis. As far >>>>> as I can see, there seems to be a bug in the evaluation of function >>>>> position(). >>>>> >>>>> Example: >>>>> When I load the following XML document and evaluate the path >>>>> expression /descendant::c[1], both c element nodes are returned, but >>>>> only the first one is expected. So, currently the result is identical >>>>> to that of //c[1]. >>>>> >>>>> <a> >>>>> <b> >>>>> <c/> >>>>> </b> >>>>> <b> >>>>> <c/> >>>>> </b> >>>>> </a> >>>>> >>>>> >>>>> Best regards, >>>>> Martin >>>>> _______________________________________________ >>>>> BaseX-Talk mailing list >>>>> BaseX-Talk at mailman.uni-konstanz.de >>>>> <mailto:BaseX-Talk at mailman.uni-konstanz.de> >>>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>>> >>> >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>> >> > >
MG
Martin Gieseking9 Nov 2010 23:28 #
Hi Christian, wow, that was fast. Thanks! I'll check out the sources from svn tomorrow and will continue playing around with BaseX then. :) Regards, Martin
Quoted text · Christian Grün · 130 lines
Am 09.11.2010 23:22, schrieb Christian Grün: > Hi Martin, > > we've just fixed the (somewhat embarassing) bug; feel free to tell us > if you need a jar snapshot. Otherwise, you'll find the fix in the SVN > repository and in the next minor release. > > Thanks again, > Christian > > > > On Tue, Nov 9, 2010 at 11:20 PM, Martin Gieseking > <martin.gieseking at uos.de> wrote: >> Hi Christian, >> >> thanks for your confirmation. I'm glad to hear you already found the origin >> of the issue and that you will fix it soon. >> >> Best regards, and thank you for the great application. >> Martin >> >> >> Am 09.11.2010 23:04, schrieb Christian Grün: >>> >>> Hi Martin, >>> >>> thanks for your feedback. Indeed that's a (pretty new) bug, which >>> seems to be caused by the query compiler: your query is rewritten to >>> >>> /*:a/*:b/*:c[position() = 1] >>> >>> which should never happen if a position predicate is specified. Kinda >>> surprising that none of the test cases stumbled across this issue. >>> >>> Be sure this will be fixed pretty soon. >>> >>> Best, >>> Christian >>> >>> >>> >>> On Tue, Nov 9, 2010 at 10:58 PM, Martin Gieseking >>> <martin.gieseking at uos.de> wrote: >>>> >>>> Hi Jens, >>>> >>>> thank you for your immediate reply. >>>> Is this kind of evaluation specific to BaseX? All other XQuery/XPath >>>> processors I know don't require parenthesis to produce the result I >>>> expect. >>>> Usually, a predicate is part of the location step. On the descendant >>>> axis, >>>> all selected nodes are numbered in depth first order and position() >>>> evaluates to the number of the context node. Thus, /descendant::c[1] >>>> should >>>> return the first c node because there is only one node with position >>>> number >>>> 1. >>>> >>>> Best regards, >>>> Martin >>>> >>>> >>>> >>>> Am 09.11.2010 22:25, schrieb Jens Erat: >>>>> >>>>> Hi Martin, >>>>> >>>>> the predicate gets evaluate for each result of the XPath-step. BaseX's >>>>> output is expected. >>>>> >>>>> The query you wanted to perform is (/descendant::c)[1] which only >>>>> returns the first result over all. >>>>> >>>>> Best regards, >>>>> *Jens Erat* >>>>> >>>>> * » *web:* www.jenserat.de<http://www.jenserat.de> >>>>> * » *email:* jens.erat at uni-konstanz.de >>>>> <mailto:jens.erat at uni-konstanz.de> >>>>> * » *phone:* 0151 56961126<callto:+4915156961126> >>>>> >>>>> * » weitere und aktuelle *Kontaktmöglichkeiten:* >>>>> www.jenserat.de/kontakt<http://www.jenserat.de/kontakt> >>>>> >>>>> >>>>> Am 09.11.2010 um 22:18 schrieb Martin Gieseking: >>>>> >>>>>> Hi, >>>>>> >>>>>> while playing around with BaseX, I stumbled over some weird results in >>>>>> conjunction with positional predicates on the descendant axis. As far >>>>>> as I can see, there seems to be a bug in the evaluation of function >>>>>> position(). >>>>>> >>>>>> Example: >>>>>> When I load the following XML document and evaluate the path >>>>>> expression /descendant::c[1], both c element nodes are returned, but >>>>>> only the first one is expected. So, currently the result is identical >>>>>> to that of //c[1]. >>>>>> >>>>>> <a> >>>>>> <b> >>>>>> <c/> >>>>>> </b> >>>>>> <b> >>>>>> <c/> >>>>>> </b> >>>>>> </a> >>>>>> >>>>>> >>>>>> Best regards, >>>>>> Martin >>>>>> _______________________________________________ >>>>>> BaseX-Talk mailing list >>>>>> BaseX-Talk at mailman.uni-konstanz.de >>>>>> <mailto:BaseX-Talk at mailman.uni-konstanz.de> >>>>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>>>> >>>> >>>> _______________________________________________ >>>> BaseX-Talk mailing list >>>> BaseX-Talk at mailman.uni-konstanz.de >>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>>> >>> >> >> >

⚡Generated with XQuery