代码之家  ›  专栏  ›  技术社区  ›  Gavin

使用XLink引用同一文档中的节点

  •  3
  • Gavin  · 技术社区  · 17 年前

    将简单的XLink链接到同一文档中的另一个节点的一般要点似乎是:

    <root xmlns:xlink="http://www.w3.org/1999/xlink">
      <firstChild id="ID1" />
      ...
      <ref xlink:href="#ID1" />
    </root>
    

    在不使用XPointer或XPath的情况下,这是XLink所能做到的吗?你能做一个XLink吗 customId

    <root xmlns:xlink="http://www.w3.org/1999/xlink">
      <firstChild id="ID1" customId="{1234-5678}" />
      ...
      <ref xlink:href="#customId/{1234-5678}" />
    </root>
    

    W3 spec -我不知道你是怎么想的,但需要一种特殊的人才能解读它们,而我今天不是那种人!

    谢谢!

    1 回复  |  直到 17 年前
        1
  •  5
  •   Tomalak    17 年前

    XLink spec :

    片段标识符的格式 URI引用中使用的[…]是 由XPointer规范指定。

    XPointer spec :

    XPointer[…]基于XML路径语言(XPath)

    <root xmlns:xlink="http://www.w3.org/1999/xlink">
      <firstChild id="ID1" customId="{1234-5678}" />
      ...
      <ref xlink:href="#xpointer(/root/firstChild[@customId = '{1234-5678}'])" />
    </root>