Skip to content
Tomas Mlcoch edited this page Oct 29, 2013 · 1 revision

Schema languages for XML

Great article about XML schemas written by Jiří Kosek (Czech only)

DTD

W3C XML Schema (WXS)

RELAX NG

  • Homepage

  • Wikipedia

  • (+) Supported in Libxml2

  • (+) Supported in lxml

  • (+) Supported in xmllint

  • (+) Simpler (less verbose syntax) than XML Schema

  • (+) Could be written in XML or compact syntax

  • (+) Supports datatypes

  • (+) Supports XML namespaces

  • (+) Supports unordered content

  • (+) Supports of list

  • (+) Supports context-sensitive content models (e.g. sub-elements based on attr in parent element)

  • (-) No simple way to define an exact number of repetition of elements

Schematron

Note: Schematron is a rule-based validation language.

  • Homepage

  • Wikipedia

  • (+) Supported in Libxml2

  • (+) Supported in lxml

  • (-) Unsupported in xmllint

  • (+) Schematron validation could be done by any XSLT processor - There is an XSLT style, which transform a schematron scheme to another XSLT style. This output style is then used for validation of XML document (The XML document is transformed by this style to ouptut document which contain list of validation errors) <- This is pretty cool, right?

  • (+) Could be inserted into WXS and Relax NG schemas.

  • (+) Could validate values from an XML document agains values from any other XML document.

Comparsion

External tools for validation