DTDs live on in DocBook, JATS and old B2B feeds. For new work, choose by what you must check:
| Feature | DTD | XSD 1.1 | RELAX NG | Schematron |
|---|---|---|---|---|
| Syntax | Own, non-XML | XML | XML or compact | XML |
| Data types | None | Built-in, facets | XSD's, via library | XPath values |
| Namespaces | Literal prefixes | Full | Full | Full |
| Cross-field rules | No | Assertions | Limited | Main purpose |
| Free validators | Every parser | xmlschema 476 , Xerces 129 | Jing 258 | SchXslt 29 |
Pair a grammar (XSD when partners publish one, RELAX NG for your own) with Schematron for business rules. Trang (github.com/relaxng/jing-trang (https://github.com/relaxng/jing-trang 258 )) converts a DTD to RELAX NG or XSD, so retiring a legacy DTD is a small job.
Schema Languages
A grammar-based schema language, such as DTD or Relax NG, declares the grammar for an XML document. It defines the permissible structures, contents, and orders of the elements, attributes, and entities.A rule-based schema language, such as Schematron, specifies the relationships that must hold for the values of elements and attributes.
Very expressive, XSD is both grammar-based and rule-based.

An XML document that conforms to the schema defined in a schema language is said to be valid.
An XML document can be validated online using tools such as:
- http://validator.w3.org/check 189
- http://www.validome.org/grammar/ 895,916
- http://www.xmlvalidation.com/ 920,035
- Jing (Relax NG and Relax NG Compact): http://www.thaiopensource.com/relaxng/jing.html
- XML Validator Buddy (Schematron): http://www.xml-buddy.com/download.htm
This chapter covers the following schema languages:
- DTD - Document Type Definition, the original XML schema language, declared internally or in an external file. It is the only schema language that allows entities to be defined.
- XSD - XML Schema Definition (W3C XML Schema), the most expressive and most widely tooled schema language. Current is XSD 1.1, a W3C Recommendation.
- Relax NG - an XML-based schema language that is somewhat simpler to learn than XSD.
- Relax NG Compact - a compact, non-XML syntax equivalent to Relax NG.
- Schematron - a rule-based schema language built on XPath, standardized by ISO rather than the W3C.