XSD Empty Elements
An empty complex element cannot contain content, only attributes.
Complex empty elements:
An empty XML element:
The "product" element above has no content at all. To define a type with no content, we must declare a type that can only contain elements in its content, but in fact we do not declare any elements, like 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 example above, we defined a complex type with complex content. The complexContent element signals that we intend to restrict or extend the content model of a complex type, while the integer restriction declares an attribute but does not introduce any element content.
However, the "product" element can also be declared more compactly:
<xs:complexType>
<xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
Alternatively, you can give a name to a complexType element, then set a type attribute on the "product" element and reference this complexType name (by using this method, several elements can reference the same complex type):
<xs:complexType name="prodtype">
<xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:complexType>