|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Help with multiple deletesNewman, John W newmanjw at upmc.eduTue Sep 1 16:35:13 PDT 2009
Thanks Martin, that works. Except the 3rd delete doesn't run on the updated tree from the 2nd delete, so 2 copy statements are necessary. Is there a different way to do this, so the delete statements operate on the updated tree w/o doing a copy each time? i.e. some sort of piping construct ?
copy $x := doc("tree.xml")
modify (
delete node $x//tree[@ID = 1] /branch[@ID = 2] /branch[@ID = 13] /branch[@ID = 65] /branch[@ID = 15] /leaf[@ID = 25]
)
return
copy $y := $x
modify (
delete node $y//tree//branch[count(.//leaf) = 0]
)
return
copy $z := $y
modify (
delete node $z//tree[count(.//branch) = 0]
)
return $z
Thanks
-----Original Message-----
From: Martin Probst [mailto:http://x-query.com/mailman/listinfo/talk]
Sent: Saturday, August 29, 2009 10:47 AM
To: Newman, John W
Cc: Michael Kay; http://x-query.com/mailman/listinfo/talk
Subject: Re: Help with multiple deletes
> After I spent a nice chunk of time testing this in stylus studio, I took the
> concept and ported it into our application. Only to discover that the
> implementation we are using, MXQuery 0.6.0, does not support ancestor!
> Argh.. =) So if anyone thinks it can possibly be rewritten without using
> ancestor (or any other axes I'm guessing), please share your thoughts. But
> I think we are going to end up using an XSLT for this operation.
You could simply transform twice, which might be less efficient, but
its certainly simpler to write:
copy $x := doc("tree.xml")
modify (
delete node $x//tree[@ID = 1] /branch[@ID = 2] /branch[@ID =
13] /branch[@ID = 65] /branch[@ID = 15] /leaf[@ID = 25]
)
return
copy $y := $x
modify (
delete node $x//tree//branch[count(.//leaf) = 0]
,
delete node $x//tree[count(.//branch) = 0]
)
return $y
Martin
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






