/ recipeBoxSchema.xsd
recipeBoxSchema.xsd
  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  3  
  4      <xs:simpleType name="stringNotEmpty">
  5          <xs:restriction base="xs:string">
  6              <xs:minLength value="1"/>
  7          </xs:restriction>
  8      </xs:simpleType>
  9  
 10      <xs:element name="recipeBox">
 11          <xs:complexType>
 12              <xs:sequence>
 13                  <xs:element name="ingredients">
 14                      <xs:complexType>
 15                          <xs:sequence>
 16                              <xs:element name="ingredient" minOccurs="1" maxOccurs="unbounded">
 17                                  <xs:complexType>
 18                                      <xs:sequence>
 19                                          <xs:element name="name" type="stringNotEmpty"/>
 20                                          <xs:element name="category" type="stringNotEmpty"/>
 21                                          <xs:element name="allergens" type="stringNotEmpty"/>
 22                                      </xs:sequence>
 23                                      <xs:attribute name="id" type="xs:ID" use="required"/>
 24                                  </xs:complexType>
 25                              </xs:element>
 26                          </xs:sequence>
 27                      </xs:complexType>
 28                  </xs:element>
 29  
 30                  <xs:element name="recipes">
 31                      <xs:complexType>
 32                          <xs:sequence>
 33                              <xs:element name="recipe" minOccurs="1" maxOccurs="unbounded">
 34                                  <xs:complexType>
 35                                      <xs:sequence>
 36                                          <xs:element name="title" type="stringNotEmpty"/>
 37                                          <xs:element name="cuisine" type="stringNotEmpty"/>
 38                                          <xs:element name="difficulty" type="stringNotEmpty"/>
 39                                          <xs:element name="healthRating" type="xs:integer"/>
 40                                          <xs:element name="price" type="xs:float"/>
 41                                          <xs:element name="preparationTime" type="stringNotEmpty"/>
 42                                          <xs:element name="cookingTime" type="stringNotEmpty"/>
 43                                          <xs:element name="servings" type="xs:integer"/>
 44                                          <xs:element name="ingredientRefs">
 45                                              <xs:complexType>
 46                                                  <xs:sequence>
 47                                                      <xs:element name="ref" minOccurs="1" maxOccurs="unbounded">
 48                                                          <xs:complexType>
 49                                                                  <xs:attribute name="id" type="xs:IDREF" use="required"/>
 50                                                                  <xs:attribute name="quantity" type="xs:decimal" use="required"/>
 51                                                                  <xs:attribute name="unit" type="stringNotEmpty" use="required"/>
 52                                                          </xs:complexType>
 53                                                      </xs:element>
 54                                                  </xs:sequence>
 55                                              </xs:complexType>
 56                                          </xs:element>
 57                                          <xs:element name="instructions">
 58                                              <xs:complexType>
 59                                                  <xs:sequence>
 60                                                      <xs:element name="step" type="stringNotEmpty" minOccurs="1" maxOccurs="unbounded"/>
 61                                                  </xs:sequence>
 62                                              </xs:complexType>
 63                                          </xs:element>
 64                                          <xs:element name="nutritionFacts">
 65                                              <xs:complexType>
 66                                                  <xs:sequence>
 67                                                      <xs:element name="calories" type="xs:integer"/>
 68                                                      <xs:element name="carbs" type="stringNotEmpty"/>
 69                                                      <xs:element name="protein" type="stringNotEmpty"/>
 70                                                      <xs:element name="fat" type="stringNotEmpty"/>
 71                                                  </xs:sequence>
 72                                              </xs:complexType>
 73                                          </xs:element>
 74                                      </xs:sequence>
 75                                      <xs:attribute name="id" type="xs:ID" use="required"/>
 76                                  </xs:complexType>
 77                              </xs:element>
 78                          </xs:sequence>
 79                      </xs:complexType>
 80                  </xs:element>
 81  
 82                  <xs:element name="menus">
 83                      <xs:complexType>
 84                          <xs:sequence>
 85                              <xs:element name="menu" minOccurs="1" maxOccurs="unbounded">
 86                                  <xs:complexType>
 87                                      <xs:sequence>
 88                                          <xs:element name="meal" minOccurs="1" maxOccurs="7">
 89                                              <xs:complexType>
 90                                                  <xs:attribute name="type" type="stringNotEmpty" use="required"/>
 91                                                  <xs:attribute name="day" type="stringNotEmpty" use="required"/>
 92                                                  <xs:attribute name="recipeId" type="xs:IDREF" use="required"/>
 93                                              </xs:complexType>
 94                                          </xs:element>
 95                                      </xs:sequence>
 96                                      <xs:attribute name="id" type="xs:ID" use="required"/>
 97                                      <xs:attribute name="name" type="stringNotEmpty" use="required"/>
 98                                  </xs:complexType>
 99                              </xs:element>
100                          </xs:sequence>
101                      </xs:complexType>
102                  </xs:element>
103  
104                  <xs:element name="orders">
105                      <xs:complexType>
106                          <xs:sequence>
107                              <xs:element name="order" minOccurs="1" maxOccurs="unbounded">
108                                  <xs:complexType>
109                                      <xs:sequence>
110                                          <xs:element name="menuId" type="xs:IDREF" minOccurs="1"/>
111                                          <xs:element name="deliveryAddress" type="stringNotEmpty"/>
112                                          <xs:element name="deliveryTime" type="stringNotEmpty"/>
113                                          <xs:element name="status" type="stringNotEmpty"/>
114                                      </xs:sequence>
115                                      <xs:attribute name="id" type="xs:ID" use="required"/>
116                                      <xs:attribute name="customerId" type="xs:IDREF" use="required"/>
117                                      <xs:attribute name="deliveryPeopleId" type="xs:IDREF" use="required"/>
118                                      <xs:attribute name="date" type="xs:date" use="required"/>
119                                  </xs:complexType>
120                              </xs:element>
121                          </xs:sequence>
122                      </xs:complexType>
123                  </xs:element>
124  
125                  <xs:element name="customers">
126                      <xs:complexType>
127                          <xs:sequence>
128                              <xs:element name="customer" minOccurs="1" maxOccurs="unbounded">
129                                  <xs:complexType>
130                                      <xs:sequence>
131                                          <xs:element name="name" type="stringNotEmpty"/>
132                                          <xs:element name="email" type="stringNotEmpty"/>
133                                          <xs:element name="address" type="stringNotEmpty"/>
134                                          <xs:element name="preference">
135                                              <xs:complexType>
136                                                  <xs:sequence>
137                                                      <xs:element name="diet" type="stringNotEmpty"/>
138                                                      <xs:element name="allergy" type="stringNotEmpty"/>
139                                                  </xs:sequence>
140                                              </xs:complexType>
141                                          </xs:element>
142                                      </xs:sequence>
143                                      <xs:attribute name="id" type="xs:ID" use="required"/>
144                                  </xs:complexType>
145                              </xs:element>
146                          </xs:sequence>
147                      </xs:complexType>
148                  </xs:element>
149  
150                  <xs:element name="deliveryPeople">
151                      <xs:complexType>
152                          <xs:sequence>
153                              <xs:element name="deliveryPerson" minOccurs="1" maxOccurs="unbounded">
154                                  <xs:complexType>
155                                      <xs:sequence>
156                                          <xs:element name="name" type="stringNotEmpty"/>
157                                          <xs:element name="email" type="stringNotEmpty"/>
158                                          <xs:element name="phone" type="stringNotEmpty"/>
159                                      </xs:sequence>
160                                      <xs:attribute name="id" type="xs:ID" use="required"/>
161                                  </xs:complexType>
162                              </xs:element>
163                          </xs:sequence>
164                      </xs:complexType>
165                  </xs:element>
166  
167                  <xs:element name="comments">
168                      <xs:complexType>
169                          <xs:sequence>
170                              <xs:element name="comment" minOccurs="1" maxOccurs="unbounded">
171                                  <xs:complexType>
172                                      <xs:sequence>
173                                          <xs:element name="text" type="stringNotEmpty"/>
174                                          <xs:element name="rating" type="xs:integer"/>
175                                      </xs:sequence>
176                                      <xs:attribute name="id" type="xs:ID" use="required"/>
177                                      <xs:attribute name="recipeId" type="xs:IDREF" use="required"/>
178                                      <xs:attribute name="customerId" type="xs:IDREF" use="required"/>
179                                  </xs:complexType>
180                              </xs:element>
181                          </xs:sequence>
182                      </xs:complexType>
183                  </xs:element>
184              </xs:sequence>
185          </xs:complexType>
186  
187          <xs:key name="ingredientIdKey">
188              <xs:selector xpath="ingredients/ingredient"/>
189              <xs:field xpath="@id"/>
190          </xs:key>
191  
192          <xs:key name="recipeIdKey">
193              <xs:selector xpath="recipes/recipe"/>
194              <xs:field xpath="@id"/>
195          </xs:key>
196  
197          <xs:key name="menuIdKey">
198              <xs:selector xpath="menus/menu"/>
199              <xs:field xpath="@id"/>
200          </xs:key>
201  
202          <xs:key name="orderIdKey">
203              <xs:selector xpath="orders/order"/>
204              <xs:field xpath="@id"/>
205          </xs:key>
206  
207          <xs:key name="customerIdKey">
208              <xs:selector xpath="customers/customer"/>
209              <xs:field xpath="@id"/>
210          </xs:key>
211  
212          <xs:key name="deliveryPeopleIdKey">
213              <xs:selector xpath="deliveryPeople/deliveryPerson"/>
214              <xs:field xpath="@id"/>
215          </xs:key>
216  
217          <xs:key name="commentIdKey">
218              <xs:selector xpath="comments/comment"/>
219              <xs:field xpath="@id"/>
220          </xs:key>
221  
222          <xs:keyref name="menuIdRef" refer="menuIdKey">
223              <xs:selector xpath="orders/order/menuId"/>
224              <xs:field xpath="."/>
225          </xs:keyref>
226  
227          <xs:keyref name="recipeIdRef" refer="recipeIdKey">
228              <xs:selector xpath="menus/menu/meal"/>
229              <xs:field xpath="@recipeId"/>
230          </xs:keyref>
231  
232          <xs:keyref name="customerIdRef" refer="customerIdKey">
233              <xs:selector xpath="orders/order"/>
234              <xs:field xpath="@customerId"/>
235          </xs:keyref>
236  
237          <xs:keyref name="deliveryPeopleIdRef" refer="deliveryPeopleIdKey">
238              <xs:selector xpath="orders/order"/>
239              <xs:field xpath="@deliveryPeopleId"/>
240          </xs:keyref>
241  
242          <xs:keyref name="recipeIdRef2" refer="recipeIdKey">
243              <xs:selector xpath="comments/comment"/>
244              <xs:field xpath="@recipeId"/>
245          </xs:keyref>
246  
247          <xs:keyref name="customerIdRef2" refer="customerIdKey">
248              <xs:selector xpath="comments/comment"/>
249              <xs:field xpath="@customerId"/>
250          </xs:keyref>
251      </xs:element>
252  
253  </xs:schema>