<?xml version="1.0" encoding="UTF-8"?>

<schema
	xmlns="http://www.w3.org/2001/XMLSchema"
	xml:lang="EN"
	targetNamespace="http://msqr.us/xsd/ieat"
	jaxb:version="1.0"
	xmlns:eat="http://msqr.us/xsd/ieat"
	xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
	xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
	jaxb:extensionBindingPrefixes="xjc"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	elementFormDefault="qualified"
	attributeFormDefault="unqualified">
    
	<complexType name="base">
		<simpleContent>
			<extension base="string">
				<attribute name="baseId" type="int"/>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="course">
		<simpleContent>
			<extension base="string">
				<attribute name="courseId" type="int"/>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="difficulty">
		<simpleContent>
			<extension base="string">
				<attribute name="difficultyId" type="int"/>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="ethnicity">
		<simpleContent>
			<extension base="string">
				<attribute name="ethnicityId" type="int"/>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="ingredient">
		<sequence>
			<element name="name" type="string"/>
			<element name="description" type="string" minOccurs="0"/>
		</sequence>
		<attribute name="ingredientId" type="int"/>
	</complexType>

	<complexType name="meal">
		<sequence>
			<element name="name" type="string"/>
			<element name="recipe" type="eat:meal-recipe" maxOccurs="unbounded"/>
			<element name="owner" type="eat:user" minOccurs="0"/>
		</sequence>
		<attribute name="mealId" type="long"/>
	</complexType>
	
	<complexType name="meal-recipe">
		<sequence>
			<element name="recipe" type="eat:recipe"/>
			<element name="course" type="eat:course"/>
		</sequence>
		<attribute name="quantity" type="double" use="optional" default="1.0"/>
	</complexType>
	
	<complexType name="prep-time">
		<simpleContent>
			<extension base="string">
				<attribute name="prepTimeId" type="int"/>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="recipe">
		<sequence>
			<element name="name" type="string"/>
			<element name="excerpt" type="string" minOccurs="0"/>
			<element name="source" type="string" minOccurs="0"/>
			<element name="directions" type="string" minOccurs="0"/>
			<element name="image" type="string" minOccurs="0">
				<annotation>
					<documentation>
						The URL of an image file to display with the recipe.
					</documentation>
				</annotation>
			</element>
			<element name="base" type="eat:base" minOccurs="0"/>
			<element name="course" type="eat:course" minOccurs="0"/>
			<element name="ethnicity" type="eat:ethnicity" minOccurs="0"/>
			<element name="difficulty" type="eat:difficulty" minOccurs="0"/>
			<element name="owner" type="eat:user" minOccurs="0"/>
			<element name="prep-time" type="eat:prep-time" minOccurs="0"/>
			<element name="system" type="eat:system"/>
			<element name="ingredient" type="eat:recipe-ingredient" minOccurs="0" maxOccurs="unbounded"/>
			<element name="related-recipe" type="eat:related-recipe" minOccurs="0" maxOccurs="unbounded"/>
			<element name="step" type="eat:recipe-step" minOccurs="0" maxOccurs="unbounded"/>
			<element name="comment" type="eat:recipe-comment" minOccurs="0" maxOccurs="unbounded"/>
			<element name="rating" type="eat:recipe-rating" minOccurs="0" maxOccurs="unbounded"/>
		</sequence>
		<attribute name="recipeId" type="long"/>
		<attribute name="servingSize" type="int"/>
		<attribute name="createdDate" type="dateTime"/>
		<attribute name="modifiedDate" type="dateTime" use="optional"/>
	</complexType>
	
	<complexType name="recipe-comment">
		<simpleContent>
			<extension base="string">
				<attribute name="commentId" type="long"/>
				<attribute name="createdDate" type="dateTime"/>
				<attribute name="userId" type="int"/>
			</extension>
		</simpleContent>
	</complexType>
	
	<complexType name="recipe-ingredient">
		<sequence>
			<element name="unit" type="eat:unit" minOccurs="0"/>
			<!-- Removing choice for backwards compatibility with HJAXB1 -->
			<!--choice minOccurs="1" maxOccurs="1"-->
				<element name="ingredient" type="eat:ingredient" minOccurs="0"/>
				<element name="recipe" type="eat:recipe" minOccurs="0"/>
			<!--/choice-->
		</sequence>
		<attribute name="quantity" type="double"/>
		<attribute name="qualifier" type="string" use="optional"/>
		<attribute name="optional" type="boolean"/>
	</complexType>

	<complexType name="recipe-rating">
		<attribute name="ratingId" type="long"/>
		<attribute name="rating" type="short"/>
		<attribute name="createdDate" type="dateTime"/>
		<attribute name="userId" type="int"/>
	</complexType>
	
	<complexType name="recipe-step">
		<simpleContent>
			<extension base="string"/>
		</simpleContent>
	</complexType>

	<complexType name="related-recipe">
		<sequence>
			<element name="kind" type="eat:relation-kind"/>
			<element name="recipe" type="eat:recipe"/>
		</sequence>
	</complexType>

	<complexType name="relation-kind">
		<simpleContent>
			<extension base="string">
				<attribute name="relationKindId" type="int"/>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="system">
		<simpleContent>
			<extension base="string">
				<attribute name="systemId" type="int"/>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="unit">
		<simpleContent>
			<extension base="string">
				<attribute name="unitId" type="int"/>
				<attribute name="abbreviation" type="string"/>
				<attribute name="systemId" type="int"/>
				<attribute name="toMetric" type="double" use="optional"/>
				<attribute name="toImperial" type="double" use="optional"/>
				<attribute name="toUS" type="double" use="optional"/>
				<attribute name="mass" type="boolean" use="optional" default="false"/>
			</extension>
		</simpleContent>
	</complexType>

	<complexType name="user">
		<sequence>
			<element name="name" type="string"/>
			<element name="email" type="string"/>
			<element name="password" type="string"/>
		</sequence>
		<attribute name="accessLevel" type="int"/>
		<attribute name="country" type="string"/>
		<attribute name="createdDate" type="dateTime"/>
		<attribute name="userId" type="int"/>
		<attribute name="language" type="string"/>
		<attribute name="lastLoginDate" type="dateTime"/>
		<attribute name="login" type="string"/>
	</complexType>
	
</schema>
