<?xml version="1.0" encoding="iso-8859-1"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:annotation>
<xsd:documentation xml:lang="en">
GrubML - a markup language for recipes
Copyright (C) 2002 Simon Huggins &lt;huggie@earth.li&gt;
</xsd:documentation>
</xsd:annotation>

<xsd:element name="grubml">
	<xsd:complexType>
		<xsd:sequence>
			<xsd:element name="grub" type="grubType"/>
		</xsd:sequence>
		<xsd:attribute name="version" type="posdecimalType"/>
	</xsd:complexType>
</xsd:element>

<xsd:complexType name="grubType">
	<xsd:sequence>
		<xsd:element name="title" type="xsd:string"/>
<!--
The following might be better in RDF or something similar but it may want to
be in the recipe as well ?

See http://www.dublincore.org/documents/usageguide/
-->
		<xsd:element name="author" type="xsd:string" minOccurs="0"/>
		<xsd:choice>
			<xsd:element name="portions" type="xsd:integer"/>
			<xsd:element name="portionrange" type="integerRange"/>
		</xsd:choice>
		<xsd:element name="ingredients" type="ingredientsType"
			maxOccurs="unbounded"/>
		<xsd:element name="method" type="methodType"
			maxOccurs="unbounded"/>
		<xsd:element name="comments" type="xsd:string"
			minOccurs="0" maxOccurs="unbounded"/>
	</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ingredientsType">
	<xsd:sequence>
		<xsd:element name="desc" type="xsd:string" minOccurs="0"/>
		<xsd:element name="ingredient" type="ingredientType"
			maxOccurs="unbounded"/>
	</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ingredientType">
	<xsd:sequence>
		<xsd:element name="item" type="xsd:string"/>
		<xsd:choice>
			<xsd:element name="qty" type="qtyType" minOccurs="0"/>
			<xsd:element name="qtyrange" type="qtyRangeType" minOccurs="0"/>
		</xsd:choice>
		<xsd:element name="comments" type="xsd:string" minOccurs="0"/>
	</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="qtyType">
	<xsd:simpleContent>
		<xsd:extension base="xsd:decimal">
			<xsd:attribute name="units" type="unitsType"/>
		</xsd:extension>
	</xsd:simpleContent>
</xsd:complexType>

<xsd:complexType name="qtyRangeType">
	<xsd:simpleContent>
		<xsd:extension base="decimalRange">
			<xsd:attribute name="units" type="unitsType"/>
		</xsd:extension>
	</xsd:simpleContent>
</xsd:complexType>

<xsd:simpleType name="posdecimalType">
	<xsd:restriction base="xsd:decimal">
		<xsd:minExclusive value="0"/>
	</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="integerRange">
	<xsd:restriction base="xsd:string">
		<xsd:pattern value="[1-9][0-9]*-[1-9][0-9]*"/>
	</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="decimalRange">
	<xsd:restriction base="xsd:string">
		<xsd:pattern value="[0-9]+(\.[0-9]*)?-[0-9]+(\.[0-9]*)?"/>
	</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="unitsType">
	<xsd:restriction base="xsd:string">
		<xsd:enumeration value="ounces"/>
		<xsd:enumeration value="pounds"/>
		<xsd:enumeration value="grams"/>
		<xsd:enumeration value="kilograms"/>
		<xsd:enumeration value="fluid ounces"/>
		<xsd:enumeration value="millilitres"/>
		<xsd:enumeration value="centilitres"/>
		<xsd:enumeration value="decilitres"/>
		<xsd:enumeration value="litres"/>
		<xsd:enumeration value="tablespoons"/>
		<xsd:enumeration value="teaspoons"/>
		<xsd:enumeration value="other"/>
	</xsd:restriction>
</xsd:simpleType>



<xsd:complexType name="methodType">
	<xsd:sequence>
		<xsd:element name="desc" type="xsd:string" minOccurs="0"/>
		<xsd:element name="step" type="stepType"
			maxOccurs="unbounded"/>
	</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="stepType">
	<xsd:sequence>
		<xsd:element name="desc" type="xsd:string"/>
		<xsd:element name="comments" type="xsd:string" minOccurs="0"/>
	</xsd:sequence>
</xsd:complexType>


</xsd:schema>
