为什么对 XML 同时使用 XSD 和 DTD? [英] Why use both XSD and DTD for XML?

查看:28
本文介绍了为什么对 XML 同时使用 XSD 和 DTD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Stackoverflow 有几个很好的问题对比 XSD 和 DTD在 XSD 和 DTD 之间进行选择.但是我遇到了一种同时使用 XSD 和 DTD 的数据格式和库.XML 文档指定 DTD,但支持库需要 XSD 进行编码和解码.

Stackoverflow has a couple of great questions contrasting XSD and DTD and choosing between XSD and DTD. But I came across a data format and library that used both XSD and DTD. The XML documents specify the DTD but the supporting library requires the XSD to encode and decode.

同时使用 XSD 和 DTD 有什么好处?

What are the benefits of using an XSD and DTD at the same time?

推荐答案

我见过 DTD 和 XSD 一起使用的最重要的时间与你引用的例子有关:一个行业标准组已经定义了他们的 XML 词汇和语法很长以前使用 DTD,但 XML 的特定使用者希望使用需要 XSD 的 JAXB 等工具.因此,消费者使用 XSD 创建了一个并行模式,以便能够利用工具或满足需要 XSD 的其他依赖项,同时保持与通过先前建立的 DTD 指定的模式的兼容性.

The most significant time I've seen both DTD and XSD used together relates to the example you cite: A sector standards group had defined their XML vocabulary and grammar long ago using DTD, yet particular consumers of the XML wanted to use tools such as JAXB that require a XSD. So, the consumers created a parallel schema using XSD to be able to take advantage of tools or satisfy other dependencies requiring XSD while maintaining compatibility with the schema specified via previously established DTDs.

除了解决此类遗留问题之外,不要打扰 DTD.新项目应仅使用更现代的 XML 模式语言,例如 XSD、RELAX NG 或 Schematron.

Other than to address such legacy concerns, don't bother with DTD. New projects should solely use more modern XML schema languages such as XSD, RELAX NG, or Schematron.

这篇关于为什么对 XML 同时使用 XSD 和 DTD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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