[xquery-talk] reconstructing missing attributes
Howard Katz
howardk at fatdog.com
Tue Feb 7 19:31:10 PST 2006
Thanks. At least I'm happy to say it's definitely not the old familiar Doh!
experience, since Doh! usually stands for: I knew that! Not in this case.
I've never had occasion to use preceding-sibling before (tho I've
implemented it). Nicely done (tho the second variation gives me a headache).
Howard
> -----Original Message-----
> From: talk-bounces at xquery.com
> [mailto:talk-bounces at xquery.com] On Behalf Of David Carlisle
> Sent: February 7, 2006 5:49 PM
> To: howardk at fatdog.com
> Cc: talk at xquery.com
> Subject: Re: [xquery-talk] reconstructing missing attributes
>
>
> If your processor supports preceding-sibling then it's easy:
>
> <x>
> {/x/*/element {name()} {(.|preceding-sibling::*)[@id][last()]/@id}}
> </x>
>
> $ saxon8q -s abc.xml abc.xq
> <?xml version="1.0" encoding="UTF-8"?>
> <x>
> <a id="1"/>
> <a id="1"/>
> <a id="1"/>
> <a id="2"/>
> <b id="2"/>
> <b id="2"/>
> <b id="2"/>
> <c id="2"/>
> <a id="3"/>
> <a id="3"/>
> <b id="3"/>
> <c id="3"/>
> <c id="3"/>
> <a id="4"/>
> <a id="4"/>
> <a id="4"/>
> <a id="5"/>
> <b id="5"/>
> <b id="5"/>
> <a id="6"/>
> </x>
>
> if not it's slightly more tiresome but you can always
> rewrite the axis
> in terms of <<
>
> fullaxis.xsl rewites the above to
> <x>
> {//x/*/ element {name()}{(. |
> (let $here := . return
> reverse(../*[. << $here]))
> /.)[@id][last()]/@id}}
> </x>
>
> for example (which gives the same result in saxon)
>
> David
>
> _____________________________________________________________
___________
> 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
> _____________________________________________________________
___________
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
>
More information about the talk
mailing list