[xquery-talk] Recursive Sort
David Carlisle
davidc at nag.co.uk
Tue Jun 20 18:05:37 PDT 2006
something like this, probably
(: catsort.xq :)
declare function local:f ($e as element()) {
element {name($e)}{
$e/@*,
for $c in $e/category
order by $c/@name
return
local:f($c)
}};
local:f(*)
$ saxon8q -s catsort.xml catsort.xq 2> x
<?xml version="1.0" encoding="UTF-8"?>
<categories>
<category id="22" name="General Accessories"/>
<category id="23" name="Gift Boxes"/>
<category id="1" name="Memory Sticks, Flash Drives, & Memory Cards"/>
<category id="11" name="Novelties & Gadgets">
<category id="18" name="LCD Clocks"/>
<category id="19" name="MP3 Sunglasses"/>
<category id="21" name="Multi-Function Pens"/>
<category id="20" name="USB Watches"/>
</category>
<category id="2" name="USB Hubs & Accessories">
<category id="3" name="Chargers"/>
<category id="8" name="Cords & Cord Organizers"/>
<category id="4" name="Fans/Lights"/>
<category id="7" name="Mousepads"/>
</category>
</categories>
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
More information about the talk
mailing list