您可以将前缀指定给QName,如下所示:
let $exp:= QName ("urn:my-namespace", "myns:real")
解决这个问题的最好方法可能是在查询中声明这些名称空间,并通过前缀引用它们:
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
declare namespace myns="urn:my-namespace";
declare function local:exp($w as node()) as element()* {
for $e in $w/e
return
element myns:real {
attribute rdf:resource {$e/@lang}
}
};
请注意,可以使用直接构造函数简化函数:
declare function local:exp($w as node()) as element()* {
for $e in $w/e
return <myns:real rdf:resource="{$e/@lang}" />
};