XML属性可以有空格吗? [英] Can XML attributes have spaces?
问题描述
我正在为xml文档创建 DTD .我有一个xml元素的枚举属性.我的问题是:属性 Type 可以有空格吗?
I'm creating a DTD for an xml document. I have an Enumerated attribute for an xml element. My question is: Can the attribute Type have spaces?
例如:
<!ELEMENT Link (#PCDATA)>
<!ATTLIST Link Type (Amendment|Reference|Superseded|Modified|
Corrigendum|Corresponds|Endorsement|Equivalent|Identical|Modified|
Not Equivalent|Note taken of|Related|Similar) "Reference">
所以我想要的是:
<Link Type="Not Equivalent" \>
但是这似乎很荒唐.
我需要为太空做一些魔术伏都教吗?还是只是运气不好?
Is there some magic voodoo I need to do for spaces? Or is it just tough luck?
我看着很少
I looked in a few spots but couldn't see any reference
谢谢!
更新
对不起-当我说barf时,我的意思是当我尝试验证文档时(例如,在Web浏览器中打开它),我收到一条错误消息:ATTLIST枚举中发现无效字符.处理资源'file:///C:/myxmldocument.xml'时出错....
Sorry - when I say barf, I mean that when I try to validate the document (Eg Open it in a web browser) I get an error message: Invalid character found in ATTLIST enumeration. Error processing resource 'file:///C:/myxmldocument.xml'. ...
推荐答案
简短的回答是否".Xml属性是名称标记,名称标记不能包含空格.相关规格已链接:
The short answer is no. Xml attributes are name tokens and name tokens cannot contain spaces. The relevant specs are linked:
无效字符是空格.您可以使用 '.'或使用-"作为分隔符.
The invalid character is the space. You can use '.' or '-' as a separator if you like.
这篇关于XML属性可以有空格吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!