尝试模拟 XQuery 函数 fn:idref() 但没有模式
我想在 XML 文档中搜索具有包含特定 id
的 idrefs 属性的元素。例如,给定此 XML 文档 doc.xml
;
<doc>
<x1 idrefs="foo bar">
<x2 idrefs="world hello"/>
</x1>
<x3 idrefs="ipsum lepsum"/>
<a xml:id="bar"/>
<b xml:id="hello"/>
</doc>
我想要这个 XQuery;
let $d := doc("doc.xml")
return $d/local:getref("hello")
返回该元素;
<x2 idrefs="world hello"/>
我相信 fn:idref()
正是这样做的,但前提是 doc.xml
具有适当的架构。这可以在没有模式的情况下完成吗?
我正在使用 Saxon XQuery 处理器。
I want to search an XML document for the element that has an idrefs
attribute containing a specific id
. For example, given this XML document doc.xml
;
<doc>
<x1 idrefs="foo bar">
<x2 idrefs="world hello"/>
</x1>
<x3 idrefs="ipsum lepsum"/>
<a xml:id="bar"/>
<b xml:id="hello"/>
</doc>
I want this XQuery;
let $d := doc("doc.xml")
return $d/local:getref("hello")
to return this element;
<x2 idrefs="world hello"/>
I believe that fn:idref()
does exactly this, but only if doc.xml
has an appropriate schema. Can this be done without a schema?
I'm using the Saxon XQuery processor.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎与
如何使用 XQuery fn:idref 有关() 函数?
没有架构,您需要
This seems to be related to
How to use the XQuery fn:idref() function?
Without a schema, you need