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, e ...
, 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 ...
—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 ...
document but RELAX NG also offers a popular compact, non-XML syntax. Compared to other
XML schema languages An XML schema is a description of a type of Extensible Markup Language, 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 ...
RELAX NG is considered relatively simple. It was defined by a committee specification of the OASIS 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. Mu ...
's
RELAX Relax may refer to: Aviation * Roland Z-120 Relax, a German ultralight aircraft design for the 120 kg class Music Albums * ''Relax'' (Blank & Jones album), 2003 * ''Relax'' (Das Racist album), 2011 Songs * "Relax" (song), a 1983 song by Fran ...
and James Clark's TREX, and also by part two of the international standard
ISO ISO is the most common abbreviation for the International Organization for Standardization. ISO or Iso may also refer to: Business and finance * Iso (supermarket), a chain of Danish supermarkets incorporated into the SuperBest chain in 2007 * 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). 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 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" o ...
, 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 ...
. 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 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. As a semantic languag ...
, 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 developed wi ...
, and EPUB. RELAX NG shares with W3C XML Schema many features that set both apart from traditional DTDs:
data typing In computer science and computer programming, a data type (or simply type) is a set of possible values and a set of allowed operations on it. A data type tells the compiler or interpreter how the programmer intends to use the data. Most progra ...
,
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 d ...
".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 which can be found at

The manual for Trang is located a

Note that Trang is unable to convert the OASIS 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 named ...
*
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 cont ...
*
Schematron Schematron is a rule-based validation language for making assertions about the presence or absence of patterns in XML trees. It is a structural schema language expressed in XML using a small number of elements and XPath. In many implementations ...
*
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 main ...
* SXML


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
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