<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:include schemaLocation="expressions.xsd"/>
	<xs:complexType name="offset">
		<xs:attribute name="value" type="arglist"/>	
	</xs:complexType>
	<xs:complexType name="momentum">
		<xs:attribute name="value" type="arglist"/>	
	</xs:complexType>
	<xs:complexType name="angles">
		<xs:attribute name="value" type="arglist"/>	
	</xs:complexType>
	<!-- now, define all the child elements of orientation -->
	<xs:element name="x_offset" type="offset"/>
	<xs:element name="y_offset" type="offset"/>
	<xs:element name="s_offset" type="offset"/>
	<xs:element name="x_pitch" type="angles"/>
	<xs:element name="y_pitch" type="angles"/>
	<xs:element name="tilt" type="angles"/>
	<xs:element name="roll" type="angles"/>
	<!-- now define the orientation tag -->
	<xs:complexType name="rootorientationtype">
		<xs:all>
			<xs:element ref="x_offset" minOccurs="0"/>
			<xs:element ref="y_offset" minOccurs="0"/>
			<xs:element ref="s_offset" minOccurs="0"/>
			<xs:element ref="x_pitch" minOccurs="0"/>
			<xs:element ref="y_pitch" minOccurs="0"/>
			<xs:element ref="tilt" minOccurs="0"/>
			<xs:element ref="roll" minOccurs="0"/>
		</xs:all>
		<xs:attribute name="name" type="xs:string" use="optional"/>
		<xs:attribute name="ref" type="xs:string"/>
		<xs:attribute name="at" type="place" default="CENTER"/>
	</xs:complexType>
	<xs:element name="orientation" type="rootorientationtype"/>
	<!-- now, define all the child elements of global position -->
	<xs:element name="x" type="offset"/>
	<xs:element name="y" type="offset"/>
	<xs:element name="z" type="offset"/>
	<xs:element name="phi" type="angles"/>
	<xs:element name="psi" type="angles"/>
	<xs:element name="theta" type="angles"/>
	<!-- now define the global position  tag -->
	<xs:element name="global_position">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="x"/>
				<xs:element ref="y"/>
				<xs:element ref="z"/>
				<xs:element ref="phi"/>
				<xs:element ref="psi"/>
				<xs:element ref="theta"/>
			</xs:sequence>
			<xs:attribute name="name" type="xs:string"/>
			<xs:attribute name="ref" type="xs:string"/>
			<xs:attribute name="at" type="place" default="CENTER"/>
		</xs:complexType>
	</xs:element>
	<!-- child elements of position not already defined above -->
	<xs:element name="p_x" type="momentum"/>
	<xs:element name="p_y" type="momentum"/>
	<xs:element name="p_z" type="momentum"/>
	<!-- the tag name position may be misleading. Perhaps we should name it such -->
	<!-- that it is clear that it refers to phase space. Perhaps phasespace ? -->
	<xs:element name="position">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="x"/>
				<xs:element ref="p_x"/>
				<xs:element ref="y"/>
				<xs:element ref="p_y"/>
				<xs:element ref="z"/>
				<xs:element ref="p_z"/>
			</xs:sequence>
			<xs:attribute name="name" type="xs:string"/>
			<xs:attribute name="ref" type="xs:string"/>
			<xs:attribute name="at" type="place" default="CENTER"/>
		</xs:complexType>
	</xs:element>
	<xs:simpleType name="place">
		<xs:restriction base="xs:string">
			<xs:enumeration value="ENTRANCE END"/>
			<xs:enumeration value="CENTER"/>
			<xs:enumeration value="EXIT END"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>
