How to get node without children in xQuery?

天涯浪子 提交于 2019-12-04 10:11:27

Use:

$list1/item[@foo = $list2/item/@foo]

This selects all <item> elements in $list1 the value of whose foo attribute is equal to the foo attribute of one of the <item> elements in $list2.

In order to copy all attributes of the <list> element, do something like this:

  for $attr in /whateverIsthePathLeadingToList/list/@*
    return 
      attibute {name($attr)} {$attr}

Slightly simplier ... to create a new object from an existing one, but without its children only attributes

assume :

let $old_list :=

This creates a new list copying its attributes

 <list>{$old_list/@*}</list>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!