请输入您要查询的百科知识:

 

词条 RELAX NG
释义

  1. Schema examples

     XML syntax  Compact syntax 

  2. Comparison with W3C XML Schema

  3. Filename extensions

  4. Determinism

  5. Converting Relax NG to DTD

  6. See also

  7. References

  8. External links

{{infobox file format
| name = RELAX NG
| extension = .rng
| mime = application/xml, text/xml
| owner =
| genre = XML Schema language
| extendedfrom = XML
| standard =
}}

In computing, RELAX NG (REgular LAnguage for XML Next Generation) is a schema language for XML—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 but RELAX NG also offers a popular compact, non-XML syntax.[1] Compared to other XML schema languages 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's RELAX and James Clark's TREX,[2][3][4] and also by part two of the international standard ISO/IEC 19757: Document Schema Definition Languages (DSDL).[5][6] ISO/IEC 19757-2 was developed by ISO/IEC JTC1/SC34 and published in its first version in 2003.[7]

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. 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+ }

page = element page { text }

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

Comparison with W3C XML Schema

{{Main|XML schema languages}}

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 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, and EPUB.

RELAX NG shares with W3C XML Schema many features that set both apart from traditional DTDs: data typing, regular expression support, namespace 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 ".rng". For schemas in the compact syntax, the extension ".rnc" is used.

Determinism

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

Converting Relax NG to DTD

Relax NG schemas can be converted to DTDs by applying Trang which can be found at: [https://github.com/relaxng/jing-trang]. The manual for Trang is located at  . Note that Trang is unable to convert the OASIS DITA 1.3 schema to DTDs, failing with messages like:

See also

  • XML schemas
  • DTD (Document Type Definition)
  • Document Structure Description
  • XML Schema (W3C)
  • Schematron
  • ODD (One Document Does it all)
  • SXML

References

1. ^RELAX NG Compact Syntax
2. ^{{cite web |url=http://www.thaiopensource.com/trex/ |title=TREX - Tree Regular Expressions for XML - "TREX has been merged with RELAX to create RELAX NG." |author=James Clark |accessdate=2009-12-28}}
3. ^{{cite web |url=http://www.xml.gr.jp/relax/ |title=RELAX (Regular Language description for XML) -- "RELAX NG of OASIS. It is a schema language created by unifying RELAX Core and TREX." |author=Murata Makoto |date=2002-04-03 |accessdate=2009-12-28}}
4. ^{{cite web |url=http://xml.coverpages.org/ni2001-06-05-a.html |title=TREX and RELAX Unified as RELAX NG, a Lightweight XML Language Validation Specification. |publisher=Cover Pages |date=2001-06-05 |accessdate=2009-12-28}}
5. ^RELAX NG Specification
6. ^RELAX NG Technical Committee
7. ^{{cite web |url=http://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?csnumber=37605 |title=ISO/IEC 19757-2:2003 - Information technology -- Document Schema Definition Language (DSDL) -- Part 2: Regular-grammar-based validation -- RELAX NG |author=ISO |publisher=ISO |accessdate=2009-12-28}}

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
  • [https://web.archive.org/web/20000711044018/http://www.xmlpatterns.com/ Design patterns for structuring XML documents]
  • RELAX NG Book by Eric van der Vlist, released under the GNU Free Documentation License
  • Relax NG Reference by ZVON
  • [https://web.archive.org/web/20070708133256/https://relax-ng.dev.java.net/ RELAX NG Java community projects] at java.net
  • [https://web.archive.org/web/20070610122849/https://msv.dev.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
{{ISO standards}}{{List of International Electrotechnical Commission standards}}{{Authority control}}

5 : Computer-related introductions in 2001|Data modeling languages|ISO/IEC standards|XML|XML-based standards

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/21 3:22:27