How to validate XML against RelaxNG
- Open the validator and paste, drop or fetch the XML document.
- Expand Validate against a schema and add the .rng or .rnc file. The syntax is recognised from the content, so there is nothing to choose.
- Press Validate and click an error to jump to its line.
Compact syntax
A compact schema, and any .rnc files it includes, is translated to the XML syntax in your browser before validation, the way trang does. Annotations and Schematron rules embedded in it are ignored.
Schemas split over several files (include and externalRef in the XML syntax, include and external in the compact one) work when you choose all of the files, or their folder, together.
What is checked
RelaxNG describes documents as patterns: interleaving, choices between attributes and elements, and mixed content that XSD handles awkwardly. Data types come from XML Schema (xsd:date, xsd:decimal, facets such as pattern). Validation runs on libxml2, so the result matches xmllint --relaxng.
The catalog has DocBook 5.2, TEI P5, Atom 1.0 and the EPUB package and container schemas ready to use.
Common RelaxNG errors
- Did not expect element there
- Expecting an element, got nothing
- Type doesn't allow value
- Invalid attribute for element
In CI and from code
From the command line or GitHub Actions, or through the API:
npx @xmlvalid/cli validate "content/**/*.xml" --schema-file schema/book.rnc
From the catalog
Official schemas with all their files in place. Open one to see what it checks, or validate against it straight away.
- Atom 1.0: Blog, podcast and changelog feeds in the Atom format, as read by feed readers and aggregators.
- DocBook 5.2: Books, articles and reference documentation written in DocBook.
- TEI P5: Texts encoded with the Text Encoding Initiative guidelines, the standard of digital humanities.
- EPUB 3 package document: The package document of an EPUB 3 book: metadata, manifest and spine, checked with the grammar and rules epubcheck uses.
- EPUB container.xml: The META-INF/container.xml of an EPUB, which tells reading systems where the package document is.
- EPUB 2 OPF 2.0.1: The content.opf of an EPUB 2 book, checked with the grammar and rules epubcheck uses.
- NCX 2005-1: The NCX navigation file of EPUB 2 books, also kept in many EPUB 3 books for older readers.
Questions
Do I need to convert .rnc to .rng first?
No. Compact schemas are translated in the browser, includes and all.
Is my XML uploaded?
No. The document and the schema stay on your machine; validation runs in WebAssembly.
Are Schematron rules inside the schema checked?
No, embedded Schematron annotations are ignored. Catalog entries for EN 16931, Peppol, XRechnung, Factur-X and EPUB do run Schematron; see the Schematron validator.
How large can the file be?
Up to 50 MB without an account and 1 GB with a free one, streamed in constant memory.
Other schema languages
- XSD validator (XML Schema)
- DTD validator (Document Type Definition)
- Schematron validator for e-invoices (Schematron)