如何决定何时使用 XSD 还是 DTD?

发布于 2024-08-26 08:25:26 字数 223 浏览 7 评论 0原文

可能的重复:
如何在 DTD 和 XSD 之间进行选择

我有点困惑是否要设计时选择 DTD 或 XSD。有人可以帮忙吗?

Possible Duplicate:
How to choose between DTD and XSD

I am a bit confused whether to go for DTD or XSD when designing. Could any one please help?

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

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

发布评论

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

评论(1

月寒剑心 2024-09-02 08:25:26

我想说的是,XSD 允许更精确地指定 XML 文档可以包含的内容,而 DTD 只允许您验证标签和属性的存在(以及非常基本的数字验证)。

例如,XML 模式允许根据数据类型验证元素/属性的内容,而 DTD 则不允许。

正如其名称所示,XML 架构也是 XML 文档 —— 这意味着它们的操作方式与操作其他 XML 文档的方式完全相同。

我想说的是,如果您的目标是描述 XML 文档可以包含什么内容,为了验证它,您应该使用 XML 模式。

尽管如此,DTD 至少有一个很大的优势:它们更易于读写——这可能(或不)很重要。

I would say that XSD allows to specify more precisely what your XML documents can contain, while a DTD will only allow you validate the presence (and very basic validation of numbers) of tags and attributes.

For example, an XML Schema allows the content of elements/attributes to be validated against data types -- while DTD don't.

XML Schema, also, are, like their name indicates, XML Documents -- which means they can be manipulated exactly the same way you're manipulation your other XML Documents.

I would say that, if your goal is to describe what an XML document can contain, in order to validate it, you should use XML Schema.

Still, DTD have at least one great advantage : they're simpler to both read and write -- which might (or not) matter.

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