XML DTD - 将属性定义为数字并要求 #PCDATA

发布于 2024-08-22 01:41:56 字数 504 浏览 0 评论 0原文

我意识到架构是可行的方法,但这是一项任务。如果我想要求某个元素上的属性是浮点数/数字,这可能吗?我唯一知道要做的就是将其定义为 CDATA - 是否有一些预定义的 ENTITY ?我认为我不应该引入任何其他 DTD,因此如果它那么复杂,那么对于本次作业的目的来说它是不正确的。现在我这样做:

这只是 DTD 的限制吗?

此外,有没有办法在元素上要求#PCDATA?我正在使用 Altova XML Spy,它允许元素具有:

对于如下定义的东西:


通过了验证。谢谢。

I realize Schema is the way to go, but this is an assignment. If I wanted to require an attribute on some element to be a float/number, is that possible? The only thing I know to do is to define it as CDATA - is there some predefined ENTITY ? I don't think I should pull in any other DTD, so if it's that complex, it's incorrect for the purposes of this assignment. Right now I do it like so:

<!ATTLIST elemName attrName CDATA>

Is this just a limitation of DTD?

Additionally, is there a way to require #PCDATA on an element? I'm using Altova XML Spy and it is allowing elements with:

<elem foo="bar"/>

for something defined like:

<!ELEMENT elem (#PCDATA)>
<!ATTLIST elem foo CDATA #REQUIRED>

past the validation. Thanks.

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

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

发布评论

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

评论(1

爱给你人给你 2024-08-29 01:41:56

似乎没有办法仅指定数字,并且空字符串对于 #PCDATA 有效。

there doesn't appear to be a way to specify only numbers and the empty string is valid for #PCDATA.

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