The generic form is:
- <xsd:complexType name="nameType">
<xsd:choice>
<xsd:element name="name"
type="attribute">
<xsd:element name="name"
type="attribute">
<xsd:element name="name"
type="attribute">
</xsd:choice>
</xsd:complexType>
This is a valid element:
- <xsd:complexType name="alien_probeType">
<xsd:choice>
<xsd:element name="tubes"
type="metallic">
<xsd:element name="shapes"
type="triangular">
<xsd:element name="duration"
type="xsd:time">
</xsd:choice>
</xsd:complexType>
In the schema, this complexType can be used in an element by calling it
- <xsd:element name="alien_probe" type="alienprobeType">
In the XML file, this is a valid element
- <alien_probe>
<tubes type="metallic">outer_spacium</tubes>
<shape type="triangular">long</shape>
</alien_probe>
So is this
- <alien_probe>
<tubes type="metallic">outer_spacium</tubes>
<duration type="time">4 hours</duration>
</alien_probe>
Using the all facet, an element can be defined so that all of the elements can be used in any order in the XML file
The generic form is:
- <xsd:complexType name="nameType">
<xsd:all>
<xsd:element name="name1"
type="attribute">
<xsd:element name="name2"
type="attribute">
<xsd:element name="name3"
type="attribute">
</xsd:all>
</xsd:complexType>
This is the complexType with all three elements:
- <xsd:complexType name="alien_probeType">
<xsd:choice>
<xsd:element name="tubes"
type="metallic">
<xsd:element name="shapes"
type="triangular">
<xsd:element name="duration"
type="xsd:time">
</xsd:choice>
</xsd:complexType>
In the schema, this complexType can be used in an element by calling it
- <xsd:element name="alien_probe" type="alienprobeType">
Because of the use of xsd:all, order no longer matters, so this is
a valid element :
- <alien_probe>
<duration type="time">4 hours</duration>
<tubes type="metallic">outer_spacium</tubes>
<shape type="triangular">long</shape>
</alien_probe>
So is this
- <alien_probe>
<shape type="triangular">long</shape>
<tubes type="metallic">outer_spacium</tubes>
<duration type="time">4 hours</duration>
- </alien_probe>
There are several restrictions when using the all facet
- An element may only be used once in this type of facet
It may not contain groups of elements
It must be the only child of the complex type