The fact that MarkLogic expands a / at the beginning of an XPath is just a
convenient extension. That a bare / as start within a predicated works like
root()/ is conform spec to my knowledge.



Kind regards,

Geert



*Van:* [email protected] [mailto:
[email protected]] *Namens *Szabolcs Illes
*Verzonden:* donderdag 23 februari 2012 15:50
*Aan:* MarkLogic Developer Discussion
*Onderwerp:* Re: [MarkLogic Dev General] weird xpath behaviour



Hi Geert,



That explains it, is it a bug  or a feature?  ( The same thing works as
expected in eXists … )



Cheers,

Szabolcs



*From:* [email protected]
[mailto:[email protected]] *On Behalf Of *Geert Josten
*Sent:* 23 February 2012 14:21
*To:* MarkLogic Developer Discussion
*Subject:* Re: [MarkLogic Dev General] weird xpath behaviour



Hi Szabolcs,



Evan pointed out the following to me recently. / at the start of an XPath
expression is interpreted within MarkLogic as ‘collection()/’. A / within a
predicate,  however, is not. It is effectively interpreted as ‘root()/ ‘.



Kind regards,

Geert







*Van:* [email protected] [mailto:
[email protected]] *Namens *Szabolcs Illes
*Verzonden:* donderdag 23 februari 2012 13:54
*Aan:* [email protected]
*Onderwerp:* [MarkLogic Dev General] weird xpath behaviour



Hi,



I have seen this before, but came across again, so I thought ask this time.
Same/similar xquery but different results:



*Version 1:*



let $ids := /HorseRacingCard/Meeting[@country eq "England" and
AdvancedGoing]/@id

return (/HorseRacing/Meeting[@id = $ids] )[1]



returns expected results.



*Version 2*: Same as 1 but ids vatriable is just inlined



(/HorseRacing/Meeting[@id = /HorseRacingCard/Meeting[@country eq "England"
and AdvancedGoing]/@id ] )[1]



returns nothing [ slow, but that’s expected: ]



Other than Version 2 is NOT optimal since the expression inside the
predicate is evaluated for each sequence item, I guess it should return the
same results.



*Version 3:*

(/HorseRacing/Meeting[@id =* fn:collection()/*HorseRacingCard/Meeting[@country
eq "England" and AdvancedGoing]/@id ] )[1]



Returns expected results and it’s fast, expression is only evaluated once



Can someone shed some light why Version 2 is not returning any results?
Could it be a bug in the optimizer?



Thanks,

Szabolcs
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to