【问题标题】:Trying to simulate the XQuery function fn:idref() but without a schema试图模拟 XQuery 函数 fn:idref() 但没有模式
【发布时间】:2011-06-22 09:53:50
【问题描述】:

我想在 XML 文档中搜索具有包含特定 ididrefs 属性的元素。例如,给定这个 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 处理器。

【问题讨论】:

    标签: xml xquery saxon idref


    【解决方案1】:

    这似乎与

    有关

    How to use the XQuery fn:idref() function?

    没有架构,你需要

    //*[tokenize(@idrefs, ' ') = "hello"]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 1970-01-01
      • 1970-01-01
      • 2013-11-04
      • 2023-03-17
      • 2019-07-14
      • 2011-05-27
      相关资源
      最近更新 更多