#Dev

RELAX NG: A Modern XML Schema Language

AI & ML Reporter
4 min read

RELAX NG is a schema language for XML that emphasizes simplicity and ease of use while providing powerful validation capabilities.

RELAX NG (REgular LAnguage for XML Next Generation) is a schema language for XML that was developed to address the complexity and usability issues found in other schema languages like W3C XML Schema. Created by James Clark and MURATA Makoto, RELAX NG combines the best features of earlier schema languages TREX and RELAX Core, resulting in a powerful yet accessible tool for XML validation.

Key Features

RELAX NG distinguishes itself through several core design principles:

  • Simplicity: The language is intentionally designed to be easy to learn and use
  • Dual syntax support: Both an XML syntax and a compact non-XML syntax are available
  • Non-intrusive: It doesn't change the information set of XML documents
  • Namespace support: Full support for XML namespaces
  • Uniform treatment: Attributes are treated uniformly with elements where possible
  • Unrestricted content: Supports unordered and mixed content freely
  • Theoretical foundation: Built on solid theoretical principles
  • Datatype flexibility: Can partner with separate datatyping languages like W3C XML Schema Datatypes

Specifications and Standards

RELAX NG has achieved significant standardization recognition:

  • OASIS Standard: Developed within the OASIS RELAX NG Technical Committee
  • ISO/IEC 19757-2: Recognized as an International Standard (Part 2 of DSDL - Document Schema Definition Languages)
  • Amendment 1: Includes Compact Syntax as ISO/IEC 19757-2:Amd1
  • Second Edition: ISO/IEC 19757-2:2008 consolidates the first edition with amendments

Learning Resources

For those new to RELAX NG, several tutorials are available:

  • RELAX NG Tutorial (OASIS Committee Specification, December 2001): Comprehensive tutorial using XML syntax
  • RELAX NG Compact Syntax Tutorial (OASIS Working Draft, March 2003): Tutorial for compact syntax without requiring XML syntax knowledge
  • XML Matters Series (David Mertz, IBM developerWorks): Three-part series introducing RELAX NG concepts
  • Relax NG, Compared (Eric van der Vlist, XML.com): Comparison with W3C XML Schema

Software Ecosystem

A robust ecosystem of tools supports RELAX NG development:

Validators

  • Jing: Primary validator supporting both XML and compact syntaxes, implemented in Java by James Clark
  • RNV: Compact syntax validator in ANSI C under BSD license
  • Libxml2: GNOME's XML library with RELAX NG support (XML syntax only)
  • MSV: Sun Multi-Schema XML Validator supporting RELAX NG and other schema languages
  • Tenuto: .NET validator implemented in C#
  • Bali: Validator compiler producing standalone validators

Conversion Tools

  • Trang: Multi-format schema converter supporting RELAX NG, XML DTDs, and W3C XML Schema
  • Sun RELAX NG Converter: Converts various schema languages to RELAX NG
  • XSD to RelaxNG: Web-based converter from W3C XML Schema
  • rng2srng: Converts RELAX NG to simple syntax
  • rnc2rng: Converts compact syntax to XML syntax

Code Generators

  • Relaxer: Schema compiler generating Java classes from RELAX NG schemas
  • RelaxNGCC: Compiler compiler for generating Java source code from RELAX NG grammars

XML Editors

  • Stylus Studio: Commercial XML editor with RELAX NG support
  • oXygen: Multiplatform commercial editor supporting both syntaxes
  • XMLBlueprint: Commercial editor with RELAX NG validation
  • XMLBuddy Pro: Commercial editor with RELAX NG support
  • nXML mode: GNU Emacs addon for XML editing
  • Firedocs: Browser-based WYSIWYG XML editor using Jing for validation

Other Tools

  • RelaxMeter: Checks for ambiguous RELAX NG grammars
  • Schema simplifier: Web-based tool for simplifying RELAX NG schemas
  • RNGOM: Java library for parsing RELAX NG grammars
  • Schema to web form: Transforms RELAX NG schemas into XHTML forms

Real-World Applications

RELAX NG schemas are used in numerous important standards and applications:

  • XSLT 3.0: Citation Style Language uses RELAX NG schemas
  • Atom Syndication Format: Web feed standard
  • Google Data API: Including Calendar List Feed Schema
  • Adobe InDesign IDML: InDesign Markup Language
  • ODF (Open Document Format): Schemas for ODF 1.0 and 1.1
  • OOXML: Ecma-376 2nd edition includes non-normative RELAX NG schemas
  • TEI P5: Text Encoding Initiative
  • DocBook: Technical documentation format
  • XHTML: Extensible HTML
  • MathML 2.0: Mathematical Markup Language
  • SVG 1.1: Scalable Vector Graphics
  • VoiceXML: Voice XML for voice applications
  • RDF: Resource Description Framework

Future Development

The RELAX NG community continues to evolve the language:

  • RELAX NG Version 2: A new project has started in ISO/IEC JTC1/SC34/WG1
  • New Part: Version 2 is likely to become a new part of ISO/IEC 19757 while Version 1 remains as Part 2
  • Ongoing Maintenance: The standard continues to be maintained and updated

Getting Involved

The RELAX NG community maintains several resources:

  • OASIS RELAX NG TC home page: Official technical committee site
  • Robin Cover's RELAX NG page: Comprehensive resource listing
  • James Clark's RELAX NG page: Creator's personal site
  • Mailing lists: Active community discussion forums

RELAX NG represents a thoughtful approach to XML validation that prioritizes usability without sacrificing power. Its continued use in major standards and active development community demonstrate its enduring relevance in the XML ecosystem.

Comments

Loading comments...