Browse Source

Add in XML Schema

Samuel W. Flint 4 years ago
parent
commit
ff6d216609
1 changed files with 100 additions and 0 deletions
  1. 100 0
      schema.xsd

+ 100 - 0
schema.xsd

@@ -0,0 +1,100 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+  <xs:element name="recipe">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element name="meta" type="MetaType" />
+        <xs:element name="nutrition" type="NutritionType" />
+        <xs:element name="ingredients" type="IngredientsType" />
+        <xs:element name="steps" type="StepsType" />
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="StepsType">
+    <xs:sequence>
+      <xs:element name="step" type="StepType" minOccurs="1" maxOccurs="unbounded" />
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="MetaType">
+    <xs:sequence>
+      <xs:element name="categories" type="CategoriesType" minOccurs="0" maxOccurs="1" />
+      <xs:element name="title" type="xs:string" />
+      <xs:element name="author" type="xs:string" />
+      <xs:element name="date" minOccurs="0" maxOccurs="1" type="xs:date" />
+      <xs:element name="collections" minOccurs="0" maxOccurs="1" type="CollectionsType" />
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="NutritionType">
+    <xs:sequence>
+      <xs:element name="servings" type="xs:positiveInteger" />
+      <xs:element name="servingSize" type="xs:string" />
+      <xs:element name="caloriesPerServing" type="xs:positiveInteger" />
+      <xs:element name="fat" type="xs:positiveInteger" />
+      <xs:element name="cholesterol" type="xs:positiveInteger" />
+      <xs:element name="sodium" type="xs:positiveInteger" />
+      <xs:element name="fiber" type="xs:positiveInteger" />
+      <xs:element name="sugars" type="xs:positiveInteger" />
+      <xs:element name="totalCarbs" type="xs:positiveInteger" />
+      <xs:element name="protein" type="xs:positiveInteger" />
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="CollectionsType">
+    <xs:sequence>
+      <xs:element name="collection" minOccurs="0" maxOccurs="unbounded" type="xs:string" />
+    </xs:sequence>
+  </xs:complexType>
+  
+  <xs:complexType name="CategoriesType">
+    <xs:sequence>
+      <xs:element name="category" minOccurs="0" maxOccurs="unbounded" type="xs:string" />
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="IngredientCategoryType">
+    <xs:simpleContent>
+      <xs:extension base="xs:string">
+        <xs:attribute name="ref" type="xs:string" />
+      </xs:extension>
+    </xs:simpleContent>
+  </xs:complexType>
+  
+  <xs:complexType name="IngredientCategoriesType">
+    <xs:sequence>
+      <xs:element name="category" minOccurs="0" maxOccurs="unbounded" type="IngredientCategoryType" />
+    </xs:sequence>
+  </xs:complexType>
+  
+  <xs:complexType name="IngredientsType">
+    <xs:sequence>
+      <xs:element name="categories" type="IngredientCategoriesType" />
+      <xs:element name="ingredient" type="IngredientType" minOccurs="1" maxOccurs="unbounded" />
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="IngredientType">
+    <xs:attribute name="ref" type="xs:string" />
+    <xs:attribute name="ingredient" type="xs:string" />
+    <xs:attribute name="amount" type="xs:positiveInteger" />
+    <xs:attribute name="unit" type="xs:string" />
+    <xs:attribute name="categories" type="xs:string" />
+  </xs:complexType>
+
+  <xs:complexType name="StepType" mixed="true">
+    <xs:sequence>
+      <xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded">
+        <xs:complexType>
+          <xs:attribute name="ref" type="xs:string" />
+          <xs:attribute name="category" type="xs:string" />
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <xs:attribute name="ref" type="xs:string" />
+    <xs:attribute name="sequence" type="xs:positiveInteger" />
+  </xs:complexType>
+
+</xs:schema>