3

我目前的项目由收藏中的信件组成。每个集合都有一个 id,字母指的是这些 id。来自“TEI 世界”,我认为使用 # 来做到这一点是最好的解决方案:

<collection xml:id="1"/>

<letter is_included_in="#1"/>

我认为这是实现这一点的最常用和最好的方法,也是 XPointer 标准的意图。

最近,我了解到 XML Schema 中有一个 dt:type="idref" 类型来处理对 id 的引用。这样就没有#了。

所以,我现在有点困惑。

这里的最佳实践是什么,以及在一个 xml 文档中处理 id 引用的最语义化方式是什么?或者,换句话说:任何不知道我的 XMl 模式的人类或非人类读者会如何期望我这样做?

4

1 回答 1

2

If you're developing a simple referencing scheme that does not have to make sub-references, I recommend that you do not pre-pend all references with hash characters (#):

<collection xml:id="c1"/>

<letter is_included_in="c1"/>
  • At the base level, standard practice is for identifier and reference to match exactly; @id and @idref match exactly.
  • Historically, # in a reference is used to precede a reference to a subpart. (See specifically the widely adopted standard use of hash marks in HTML @href to introduce a fragment identifier to refer to a named part of an HTML page.) TEI and XPointer built upon this convention in URIs.
  • The XML spec requires that attribute values of type ID must match the Name production, which prohibits id's from starting with a number.
于 2014-02-28T13:28:13.347 回答