Skip to main content
XMLDir

Search 309 pages — tools, formats, elements, namespaces, directory, comparisons, XPath, datatypes, glossary, parse errors, schema errors, use cases, blog and product.

Schemas and validity

RELAX NG

A schema language built around patterns rather than types, expressing repetition, alternation and interleaving far more directly than XSD.

RELAX NG is what DocBook, TEI and JATS ship as their normative grammar. It has two syntaxes — an XML one and a compact one — and only the XML syntax is machine-readable by libxml2, which is what this site validates with.

It deliberately has no datatype library of its own, borrowing XSD's when one is wanted. The trade is a grammar that is far easier to read and a validator that will not tell you a date is malformed unless you ask it to.

Defined in
ISO/IEC 19757-2
Category
Schemas and validity
Also written
RNG, Relax NG

Shown, not asserted

This claim is executed on every test run, against the same engines the tools use. If the behaviour changes, the test fails rather than this page quietly becoming wrong.

  • A RELAX NG grammar is itself an XML document, so the same well-formedness rules apply to it.

    document.xml
    <element name="note" xmlns="http://relaxng.org/ns/structure/1.0"><text/></element>

    What the engine returns

    Well-formed.

What catches people out

  • The compact syntax (.rnc) is a different serialization of the same grammar, and most validators — ours included — read only the XML syntax.
  • Interleave is RELAX NG's superpower and has no XSD equivalent: "these children, in any order" is one keyword.
  • Without an explicit datatype library, RELAX NG checks structure and leaves values alone.

Get started

Bring order to the XML your team can't afford to ignore.

Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.