开发者

Why does Jing not allow a colon (":") in an id attribute?

I've been banging my head against xsd:ID not allowing a colon (":") in an id attribute. I first noticed this when using James Clark's nxml-mode in Emacs as it validated an XHTML file I was working with. I then ran the XHTML fi开发者_StackOverflowle against the RNG (provided with nxml-mode-20041004) using Jing and received the following error(s):

error: value of attribute "id" is invalid; must be an XML name without colons

Most of the W3 pages I've seen indicate that a colon is valid. Then I found this, http://www.w3.org/XML/xml-19980210-errata#E98, which I take to mean: "you shouldn't use a colon in an id attribute, but you should be allowed to." Given that interpretation, I'm stumped why Jing says I can't.

Thank you,

Zachary


You're looking at two subtly different definitions here. xsd:ID is defined in terms of the NCName type in Namespaces in XML 1.0 and the ID type of the base XML standard is defined in terms of the Name type. Both share the following definition:

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]
NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | 
    [#x0300-#x036F] | [#x203F-#x2040]
Name ::= NameStartChar (NameChar)*

NCName is defined as:

NCName ::=  Name - (Char* ':' Char*) 

which is Name minus the colon.

The result of this is that in terms of XML itself, the value of something typed as ID can contain a colon. In terms of anything that uses the XML Schema datatypes (such as your RelaxNG schema) there is more restricted data type in use which forbids the use of the colon. Anything that uses an XML Schema compliant attribute will be valid against the base definition but not necessarily the other way around.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜