A.7. RELAX NGIts editors (James Clark and Murata Makoto) define RELAX NG as "the next generation schema language for XML: clean, simple, and powerful." RELAX NG appears to be closer to a description of the instance documents in ordinary English as well as simpler than the W3C XML Schema, to which it might become a serious alternative. Many constraints, especially those on the fringe of nondeterministic models, can be expressed by RELAX NG and not by the W3C XML Schema. Some combinations in document structures forbidden by the W3C XML Schema can be described by RELAX NG. Even though RELAX NG seems to be technically superior to the W3C XML Schema, support by software vendors and XML developers is uncertain given that W3C XML Schema is a W3C Recommendation. Table A-3 provides the fact sheet for RELAX NG. Table A-3. RELAX NG fact sheet
A.7.1. Example<grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" xmlns="http://relaxng.org/ns/structure/1.0"> <start> <ref name="library"/> </start> <define name="library"> <element name="library"> <oneOrMore> <ref name="book"/> </oneOrMore> <zeroOrMore> <ref name="author"/> </zeroOrMore> <zeroOrMore> <ref name="character"/> </zeroOrMore> </element> </define> <define name="author"> <element name="author"> <attribute name="id"> <data type="ID"/> </attribute> <element name="name"> <text/> </element> <element name="nickName"> <text/> </element> <element name="born"> <text/> </element> <element name="dead"> <text/> </element> </element> </define> <define name="book"> <element name="book"> <ref name="id-attribute"/> <ref name="isbn"/> <ref name="title"/> <zeroOrMore> <element name="author-ref"> <attribute name="id"> <data type="IDREF"/> </attribute> <empty/> </element> </zeroOrMore> <zeroOrMore> <element name="character-ref"> <attribute name="id"> <data type="IDREF"/> </attribute> <empty/> </element> </zeroOrMore> </element> </define> <define name="id-attribute"> <attribute name="id"> <data type="ID"/> </attribute> </define> <define name="character"> <element name="character"> <ref name="id-attribute"/> <ref name="name"/> <ref name="since"/> <ref name="qualification"/> </element> </define> <define name="isbn"> <element name="isbn"> <text/> </element> </define> <define name="name"> <element name="name"> <text/> </element> </define> <define name="nickName"> <element name="nickName"> <text/> </element> </define> <define name="qualification"> <element name="qualification"> <text/> </element> </define> <define name="since"> <element name="since"> <data type="date"/> </element> </define> <define name="title"> <element name="title"> <text/> </element> </define> </grammar> Copyright © 2002 O'Reilly & Associates. All rights reserved. |
|