-
Notifications
You must be signed in to change notification settings - Fork 0
/
validationOfXML.xsd
100 lines (97 loc) · 5.11 KB
/
validationOfXML.xsd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!--The xs name space is holding the value "http://www.w3.org/2001/XMLSchema" -->
<xs:element name="company">
<xs:complexType>
<xs:sequence>
<xs:element name="products">
<xs:complexType>
<xs:sequence>
<xs:element name="product" maxOccurs="unbounded">
<!-- product can show unbounded number of times -->
<xs:complexType>
<xs:sequence>
<!-- has to go as sequanced -->
<xs:element name="category">
<xs:simpleType>
<xs:restriction base="xs:string">
<!-- category is restricted for String from here and all the way down -->
<xs:pattern value="[a-zA-Z\s]+"/>
<!-- regular expression to limit the strings with only alphabets -->
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="name">
<xs:simpleType>
<xs:restriction base="xs:string">
<!-- name is restricted for String from here and all the way down -->
<xs:pattern value="[a-zA-Z\s]+"/>
<!-- regular expression to limit the strings with only alphabets -->
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="description" type="xs:string"/>
<!-- description is restricted for String from here and all the way down -->
<xs:element name="size">
<xs:simpleType>
<xs:restriction base="xs:string">
<!-- size is restricted for String from here and all the way down -->
<xs:pattern value="[0-9a-zA-Z\s.]+"/>
<!-- regular expression to limit the strings with only alphabets and numbers according to the requirements of the size of the items -->
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="color">
<xs:simpleType>
<xs:restriction base="xs:string">
<!-- color is restricted for String from here and all the way down -->
<xs:pattern value="[a-zA-Z\s]+"/>
<!-- regular expression to limit the strings with only alphabets -->
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="quantity">
<xs:simpleType>
<xs:restriction base="xs:integer">
<!-- quantity is restricted for integers only from here and all the way down -->
<xs:minInclusive value="0"/>
<!-- the integers numbers has to be minimum of 0 if it is zero then the product should not to exist in the table (will fix that by js later)-->
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="unit_price">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<!-- money should have decimals for the cents -->
<xs:attribute name="currency" type="xs:string" use="required"/>
<!-- the artibute currency is Euro and it is been setted to String -->
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="discount">
<xs:simpleType>
<xs:restriction base="xs:boolean"/>
<!-- The type is true or false indicating that there is a discount or not -->
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="code">
<xs:simpleType>
<xs:restriction base="xs:string">
<!--reg expression been used here to restrict the # for digits only and taken all the code attribute as a String -->
<xs:pattern value="\d{3}-\d{2}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<!-- The code should always be positive integer and cannot be negative -->
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>