Information AboutRelax Ng |
| CATEGORIES ABOUT RELAX NG | |
| iso standards | |
| xml-based standards | |
| data modeling languages | |
| 2001 introductions | |
|
It is specified by a committee specification of the ). 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 "Russian-doll" 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: Russian-doll 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: <ref name="page"/> Compact syntax RELAX NG compact syntax is a non-XML format 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 . It shares many features with the syntax of DTD s. Here is the compact form of the Russian-doll schema: start = element book { element page { text }+ } The flattened schema is even shorter in compact form: start = element book { page+ } page = element page { text } A RELAX NG parser that accepts the compact syntax (most, but not all, do) will treat this two-line schema as exactly synonymous with its four-line counterpart above. 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 docucentric markup languages such as DocBook , the TEI Guidelines, and OpenDocument . RELAX NG shares with W3C XML Schema many features that set both apart from traditional , Regular Expression support, Namespace support, ability to reference complex definitions. Features missing from RELAX NG XML Schema natively supports a huge range of built-in and derived Datatype s. RELAX NG's built-in type library contains only two datatypes: string and token. However, RELAX NG permits the use of plug-in type libraries, and in practice all RELAX NG implementations support the predefined XML Schema datatypes.RELAX NG is more limited than XML Schema in its range of occurrence constraints: it has a zeroOrMore constraint and a oneOrMore constraint, but one cannot easily define an arbitrary minimum and maximum occurrence range as with XML Schema's minOccurs and maxOccurs feature. Workarounds are possible, but verbose. The following example demonstrates one way to force the example above to have between two and five page elements:<ref name="page"/> <ref name="page"/> This missing feature can be considered a feature that guides schema writers to obey the Zero-One-Infinity Rule . Features unique to RELAX NG Besides its optional compact syntax, which has no standard equivalent in XML Schema, RELAX NG offers several features not present in XML Schema:
FILENAME EXTENSIONS By informal convention, RELAX NG schemas in the regular syntax are typically named with the Filename Extension ".rng". For schemas in the compact syntax, the extension ".rnc" is used. SEE ALSO
EXTERNAL LINKS
|
|
|