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.
Where it bites
A definition on its own is trivia. These are the pages where this term decides whether a document works.
- ToolsRELAX NG validatorValidate against a RELAX NG grammar here.
- FormatsXML Schema (XSD)The alternative, and what most machine-to-machine XML actually uses.
Related terms
- ValidA well-formed document that also conforms to a declared grammar — a DTD, an XSD schema or a RELAX NG grammar.
- XML Schema (XSD)The W3C schema language: a grammar written in XML itself, with datatypes, namespaces and a type system.
- SchematronA rule-based schema language that asserts XPath conditions about a document, rather than describing its grammar.
- Content modelThe rule saying what an element may contain: which children, in what order, how many times, and whether text is allowed.
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.