mbr*_*ort 5 xml xpath xquery marklogic
因此,我实际上有两个要加入的元素节点。我希望顶层节点保持不变,但子节点将被那些交叉引用所取代。
鉴于:
<stuff>
<item foo="foo" boo="1"/>
<item foo="bar" boo="2" />
<item foo="baz" boo="3"/>
<item foo="blah boo="4""/>
</stuff>
<list a="1" b="2">
<foo>bar</foo>
<foo>baz</foo>
</list>
Run Code Online (Sandbox Code Playgroud)
我想遍历“列表”并交叉引用“内容”中的元素以获取此结果:
<list a="1" b="2">
<item foo="bar" boo="2" />
<item foo="baz" boo="3"/>
</list>
Run Code Online (Sandbox Code Playgroud)
我想这样做,而不必知道“列表”上可能有哪些属性。换句话说,我不想像这样显式地调用它们
attribute a { $list/@a }, attribute b { $list/@b }
Run Code Online (Sandbox Code Playgroud)
使用:
$list1/item[@foo = $list2/item/@foo]
这将选择属性值等于$list2 中元素之一的属性的所有<item>元素。$list1foofoo<item>
为了复制<list>元素的所有属性,请执行以下操作:
for $attr in /whateverIsthePathLeadingToList/list/@*
return
attibute {name($attr)} {$attr}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2645 次 |
| 最近记录: |