Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道如何选择这样的属性:
$table/@id
但是,如果属性名称存储为变量,我该怎么做。例如:
let $x = "id" $table/@[$x]
您可以使用函数local-name或node-name捕获属性的值并将其与谓词匹配。local-name将简单地返回一个与元素名称匹配的字符串,node-name并将返回一个完全限定的名称,这通常是推荐的,但实际上,只有在处理命名空间时才需要。
local-name
node-name
let $x = "id" return $table/@*[local-name(.) = $x] let $x := xs:QName("id") return $table/@*[node-name(.) = $x]