December 2003
Intermediate to advanced
506 pages
12h 26m
English
You now have all the patterns needed to write a full schema that expresses what we’ve discussed about this example:
<?xml version = '1.0' encoding = 'utf-8' ?>
<element xmlns="http://relaxng.org/ns/structure/1.0" name="library">
<oneOrMore>
<element name="book">
<attribute name="id"/>
<attribute name="available"/>
<element name="isbn">
<text/>
</element>
<element name="title">
<attribute name="xml:lang"/>
<text/>
</element>
<oneOrMore>
<element name="author">
<attribute name="id"/>
<element name="name">
<text/>
</element>
<optional>
<element name="born">
<text/>
</element>
</optional>
<optional>
<element name="died">
<text/>
</element>
</optional>
</element>
</oneOrMore>
<zeroOrMore>
<element name="character">
<attribute name="id"/>
<element name="name">
<text/>
</element>
<optional>
<element name="born">
<text/>
</element>
</optional>
<element name="qualification">
<text/>
</element>
</element>
</zeroOrMore>
</element>
</oneOrMore>
</element>RELAX NG directly supports four kinds of
occurrence constraints on nodes: they
may appear as exactly once (the default), optional, zero or more, or
one or more. These are the most common cases in document design. If
applications need a finer level of control, that can be achieved by
using or combining these four basic occurrence constraints. If, for
instance, you need to define that each book’s
description should have between two and six
character elements, you can write the definition as two ...
Read now
Unlock full access