Marklogic:Xpath使用删除处理指令标记

Marklogic:Xpath使用删除处理指令标记,xpath,xquery,marklogic,Xpath,Xquery,Marklogic,如何使用XQuery删除xml中的处理指令标记 示例XML: <a> <text><?test id="1" loc="start"?><b type="bold">1. </b> Security or protection <?test id="1" loc=="end"?><?test id="1" loc="start"?><b type="bold">2. </

如何使用XQuery删除xml中的处理指令标记

示例XML:

<a>
    <text><?test id="1" loc="start"?><b type="bold">1. </b>
    Security or protection <?test id="1" loc=="end"?><?test id="1" loc="start"?><b type="bold">2.
    </b> Analyse.
    <?test id="1" loc="end"?></text>
  </a>

1.
安全或保护2。
分析。
预期产出:

 <a>
     <text><b type="bold">1. </b> Security or protection <b type="bold">2.
     </b> Analyse.</text>

  </a>

1.安全或保护2。
分析。

请帮助删除PI标签。

类似的操作应该可以:

xquery version "1.0-ml";

declare function local:suppress-pi($nodes) {
  for $node in $nodes
  return
    typeswitch ($node)
    case element() return
      element { fn:node-name($node) } {
        $node/@*,
        local:suppress-pi($node/node())
      }
    case processing-instruction() return ()
    default return $node
};

local:suppress-pi(<a>
    <text><?test id="1" loc="start"?><b type="bold">1. </b>
    Security or protection <?test id="1" loc=="end"?><?test id="1" loc="start"?><b type="bold">2.
    </b> Analyse.
    <?test id="1" loc="end"?></text>
  </a>)
xquery版本“1.0-ml”;
声明函数本地:抑制pi($nodes){
对于$node中的$node
返回
类型开关($node)
case元素()返回
元素{fn:node name($node)}{
$node/@*,
本地:抑制pi($node/node())
}
案例处理-指令()返回()
默认返回$node
};
局部:抑制pi(
1.
安全或保护2。
分析。
)