LLMpediaThe first transparent, open encyclopedia generated by LLMs

Relax NG

Generated by DeepSeek V3.2
Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Expansion Funnel Raw 48 → Dedup 34 → NER 15 → Enqueued 14
1. Extracted48
2. After dedup34 (None)
3. After NER15 (None)
Rejected: 19 (not NE: 19)
4. Enqueued14 (None)
Similarity rejected: 1
Relax NG
NameRelax NG
ParadigmDeclarative programming
DesignerJames Clark (programmer)
DeveloperOASIS (organization)
Latest release version1.0
Latest release date2001
Influenced byXML Schema, DTD
InfluencedSchematron
TypingStructural type system
LicenseMIT License

Relax NG. It is a schema language for XML that specifies a pattern for the structure and content of an XML document. Developed by the OASIS (organization) consortium, it is known for its simplicity and formal mathematical foundation. The language provides a clear, non-XML syntax as well as a standard XML-based syntax, offering flexibility to developers.

Overview

The primary goal of the language is to enable the validation of XML document instances against a defined pattern. It employs a rule-based approach where schemas are composed of definitions for element (XML) and attribute (XML) patterns. Its design philosophy emphasizes readability and ease of use over the complex features found in other standards like W3C's XML Schema. The formal basis for its semantics is provided by regular tree grammar, which ensures precise and unambiguous validation rules.

Syntax variants

The specification defines two interchangeable syntax forms. The compact syntax, often saved with a `.rnc` extension, uses a non-XML format that is concise and human-readable, resembling Extended Backus–Naur Form. The XML syntax, saved with a `.rng` extension, represents the same patterns using XML elements and XML attributes, making it processable by standard XML parsers. Tools like Trang can automatically convert between these two syntaxes and also to other formats such as DTD or XML Schema.

Schema structure and components

A schema is fundamentally built from patterns that define allowed content. Key pattern types include ``, ``, and `` for specifying sequences. The `` pattern allows alternatives, while `` permits content in any order, similar to an all-group in XML Schema. Data typing is handled through the `` pattern, which can reference built-in types from W3C's XML Schema Part 2 or define new ones via the `` and `` constructs. Named patterns defined with `` and referenced with `` enable modularity and reuse.

Comparison with other schema languages

Compared to the W3C's XML Schema, it is generally considered simpler and more elegant, avoiding complexities like nilable elements and substitution groups. Unlike Document Type Definition, it supports XML namespaces natively and offers a richer set of constraints. While Schematron is rule-based and focuses on assertion (computing)s, this language is grammar-based, defining the permissible structure. It lacks built-in facilities for type inheritance or identity constraints, which are central to XML Schema.

Software support and implementations

Several major XML processors and libraries provide support. The Java (programming language) library Jing (software) is a widely used validator. Within the Python (programming language) ecosystem, lxml includes support through RelaxNG classes. The libxml2 library, used by tools like xmllint, offers validation capabilities. Editors such as oXygen XML Editor and XMLSpy integrate support for authoring and validating schemas. The Multi-schema XML Validator from Sun Microsystems also historically supported it.

Standardization and history

The language was created by James Clark (programmer), building on earlier work known as RELAX and TREX. It was standardized in 2001 by OASIS (organization) and later published in 2003 as both an OASIS Standard and an International Organization for Standardization standard, ISO/IEC 19757-2. Its development was partly a response to the perceived complexity of the W3C's XML Schema recommendation. While it gained a dedicated following, XML Schema became more widely adopted due to its integration with the W3C stack and tools like XSLT and Web Services Description Language. Category:XML