Thanks Mary,
*scratches the top of his head*
I actually thought that the 'declare ordering ordered' declaration would
preserve the sorted order, but rereading the recommendation I notice that it is
talking about document order, not about the particular order of a specific
sequence. And declaring as 'unordered' makes it implementation dependant all
together, so this declaration isn't helping me at all. :-/
But your suggestion does help me out here. And apparently MarkLogic allows the
following as well:
let $test := document {
<object object-id="a"/>,
<object object-id="b"/>,
<object object-id="c"/>
}/*
Bit funny to have multiple root elements in a document node, but MarkLogic is
not complaining, even though I am running with xquery version '1.0'.
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
> Mary Holstege
> Sent: dinsdag 28 april 2009 17:10
> To: General Mark Logic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Unpredictable order of node sets?
>
>
> What is going on here is that the results of the path
> expression $test/self::object/@object-id is being returned in
> document order.
> However, what you have is three independent nodes, and
> document order is undefined in such a case. If you want to
> force a guaranteed order, you need to put them in the same
> "document", for example:
>
> let $test :=
> <root>
> <object object-id="a"/>
> <object object-id="b"/>
> <object object-id="c"/>
> </root>
>
> with the corresponding change to the path expression.
>
> //Mary
>
> On Tue, 28 Apr 2009 02:52:08 -0700, Geert Josten
> <[email protected]> wrote:
>
> > Hi,
> >
> > I was testing code that returned a sorted sequence of nodes, but my
> > test cases were failing irratically. It took me some time to figure
> > out the exact cause, but it looks like the order of sorted
> node sets
> > is not maintained properly. I think that it should be
> maintained, and
> > am failing to see a logical reason for this behaviour.
> Contrarely, the
> > order of sorted sequences of atomic values is mainted properly.
> >
> > Anyone observed this behaviour before? Anyone who would like to
> > comment on this behaviour? Is there a logical explanation?
> The declare
> > ordering doesn't seem to influence this behaviour. Should it?
> >
> > Here the code to reproduce the problem. Run it multiple
> times in CQ to
> > see what happens..
> >
> > xquery version "1.0";
> >
> > declare default function namespace
> > "http://www.w3.org/2005/xpath-functions";
> >
> > declare ordering ordered;
> > declare default order empty least;
> > declare construction preserve;
> >
> > let $test := (
> > <object object-id="a"/>,
> > <object object-id="b"/>,
> > <object object-id="c"/>
> > )
> >
> > return (
> > '>>Predictable order<<',
> >
> > $test/self::object/@object-id/string(.),
> >
> > '>>Unpredictable order<<',
> >
> > for $id in $test/self::object/@object-id
> > return
> > string($id)
> > )
> >
> > Kind regards,
> > Geert
>
> [email protected]
> Principal Engineer
> Mark Logic Corporation
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general