Information Technology Reference
In-Depth Information
information is required. All of the previous examples indicated a required
presence. It is also a simple matter to specify a i xed number of reoccur-
rences of an element. For example, if every article in a magazine had
three authors, the following model would ensure that three names are
present:
<simpleType>
< sequence >
<element ref = “DOC: a” minOccurs = “0”
maxOccurs = “3” />
< /sequence >
</simpleType>
…author, author, author,…
But it is also possible to make an element optional, to allow it to repeat any
number of times, and even to make it both optional and repeatable.
9.2.3.1.4
If an element is optional, and also repeatable, shown in Figure 9.7, the
element name is followed by an asterisk, “*.” The “*” may be seen as
equivalent to the combination “?+.” For example, “(a, b*)” indicates that
element “b” may occur any number of times, the following XML schema
demonstrates this type of constraint.
Optional and Repeatable Element
<complexType>
< sequence >
<element ref = “DOC: a” />
<element ref = “DOC: b” minOccurs = “0”
maxOccurs = μ />
< /sequence >
</complexType>
An article element may contain any number of author elements, including
none. To take another example, a chapter may have preliminary para-
graphs, but may not always do so. The following XML fragment shows
this XML schema phenomenon.
a
b
FIGURE 9.7
Optional and repeatable element.
Search WWH ::




Custom Search