Empty compound elements cannot contain content, only attributes. An empty XML element: The “product” element above has no content at all. In order to define a type without content, we must declare a type that contains only elements in its content, but we do not actually declare any elements, such as this: In the above example, we define a composite type with composite content. The complexContent element signals that we intend to define or extend the content model of a composite type, while the integer qualification declares an attribute but does not introduce any element content. However, you can also declare this “product” element more compactly: Or you can give a name to a complexType element, then set a type attribute for the “product” element and reference the complexType name (by using this method, several elements can refer to the same compound type):Compound empty elements: ¶
<product prodid="1345" />
<xs:element name="product">
<xs:complexType>
<xs:complexContent>
<xs:restriction base="xs:integer">
<xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="product">
<xs:complexType>
<xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
<xs:element name="product" type="prodtype"/>
<xs:complexType name="prodtype">
<xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:complexType>