cschlaefcke Posted June 26, 2008 Share Posted June 26, 2008 Hi Folks,I have a xml structure that can have arbitrary nested categories/category elements: <...> <categories> <category name="1"> <categories> <category name="A"/> <category name="B"/> <category name="C"/> </categories> <category> <category name="2"> <categories> <category name="D"> <categories> <.../> </categories> </category> <category name="E"/> <category name="F"/> </categories> <category> <category name="3"> <categories> <category name="G"/> <category name="H"/> <category name="I"/> </categories> <category> </categories></..> What I want to do with XQuery is something like: "Give me everything except Category 2" and it should return: <...> <categories> <category name="1"> <categories> <category name="A"/> <category name="B"/> <category name="C"/> </categories> <category> <category name="3"> <categories> <category name="G"/> <category name="H"/> <category name="I"/> </categories> <category> </categories></..> What I have so far is: Give me Category "1" and I´ll figure out, to get the delta myself :-) declare namespace mn='http://www.my_namespace.com'; let $e := $this//mn:categories return <mn:categories> { for $z in $e/mn:category where $z/@name='2' return $z } </mn:categories> But this is getting really ugly the bigger the matching result becomes. When I try to invert my query with "!=" like this: declare namespace mn='http://www.my_namespace.com'; let $e := $this//mn:categories return <mn:categories> { for $z in $e/mn:category where $z/@name!='2' return $z } </mn:categories> it returns crap :-(Is there any clever way to get the delta with XQuery directly?Thanks for any help! Regards,Chris Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.