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

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

问题描述

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一起使用的最重要的时间与您引用的示例有关:一个行业标准小组很早以前就使用DTD定义了XML词汇和语法,但是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.

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

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