XML referencing to an id with # or not?

719 Views Asked by At

My current project consists of letters which are in collections. Each collection has an id and the letters refer to these ids. Coming from the "TEI world", I thought it would be the best solution to do that with #:

<collection xml:id="1"/>

<letter is_included_in="#1"/>

I thought that is the usal and best way to do that and also intended by the XPointer standard.

Recently, I have learned there is a dt:type="idref" type in XML Schema to handle references to ids. This way it would be without the #.

So, I'm a little bit confused right now.

What is best pratice here and a the most semantic way to handle id references inside one xml document? Or, in other words: How would any human or non-human reader which doesn't know my XMl schema expect me to do this?

1

There are 1 best solutions below

0
On BEST ANSWER

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.