7.6. Empty Content Models
Empty content models are elements that can only accept attributes.
W3C XML Schema does not include any special support for empty content
models, which can be considered either complex content models without
elements or simple content models with a value restricted to the null
string.
7.6.2. Derivation of Empty Content Models
Each of the two empty content types keeps the derivation methods of
its content model (simple or complex). The main difference between
these two methods is essentially a matter of which derivations may be
applied on the base type and what effect it will have.
7.6.2.2. Derivation by restriction
At first
glance, it seems that there are fewer differences here. The
restriction methods of both simple and complex contents allow the
restriction the scope of the attributes; restricting the content,
which is already empty, doesn't seem to be very
interesting. It's time, though, to remember what
we've learned about a simple type derivation facet,
which actually extends the set of valid instance documents! The
"empty" simple type that we created
to derive our empty simple content model has a base type equal to
xs:string. When this simple type is derived
through xs:whiteSpace, the result may be an expansion
of the sets of valid instance structures. In our case, setting
xs:whiteSpace to
"collapse" has the effect of
accepting any sequence of whitespaces between the start and closing
tags. This new type is not "empty,"
strictly speaking, but may be useful for some (if not for most)
applications that are normalizing the whitespaces and do not make any
difference between these two cases. Such a derivation can be done on
the simple content complex type like this:
<xs:simpleType name="empty">
<xs:restriction base="xs:string">
<xs:enumeration value=""/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="emptyBr">
<xs:simpleContent>
<xs:extension base="empty">
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute name="class" type="xs:NMTOKEN"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="allmostEmptyBr">
<xs:simpleContent>
<xs:restriction base="emptyBr">
<xs:whiteSpace value="collapse"/>
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute name="class" type="xs:NMTOKEN"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
 |  |  | 7.5. Mixed Content Models |  | 7.7. Back to Our Library |
Copyright © 2002 O'Reilly & Associates. All rights reserved.
|
|