删除少数节点的XQuery

时间:2015-10-04 21:39:09

标签: java xml xquery

我想创建一个xq文件(XQuery),它接收包含以下代码段的XML文件,删除2行“Ford,Harrison”& “Foster,Jodie”然后按原样返回剩余的XML。我怎么做?注意:此xq文件将由Java程序处理。

<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>

1 个答案:

答案 0 :(得分:2)

最简单的方法可能是重写XML,并排除你不想要的节点。

let $exclude-names := ("Ford, Harrison", "Foster, Jodie")
return
  element actors {
  $xml-file/actors/actor[not(. = $exclude-names)]
}