Based on all the discussion I sent a note to MarkLogic support, and
there is now a bug report filed.
David
On Sat, 28 Mar 2009, Geert Josten wrote:
Hi Pradeep,
I think the case has been cracked on the Xquery-talk list (thanks David, for
the cross-post). If you keep in mind that something like $xml//p[2] actually
expands to $xml/descendant-or-self::node()/child::p[position() = 2], then there
is really no reason for doubt..
(I forgot about the child:: part actually..)
Section 3.2.2 of the Xpath 2.0 recommendation says that predicates apply to the
inner focus, with which is meant the 'child::p' part. So
$xml/descendant-or-self::node() returns a list of div nodes (and $xml itself),
but for each of them the list of child::p is calculated and the predicate
should apply to that as context list.
I am starting to think that MarkLogic Server is translating //p wrongly to
/descendant::p instead of /descendant-or-self::node()/child::p. That could
explain its current behaviour.
Attached a self-contained testsuite with some surprising results which helped
me come to this conclusion..
Kind regards,
Geert
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
Geert Josten
Sent: zaterdag 28 maart 2009 11:29
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] issue with XPATH
David,
You triggered some nice discussion on xquery-talk.. ;-)
Kind regards,
Geert
Drs. G.P.H. Josten
Consultant
http://www.daidalos.nl/
Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
http://www.daidalos.nl/
KvK 27164984
De informatie - verzonden in of met dit emailbericht - is
afkomstig van Daidalos BV en is uitsluitend bestemd voor de
geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen,
verzoeken wij u het te verwijderen. Aan dit bericht kunnen
geen rechten worden ontleend.
From: [email protected]
[mailto:[email protected]] On Behalf Of David
Sewell
Sent: vrijdag 27 maart 2009 4:16
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] issue with XPATH
I agree with Florent that it appears to be a MarkLogic bug.
A self-contained test case follows, using an XML node
variable rather
than a call to fn:doc(). The first four return values
should contain
both p2 and p4. Only the fifth one should contain p2 alone. Under
MarkLogic, the first two return only p2.
For what it's worth, Saxon 9.1 returns the expected results, eXist
does not (but differs from MarkLogic in that set2 and
set4 contain only p2).
If Florent and I (and Michael Kay!) are wrong about this, I'd sure
like to know why.
let $xml :=
<root>
<div>
<p>p1</p>
<p>p2</p>
</div>
<div>
<p>p3</p>
<p>p4</p>
</div>
</root>
return (
(: set1 - return all p's with position() = 2. Expected
result: (p2, p4). :)
<set1>{ $xml/descendant-or-self::node()/p[position() eq 2]
}</set1>,
(: set2 - XPath abbreviation // is equivalent to
/descendant-or-self::node()/
by definition. Result should still be (p2, p4) :)
<set2>{ $xml//p[position() eq 2] }</set2>,
(: set3 - XPath predicate [2] is equivalent to
[position() eq 2].
Results
should be identical to set1/set2 :)
<set3>{ $xml/descendant-or-self::node()/p[2] }</set3>,
(: set4 - final syntax variation with full abbreviation.
Results should
still be identical to set1/set2/set3 :)
<set4>{ $xml//p[2] }</set4>,
(:set5 - This is the only one that should return a
single node, p2.
The XPath should return the second instance of all <p>
descendants
of $xml. :)
<set5>{ $xml/descendant::p[2] }</set5>
)
On Thu, 26 Mar 2009, Florent Georges wrote:
Geert Josten wrote:
Though I was surprised, I now think MarkLogic Server is
responding
correctly.
Sounds like a bug to me. If you look at the definition of
a numeric
predicate (http://www.w3.org/TR/xpath20/#id-predicates,
point 1.) you
see that [1] is defined as [position() eq 1]. And in this
expression,
using = and eq is the same.
Regards,
--
David Sewell, Editorial and Technical Manager ROTUNDA, The
University
of Virginia Press PO Box 801079, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: [email protected] Tel: +1 434 924 9973
Web: http://rotunda.upress.virginia.edu/
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
--
David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 801079, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: [email protected] Tel: +1 434 924 9973
Web: http://rotunda.upress.virginia.edu/
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general