Reputation: 53
Could someone please explain to me a bit about this XML schema. I have been reading for hours but I can't figure out the part of the restriction part, and what are those restricted values suppose to mean?
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="storagehouse">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0"/>
<xs:element name="weight" type="xs:float" minOccurs="0"/>
<xs:element name="category" type="xs:string" />
<xs:element name="location" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="A1" />
<xs:enumeration value="A2" />
<xs:enumeration value="A3" />
<xs:enumeration value="A4" />
<xs:enumeration value="B1" />
<xs:enumeration value="B2" />
<xs:enumeration value="B3" />
<xs:enumeration value="B4" />
<xs:enumeration value="C1" />
<xs:enumeration value="C2" />
<xs:enumeration value="C3" />
<xs:enumeration value="C4" />
<xs:enumeration value="D1" />
<xs:enumeration value="D2" />
<xs:enumeration value="D3" />
<xs:enumeration value="D4" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Upvotes: 0
Views: 359
Reputation: 7575
Explanation of the restriction part:
The element called location
is an element of simple type with restriction.
The restriction element defines restrictions on a set of values : The only acceptable values for the element location
are "A1", "A2", ... , "D3", "D4".
Upvotes: 1