Why use both XSD and DTD for XML?

别来无恙 提交于 2019-12-06 09:03:50

问题


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.

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


回答1:


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.

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.



来源:https://stackoverflow.com/questions/38727905/why-use-both-xsd-and-dtd-for-xml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!