RELAX NG
Encyclopedia
In computing
, RELAX NG (REgular LAnguage for XML Next Generation) is a schema
language for XML
, based on Murata Makoto
's RELAX
and James Clark
's TREX
. A RELAX NG schema specifies a pattern for the structure and content of an XML document. A RELAX NG schema is itself an XML
document; however, RELAX NG also offers a popular compact, non-XML syntax.
Compared to other popular schema languages, RELAX NG is relatively simple.
It was defined by a committee specification of the OASIS
RELAX NG technical committee in 2001 and 2002, and also by part two of the international standard ISO
/IEC
19757: Document Schema Definition Languages (DSDL). ISO/IEC 19757-2 was developed by ISO/IEC JTC1/SC34
(ISO/IEC Joint Technical Committee 1, Subcommittee 34 - Document description and processing languages) and published in its first version in 2003.
Nested structure becomes unwieldy with many sublevels and cannot define recursive elements, so most complex RELAX NG schemas use references to named pattern definitions located separately in the schema. Here, a "flattened schema" defines precisely the same book markup as the previous example:
(SOX) relates to XML
. It shares many features with the syntax of DTD
s. Here is the compact form of the above schema:
With named patterns, this can be flattened to:
A compact RELAX NG parser will treat these two as the same pattern.
, the TEI
Guidelines, and OpenDocument
.
RELAX NG shares with W3C XML Schema many features that set both apart from traditional DTD
s: data typing, regular expression
support, namespace
support, ability to reference complex definitions.
".rng". For schemas in the compact syntax, the extension ".rnc" is used.
Computing
Computing is usually defined as the activity of using and improving computer hardware and software. It is the computer-specific part of information technology...
, RELAX NG (REgular LAnguage for XML Next Generation) is a schema
XML schema
An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself...
language for XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....
, based on Murata Makoto
Murata Makoto
is a Japanese computer scientist.He participated in the W3C XML Working Group.The Working Group designed XML1.0, a markup language specification.Murata and James Clark designed RELAX NG, an XML schema language....
's RELAX
Relax
Relax may refer to:In music:Albums*Relax , a 2003 album by Blank & Jones*Relax , a 2011 album by Das RacistSongs* "Relax" by Frankie Goes to Hollywood...
and James Clark
James Clark (XML expert)
James Clark, is the author of groff and expat and has done much work with open-source software and XML. Born in London, and educated at Charterhouse and Merton College, Oxford, Clark has lived in Bangkok, Thailand since 1995, and is now a permanent resident...
's TREX
TREX
Tree Regular Expressions for XML is a simple schema language for XML.TREX's author, James Clark, says: : A TREX pattern specifies a pattern for the structure and content of an XML document. A TREX pattern thus identifies a class of XML documents consisting of those documents that match the pattern...
. A RELAX NG schema specifies a pattern for the structure and content of an XML document. A RELAX NG schema is itself an XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....
document; however, RELAX NG also offers a popular compact, non-XML syntax.
Compared to other popular schema languages, RELAX NG is relatively simple.
It was defined by a committee specification of the OASIS
OASIS (organization)
The Organization for the Advancement of Structured Information Standards is a global consortium that drives the development, convergence and adoption of e-business and web service standards...
RELAX NG technical committee in 2001 and 2002, and also by part two of the international standard ISO
International Organization for Standardization
The International Organization for Standardization , widely known as ISO, is an international standard-setting body composed of representatives from various national standards organizations. Founded on February 23, 1947, the organization promulgates worldwide proprietary, industrial and commercial...
/IEC
International Electrotechnical Commission
The International Electrotechnical Commission is a non-profit, non-governmental international standards organization that prepares and publishes International Standards for all electrical, electronic and related technologies – collectively known as "electrotechnology"...
19757: Document Schema Definition Languages (DSDL). ISO/IEC 19757-2 was developed by ISO/IEC JTC1/SC34
ISO/IEC JTC1/SC34
ISO/IEC JTC 1/SC 34 titled as Document description and processing languages is a subcommittee of the ISO/IEC JTC1 joint technical committee, which is a collaborative effort of both the International Organization for Standardization and the International Electrotechnical Commission.-Scope and Terms...
(ISO/IEC Joint Technical Committee 1, Subcommittee 34 - Document description and processing languages) and published in its first version in 2003.
Schema examples
Suppose we want to define an extremely simple XML markup scheme for a book: a book is defined as a sequence of one or more pages; each page contains text only. A sample XML document instance might be:XML syntax
A RELAX NG schema can be written in a nested structure by defining a root element that contains further element definitions, which may themselves contain embedded definitions. A schema for our book in this style, using the full XML syntax, would be written:Nested structure becomes unwieldy with many sublevels and cannot define recursive elements, so most complex RELAX NG schemas use references to named pattern definitions located separately in the schema. Here, a "flattened schema" defines precisely the same book markup as the previous example:
Compact syntax
RELAX NG compact syntax is a non-XML format inspired by extended Backus-Naur form and regular expressions, designed so that it can be unambiguously translated to its XML counterpart, and back again, with one-to-one correspondence in structure and meaning, in much the same way that Simple Outline XMLSimple Outline XML
Simple Outline XML is a compressed way of writing XML.SOX uses indenting to represent the structure of an XML document, eliminating the need for closing tags.- Example :The following XHTML markup fragment: Sample page A very brief page...
(SOX) relates to XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....
. It shares many features with the syntax of DTD
Document Type Definition
Document Type Definition is a set of markup declarations that define a document type for SGML-family markup languages...
s. Here is the compact form of the above schema:
With named patterns, this can be flattened to:
A compact RELAX NG parser will treat these two as the same pattern.
Comparison with W3C XML Schema
Although the RELAX NG specification was developed at roughly the same time as the W3C XML Schema specification, the latter was arguably better known and more widely implemented in both open-source and commercial XML parsers and editors when it became a W3C Recommendation in 2001. Since then, however, RELAX NG support has increasingly found its way into XML software, and its acceptance has been aided by its adoption as a primary schema for popular document-centric markup languages such as DocBookDocBook
DocBook is a semantic markup language for technical documentation. It was originally intended for writing technical documents related to computer hardware and software but it can be used for any other sort of documentation....
, the TEI
Text Encoding Initiative
The Text Encoding Initiative is a text-centric community of practice in the academic field of digital humanities. The community runs a mailing list, meetings and conference series, and maintains a technical standard, a wiki and a toolset....
Guidelines, and OpenDocument
OpenDocument
The Open Document Format for Office Applications is an XML-based file format for representing electronic documents such as spreadsheets, charts, presentations and word processing documents....
.
RELAX NG shares with W3C XML Schema many features that set both apart from traditional DTD
Document Type Definition
Document Type Definition is a set of markup declarations that define a document type for SGML-family markup languages...
s: data typing, regular expression
Regular expression
In computing, a regular expression provides a concise and flexible means for "matching" strings of text, such as particular characters, words, or patterns of characters. Abbreviations for "regular expression" include "regex" and "regexp"...
support, namespace
Namespace (computer science)
A namespace is an abstract container or environment created to hold a logical grouping of unique identifiers or symbols . An identifier defined in a namespace is associated only with that namespace. The same identifier can be independently defined in multiple namespaces...
support, ability to reference complex definitions.
Filename extensions
By informal convention, RELAX NG schemas in the regular syntax are typically named with the filename extensionFilename extension
A filename extension is a suffix to the name of a computer file applied to indicate the encoding of its contents or usage....
".rng". For schemas in the compact syntax, the extension ".rnc" is used.
See also
- XML schemaXML schemaAn XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself...
s - DTDDocument Type DefinitionDocument Type Definition is a set of markup declarations that define a document type for SGML-family markup languages...
(Document Type Definition) - Document Structure DescriptionDocument Structure DescriptionDocument Structure Description, or DSD, is a schema language for XML, that is, a language for describing valid XML documents. It's an alternative to DTD or the W3C XML Schema.An example of DSD in its simplest form:...
- XML Schema (W3C)
- SchematronSchematronIn markup languages, Schematron is a rule-based validation language for making assertions about the presence or absence of patterns in XML trees...
- ODD (One Document Does it all)ODD (One Document Does it all)ODD stands for "One Document Does it all". Part of the Text Encoding Initiative, it is an XML-based format for writing human-readable descriptions of XML files....
- SXMLSXMLSXML is a way to write and process XML data in the form of S-expressions.Textual correspondence between SXML and XML for a sample XML snippet is shown below: XML SXML Text node SXML is a way to write and process XML data in the form of S-expressions.Textual correspondence between...
External links
- RELAX NG home page
- "The Design of RELAX NG" by James Clark
- RELAX NG tutorial for the XML syntax
- RELAX NG tutorial for the compact syntax
- Design patterns for structuring XML documents
- RELAX NG Book by Eric van der Vlist, released under the GNU Free Documentation LicenseGNU Free Documentation LicenseThe GNU Free Documentation License is a copyleft license for free documentation, designed by the Free Software Foundation for the GNU Project. It is similar to the GNU General Public License, giving readers the rights to copy, redistribute, and modify a work and requires all copies and...
- Relax NG Reference by ZVON
- RELAX NG Java community projects at java.net
- Sun Multi-Schema Validator (MSV) open-source Java XML toolkit
- Relax NG Compact Syntax validator open-source C program
- XSD to Relax NG Converter Web-based converter