为什么Jing不允许在id属性中使用冒号(“:")? [英] Why does Jing not allow a colon (":") in an id attribute?

查看:148
本文介绍了为什么Jing不允许在id属性中使用冒号(“:")?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在反对xsd:ID,不允许在id属性中使用冒号(:").我在Emacs中使用James Clark的nxml-mode时首先注意到了这一点,因为它验证了我正在使用的XHTML文件.然后,我使用Jing对RNG(由nxml-mode-20041004提供)运行XHTML文件,并收到以下错误:

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 file 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

我见过的大多数W3页面都表明冒号有效.然后我发现了这个 http://www.w3.org/XML/xml- 19980210-errata#E98 ,我的意思是:您不应在id属性中使用冒号,但应允许使用冒号."鉴于这种解释,我很困惑为什么静说我不能.

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.

谢谢你,
扎卡里(Jachary)

Thank you,
Zachary

推荐答案

您正在这里查看两个细微不同的定义.根据 XML 1.0中的命名空间,基本XML标准的ID类型是根据以下内容定义的: 名称类型.两者都有以下定义:

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定义为:

NCName is defined as:

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

是名称减去冒号.

这样做的结果是,就XML本身而言,键入为ID的内容的值可以包含冒号.就使用XML架构数据类型的任何内容(例如RelaxNG架构)而言,使用中的限制数据类型都更多,从而禁止使用冒号.使用XML Schema兼容属性的任何内容都将对基本定义有效,但不一定相反.

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.

这篇关于为什么Jing不允许在id属性中使用冒号(“:")?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆