FYI, this is fixed in 4.0-5, which was recently released.

-Danny

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of David Sewell
Sent: Thursday, March 26, 2009 8:16 PM
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

Reply via email to