XML 属性可以有空格吗?

发布于 2024-08-21 09:24:21 字数 1025 浏览 2 评论 0原文

我正在为 xml 文档创建 DTD 。我有一个 xml 元素的 枚举属性。我的问题是:属性 Type 可以有空格吗?

例如:

  <!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" \>

但这似乎令人呕吐。当我说 barf 时,我的意思是当我尝试验证文档(例如在网络浏览器中打开它)时,我收到一条错误消息:

在 ATTLIST 枚举中发现无效字符。错误处理 资源“file:///C:/myxmldocument.xml”。 ...

我需要对空间施一些魔法吗?或者只是运气不好?

我查看了一些 但看不到任何参考

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?

eg:

  <!ELEMENT Link (#PCDATA)>
  <!ATTLIST Link Type (Amendment|Reference|Superseded|Modified|
  Corrigendum|Corresponds|Endorsement|Equivalent|Identical|Modified|
  Not Equivalent|Note taken of|Related|Similar) "Reference">

So what I would like is:

  <Link Type="Not Equivalent" \>

But that seems to barf. 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'. ...

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

没有心的人 2024-08-28 09:24:21

简短的回答是否定的。 Xml 属性是名称标记,并且名称标记不能包含空格。相关规范已链接:

属性

属性类型(请参阅 NotationType)

名称(参见 4a - NameChar)

无效字符是空格。您可以使用“.”或者如果您愿意,可以使用“-”作为分隔符。

The short answer is no. Xml attributes are name tokens and name tokens cannot contain spaces. The relevant specs are linked:

Attributes

Attribute Types (see NotationType)

Names (See 4a - NameChar)

The invalid character is the space. You can use '.' or '-' as a separator if you like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文