Reputation: 2661
I want to create a xq file (XQuery) which takes in a XML file that contains the following snippet, removes say 2 lines for "Ford, Harrison" & "Foster, Jodie" and then returns the remaining XML as is. How do I do that? Note: This xq file will be processed by a Java program.
<actors>
<actor id="00000015">Anderson, Jeff</actor>
<actor id="00000030">Bishop, Kevin</actor>
<actor id="0000000f">Bonet, Lisa</actor>
<actor id="00000024">Bowz, Eddie</actor>
<actor id="0000002d">Curry, Tim</actor>
<actor id="00000033">Dullea, Keir</actor>
<actor id="00000042">Fisher, Carrie</actor>
<actor id="00000006">Ford, Harrison</actor>
<actor id="00000045">Foster, Jodie</actor>
...etc...
</actors>
Upvotes: 0
Views: 48
Reputation: 11773
The simplest approach is probably to rewrite the XML, and exclude the nodes you don't want.
let $exclude-names := ("Ford, Harrison", "Foster, Jodie")
return
element actors {
$xml-file/actors/actor[not(. = $exclude-names)]
}
Upvotes: 2