RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Discover RELAX NG, A Simple Schema Solution : Page 3

With the goals of compact syntax and compatibility, the Regular Language Description for XML (RELAX NG) eases the pain of working with cumbersome DTDs and XSDs.


Complex Types

Compared with XSD, RELAX NG does not support simpleType and complexType tags. However, you can build complex types by grouping the named patterns define and ref. For example, complexType studentRoll can be built using references to studentID and studentSSN:

<element name="studentRoll">
    <ref name="studentID "/>
    <ref ssn="studentSSN "/>

Sequence Tag
By default, XSD defines the complex type elements in ordered sequence. XML tools on the market such as XMLSpy, 4Suite, and Stylus use the sequence tag to mandate that the elements within a complex type be ordered in sequence. As a result, though you define all the sub-elements, they must be in the order specified in the schema. This limits the full features of inheritance, because it restricts the definition of a subset of elements and what can be inherited from it. RELAX NG relaxes this restriction by providing the interleave tag:

 <element name="parentNames">
   <element name="motherName"><text/></element>
    <element name="fatherName"><text/></element>

The above schema specifies that the parentNames can be interleaved, so mother's name or the optional father's name need not follow the order specified in the schema.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date