view _test/Resources/resources.xsd @ 257:299af584c05f

collapse empty array elements in POSTed data
author sergey
date Fri, 14 Dec 2012 03:07:41 +0400
parents b6cde007a175
children
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">
				    <complexType>
				        <simpleContent>
				            <extension base="string">
				                <attribute name="vars" type="tns:VarList"/>
				            </extension>
				        </simpleContent>
				    </complexType>
				    
				</element>
			</choice>
			<group ref="tns:BindingExpressions"/>
			<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>
	
	<group name="BindingExpressions">
	   <choice>
	       <element name="bind" type="tns:Binding"/>
	       <element name="transform" type="tns:Transformation"/>
	       <element name="value" type="string" />
	   </choice>
	</group>

	<complexType name="OperationContract">

		<sequence>
			<element name="bind" type="tns:Binding" />
			<element name="response" minOccurs="0">
				<complexType>
					<choice>
						<element name="redirect" type="tns:RedirectResponse" />
						<element name="transform" type="tns:Transformation" />
					</choice>
				</complexType>
			</element>
		</sequence>

	</complexType>

	<complexType name="Binding">
		<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:Binding" />
			<element name="transform" type="tns:Transformation" />
			<element name="value" type="string" />
		</choice>
		<attribute name="name" type="tns:IdentifierName" use="required" />
	</complexType>


	<complexType name="Transformation">
		<sequence>
			<element name="target" type="tns:Binding" 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>
	
	<simpleType name="VarList">
	   <restriction base="string">
	       <pattern value="(\w+)(\s*,\s*(\w+))*" />
	   </restriction>
	</simpleType>

</schema>