Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

RELAX NG

From Wikipedia, the free encyclopedia
XML schema language
RELAX NG
Filename extension
.rng
Internet media type
application/xml, text/xml
Type of formatXML schema language
Extended fromXML

Incomputing,RELAX NG (REgular LAnguage for XML Next Generation) is aschema language forXML—a RELAX NG schema specifies a pattern for the structure and content of an XML document. A RELAX NG schema is itself anXML document but RELAX NG also offers a popular compact, non-XML syntax.[1] Compared to otherXML schema languages RELAX NG is considered relatively simple.

It was defined by a committee specification of theOASIS RELAX NG technical committee in 2001 and 2002, based onMurata Makoto'sRELAX andJames Clark'sTREX,[2][3][4] and also by part two of the international standardISO/IEC 19757: Document Schema Definition Languages (DSDL).[5][6] ISO/IEC 19757-2 was developed byISO/IEC JTC 1/SC 34 and published in its first version in 2003.[7]

Schema examples

[edit]

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:

<book><page>Thisispageone.</page><page>Thisispagetwo.</page></book>

XML syntax

[edit]

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:

<elementname="book"xmlns="http://relaxng.org/ns/structure/1.0"><oneOrMore><elementname="page"><text/></element></oneOrMore></element>

Nested structure becomes unwieldy with many sublevels and cannot define recursive elements, so most complex RELAX NG schemas use references tonamed pattern definitions located separately in the schema. Here, a "flattened schema" defines precisely the same book markup as the previous example:

<grammarxmlns="http://relaxng.org/ns/structure/1.0"><start><elementname="book"><oneOrMore><refname="page"/></oneOrMore></element></start><definename="page"><elementname="page"><text/></element></define></grammar>

Compact syntax

[edit]

RELAX NG compact syntax is a non-XML format inspired byextended Backus–Naur form andregular 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 thatSimple Outline XML (SOX) relates toXML. It shares many features with the syntax ofDTDs. Here is the compact form of the above schema:

element book{element page{text}+}

With named patterns, this can be flattened to:

start=element book{ page+}page=element page{text}

A compact RELAX NG parser will treat these two as the same pattern.

Comparison with W3C XML Schema

[edit]
Main article:XML schema languages

Although the RELAX NG specification was developed at roughly the same time as the W3CXML Schema 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 asDocBook, theTEI Guidelines,OpenDocument, andEPUB.

RELAX NG shares with W3C XML Schema many features that set both apart from traditionalDTDs:data typing,regular expression support,namespace support, ability to reference complex definitions.

Filename extensions

[edit]
This sectiondoes notcite anysources. Please helpimprove this section byadding citations to reliable sources. Unsourced material may be challenged andremoved.(September 2019) (Learn how and when to remove this message)

By informal convention, RELAX NG schemas in the regular syntax are typically named with thefilename extension ".rng". For schemas in the compact syntax, the extension ".rnc" is used.

Determinism

[edit]

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

Converting Relax NG to DTD

[edit]

Relax NG schemas can be converted to DTDs by applyingTrang which can be found at:[1]. The manual for Trang is located at[2]. Note that Trang is unable to convert theOASISDITA 1.3 schema to DTDs, failing with messages like:

 sorry, combining definitions with combine="choice" is not supported

See also

[edit]

References

[edit]
  1. ^RELAX NG Compact Syntax
  2. ^James Clark."TREX - Tree Regular Expressions for XML - "TREX has been merged with RELAX to create RELAX NG."". Retrieved2009-12-28.
  3. ^Murata Makoto (2002-04-03)."RELAX (Regular Language description for XML) -- "RELAX NG of OASIS. It is a schema language created by unifying RELAX Core and TREX."". Retrieved2009-12-28.
  4. ^"TREX and RELAX Unified as RELAX NG, a Lightweight XML Language Validation Specification". Cover Pages. 2001-06-05. Retrieved2009-12-28.
  5. ^RELAX NG Specification
  6. ^RELAX NG Technical Committee
  7. ^ISO."ISO/IEC 19757-2:2008 - Information technology -- Document Schema Definition Language (DSDL) -- Part 2: Regular-grammar-based validation -- RELAX NG". ISO. Retrieved2009-12-28.

External links

[edit]
1–9999
10000–19999
20000–29999
30000+
IEC
ISO/IEC
Related
Authority control databases: NationalEdit this at Wikidata
Retrieved from "https://en.wikipedia.org/w/index.php?title=RELAX_NG&oldid=1230429578"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp