XML Schema complex empty element
Empty the contents of the composite elements can not contain only contain attributes.
Composite empty elements:
An empty XML element:
The above "product" no element content. To define no content type, we must declare a type can contain only elements in its content, but in fact we do not declare any element, 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 above example, we define a complex type with complex content. ComplexContent element gives the signal that we intend to define or expand the content model of a complex type, and integer defining a property is declared but does not introduce any element content.
However, this statement can be more compact "product" elements:
<xs:complexType>
<xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
Or you can give a name to a complexType element, and then set a type attribute "product" and refer to this complexType element name (by using this method, several elements can refer to the same complex type):
<xs:complexType name="prodtype">
<xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:complexType>