In my (generated) docbook files I got an ID / IDREF pair that started with a number (say 015_code
with the attributes xml:id / linkend and consequently a warning was emitted (XMLMind in this case):
bad value for attribute "id" from namespace "http://www.w3.org/XML/1998/namespace"
In the book "XML in a nutshell" I read:
ID numbers are tricky because a number is not an XML name and therefor not a legal XML ID. The normal solution prefixes the values with an underscore or common letter.
This solution works for me, but when looking at my example 015_code
this is not a number so my questions:
Your first bullet point is correct; ID/IDREF can’t start with a number. The value must be a valid Name...
Names and Tokens
[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
[5] Name ::= NameStartChar (NameChar)*
[6] Names ::= Name (#x20 Name)*
[7] Nmtoken ::= (NameChar)+
[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*
From https://www.w3.org/TR/REC-xml/#sec-attribute-types ...
Validity constraint: ID
Values of type ID must match the Name production. A name must not appear more than once in an XML document as a value of this type; i.e., ID values must uniquely identify the elements which bear them.
and
Validity constraint: IDREF
Values of type IDREF must match the Name production, and values of type IDREFS must match Names; each Name must match the value of an ID attribute on some element in the XML document; i.e. IDREF values must match the value of some ID attribute.