Docbook / XML 对 ID / IDREF 的限制
Docbook / XML restrictions for ID / IDREF
在我的(生成的)docbook 文件中,我得到了一个以数字开头的 ID / IDREF 对(比如 015_code
具有属性 xml:id / linkend,因此发出警告(XMLMind in这种情况):
bad value for attribute "id" from namespace "http://www.w3.org/XML/1998/namespace"
在书中"XML in a nutshell"我读到:
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.
这个解决方案对我有用,但在查看我的示例时 015_code
这不是一个数字,所以我的问题:
- 我的解释/引用不正确吗,ID / IDREF 不能以数字开头
- 这可能是 XMLMind 中的错误
你的第一个要点是正确的; ID/IDREF 不能以数字开头。该值必须是有效的 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)*
来自 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.
和
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.
在我的(生成的)docbook 文件中,我得到了一个以数字开头的 ID / IDREF 对(比如 015_code
具有属性 xml:id / linkend,因此发出警告(XMLMind in这种情况):
bad value for attribute "id" from namespace "http://www.w3.org/XML/1998/namespace"
在书中"XML in a nutshell"我读到:
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.
这个解决方案对我有用,但在查看我的示例时 015_code
这不是一个数字,所以我的问题:
- 我的解释/引用不正确吗,ID / IDREF 不能以数字开头
- 这可能是 XMLMind 中的错误
你的第一个要点是正确的; ID/IDREF 不能以数字开头。该值必须是有效的 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)*
来自 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.
和
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.