view _test/Resources/resources.xsd @ 225:a1e868b0fba9

Bindings concept in progress
author sergey
date Fri, 31 Aug 2012 16:41:18 +0400
parents e6c050db7d98
children b6cde007a175
line wrap: on
line source

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://implab.org/schemas/resources"
	elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema"
	xmlns:tns="http://implab.org/schemas/resources">
	<element name="resources">
		<complexType>
			<sequence>
				<element name="root" type="tns:ResourceContract" />
				<element name="contracts" minOccurs="0">
					<complexType>
						<sequence>
							<element name="contract" maxOccurs="unbounded">
								<complexType>
									<complexContent>
										<extension base="tns:ResourceContract">
											<attribute name="id" type="string" />
											<attribute name="modelType" type="tns:ClassName"/>
										</extension>
									</complexContent>
								</complexType>
							</element>
						</sequence>
					</complexType>
				</element>
			</sequence>
		</complexType>
	</element>

	<!-- abstract types -->
	<complexType name="AbstractBinding" abstract="true" />
	<complexType name="AbstractTransformation" abstract="true" />
	<complexType name="AbstractResult" abstract="true" />

	<complexType name="ResourceContract">
		<sequence>
			<group ref="tns:RestOperations" />
			<element name="resource" maxOccurs="unbounded" minOccurs="0"
				type="tns:ChildResourceContract" />
		</sequence>
	</complexType>

	<complexType name="ChildResourceContract">
		<sequence>
			<choice>
				<element name="name" type="string" />
				<element name="match" type="string" />
			</choice>
			<element name="model" minOccurs="0" type="tns:MethodBinding" />
			<choice>
				<element name="contract">
					<complexType>
						<attribute name="ref" type="string" use="required" />
					</complexType>
				</element>
				<sequence>
					<group ref="tns:RestOperations" />
					<element name="resource" type="tns:ChildResourceContract"
						minOccurs="0" maxOccurs="unbounded" />
				</sequence>
			</choice>
		</sequence>

	</complexType>

	<group name="RestOperations">
		<sequence>
			<element name="get" type="tns:OperationContract" minOccurs="0" />
			<element name="post" type="tns:OperationContract" minOccurs="0" />
			<element name="put" type="tns:OperationContract" minOccurs="0" />
			<element name="delete" type="tns:OperationContract"
				minOccurs="0" />
		</sequence>
	</group>

	<complexType name="OperationContract">
		<complexContent>
			<extension base="tns:MethodBinding">
				<sequence>
					<element name="response" minOccurs="0">
					   <complexType>
					       <choice>
					           <element name="redirect" type="tns:RedirectResponse" />
					           <element name="transform" type="tns:Transformation"/>
					       </choice>
					   </complexType>
					</element>
				</sequence>
			</extension>
		</complexContent>
	</complexType>

	<complexType name="MethodBinding">
		<sequence>
			<element name="var" type="tns:BindingVariable" minOccurs="0"
				maxOccurs="unbounded" />
		</sequence>
		<attribute name="expr" type="string" use="required" />
		<attribute name="handler" type="string" />
	</complexType>

	<complexType name="BindingVariable">
		<choice>
			<element name="bind" type="tns:MethodBinding" />
			<element name="transform" type="tns:Transformation" />
		</choice>
		<attribute name="name" type="tns:IdentifierName" use="required" />
	</complexType>


	<complexType name="Transformation">
	   <sequence>
	       <element name="target" type="tns:MethodBinding" minOccurs="0"/>
	       <element name="transform" type="tns:Transformation" minOccurs="0"/>
	   </sequence>
		<attribute name="class" type="tns:ClassName" use="required" />
	</complexType>

	<complexType name="ResourceLocator">
		<attribute name="locator" type="string" use="required" />
	</complexType>

	<simpleType name="RedirectCodes">
		<restriction base="string">
			<enumeration value="moved-permanently" />
			<enumeration value="temporary-redirect" />
			<enumeration value="see-other" />
		</restriction>
	</simpleType>

	<complexType name="RedirectResponse">
		<complexContent>
			<extension base="tns:AbstractResult">
				<sequence>
					<element name="location" type="tns:ResourceLocator" />
					<element name="status" type="tns:RedirectCodes" minOccurs="0" />
				</sequence>
			</extension>
		</complexContent>
	</complexType>

	<simpleType name="ClassName">
		<restriction base="string">
			<pattern value="\w+(::\w+)*" />
		</restriction>
	</simpleType>

	<simpleType name="IdentifierName">
		<restriction base="string">
			<pattern value="\w+" />
		</restriction>
	</simpleType>

</schema>