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