[MarkLogic Dev General] Distinct Nodes/Value Functions
Geert Josten
Geert.Josten at daidalos.nl
Fri Feb 19 09:58:23 PST 2010
> Ah, pity. You could ofcourse do an order by the whole item,
> but that could be a bit risky perhaps. And in the second
> loop, you could resort to deep-equal after all, perhaps
> leveraging the run-time construction of a compare node as used by Ken.
Something like this:
declare function local:distinct-items_geert ($items as node()*) as node()* {
let $items :=
for $item in $items
order by $item descending
return $item
for $item at $pos in $items
let $itemCompare :=
<compare>{$item/* except $item/testVal}</compare>
let $prev :=
$items[$pos - 1]
let $prevCompare :=
<compare>{$prev/* except $prev/testVal}</compare>
where not(deep-equal($itemCompare, $prevCompare))
return $item
};
Kind regards,
Geert
drs. G.P.H. (Geert) Josten
Consultant
Daidalos BV
Hoekeindsehof 1-4
2665 JZ Bleiswijk
T +31 (0)10 850 1200
F +31 (0)10 850 1199
mailto:geert.josten at daidalos.nl
http://www.daidalos.nl/
KvK 27164984
P Please consider the environment before printing this mail.
De informatie - verzonden in of met dit e-mailbericht - 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.
More information about the General
mailing list