RELAX NG
   HOME

TheInfoList



OR:

In
computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, ...
, RELAX NG (REgular LAnguage for XML Next Generation) is a
schema The word schema comes from the Greek word ('), which means ''shape'', or more generally, ''plan''. The plural is ('). In English, both ''schemas'' and ''schemata'' are used as plural forms. Schema may refer to: Science and technology * SCHEMA ...
language for
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
—a RELAX NG schema specifies a pattern for the structure and content of an XML document. A RELAX NG schema is itself an
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
document but RELAX NG also offers a popular compact, non-XML syntax. Compared to other XML schema languages RELAX NG is considered relatively simple. It was defined by a committee specification of the
OASIS In ecology, an oasis (; ) is a fertile area of a desert or semi-desert environment'ksar''with its surrounding feeding source, the palm grove, within a relational and circulatory nomadic system.” The location of oases has been of critical imp ...
RELAX NG technical committee in 2001 and 2002, based on
Murata Makoto is a Japanese computer scientist, Ph.D. in engineering, and Project Professor at Keio University. He participated in the W3C (World Wide Web Consortium) XML Working Group. The Working Group designed XML1.0, a markup language specification. Murata ...
's RELAX and James Clark's TREX, and also by part two of the international standard ISO/
IEC The International Electrotechnical Commission (IEC; in French: ''Commission électrotechnique internationale'') is an international standards organization that prepares and publishes international standards for all electrical, electronic and r ...
19757: Document Schema Definition Languages (
DSDL Document Schema Definition Languages (DSDL) is a framework within which multiple validation tasks of different types can be applied to an XML document in order to achieve more complete validation results than just the application of a single tech ...
). ISO/IEC 19757-2 was developed by
ISO/IEC JTC 1/SC 34 ISO/IEC JTC 1/SC 34, Document description and processing languages is a subcommittee of the ISO/IEC JTC 1 joint technical committee, which is a collaborative effort of both the International Organization for Standardization and the International ...
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: This is page one. This is page two.


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 XML (SOX) relates to
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
. It shares many features with the syntax of DTDs. Here is the compact form of the above schema: element book With named patterns, this can be flattened to: start = element book page = element page 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 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. These constra ...
specification, the latter was arguably better known and more widely implemented in both open-source and proprietary 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 DocBook, the TEI Guidelines,
OpenDocument The Open Document Format for Office Applications (ODF), also known as OpenDocument, is an open file format for word processing documents, spreadsheets, presentations and graphics and using ZIP-compressed XML files. It was develope ...
, and
EPUB EPUB is an e-book file format that uses the ".epub" file extension. The term is short for ''electronic publication'' and is sometimes styled ''ePub''. EPUB is supported by many e-readers, and compatible software is available for most smartpho ...
. RELAX NG shares with W3C XML Schema many features that set both apart from traditional DTDs: data typing,
regular expression A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
support,
namespace In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified. 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 extension A filename extension, file name extension or file extension is a suffix to the name of a computer file (e.g., .txt, .docx, .md). The extension indicates a characteristic of the file contents or its intended use. A filename extension is typically ...
".rng". For schemas in the compact syntax, the extension ".rnc" is used.


Determinism

Relax NG schemas are not necessaril
"deterministic" or "unambiguous".


Converting Relax NG to DTD

Relax NG schemas can be converted to DTDs by applying
Trang Trang may refer to: Places * Trang province, Thailand **Trang, Thailand, capital city of Trang province **Trang Airport ** Trang railway station ** Trang River *Trang, a sub-district of Mayo district, Pattani province, Thailand * Trang (commune), ...
which can be found at

The manual for Trang is located a

Note that Trang is unable to convert the
OASIS In ecology, an oasis (; ) is a fertile area of a desert or semi-desert environment'ksar''with its surrounding feeding source, the palm grove, within a relational and circulatory nomadic system.” The location of oases has been of critical imp ...
Darwin Information Typing Architecture, DITA 1.3 schema to DTDs, failing with messages like: sorry, combining definitions with combine="choice" is not supported


See also

*
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. These constra ...
s * DTD (Document Type Definition) *
Document Structure Description Document 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: This says that element name ...
*
XML Schema (W3C) XSD (XML Schema Definition), a recommendation of the World Wide Web Consortium ( W3C), specifies how to formally describe the elements in an Extensible Markup Language (XML) document. It can be used by programmers to verify each piece of item con ...
* Schematron *
ODD (One Document Does it all) The Text Encoding Initiative (TEI) is a text-centric community of practice in the academic field of digital humanities, operating continuously since the 1980s. The community currently runs a mailing list, meetings and conference series, and maint ...
*
SXML SXML is an alternative syntax for writing XML data (more precisely, XML Infosets) as S-expressions, to facilitate working with XML data in Lisp and Scheme. An associated suite of tools implements XPath, SAX and XSLT for SXML in Scheme and are a ...


References


External links


RELAX NG home page
by James Clark
Design patterns for structuring XML documentsRELAX NG Book
by Eric van der Vlist, released under the
GNU Free Documentation License The GNU Free Documentation License (GNU FDL or simply GFDL) is a copyleft license for free documentation, designed by the Free Software Foundation (FSF) for the GNU Project. It is similar to the GNU General Public License, giving readers the r ...

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 *https://github.com/relaxng/jing-trang {{Authority control Computer-related introductions in 2001 Data modeling languages ISO/IEC standards XML XML-based standards