view _test/Resources/resources.xsd @ 223:edf011437be8

updated resources schema
author sergey
date Tue, 28 Aug 2012 17:29:42 +0400
parents 84a6382b49c8
children e6c050db7d98
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">
											<all>
												<element name="modelType" type="tns:ClassName" />
											</all>
											<attribute name="id" type="string" />
										</extension>
									</complexContent>
								</complexType>
							</element>
						</sequence>
					</complexType>
				</element>
				<element name="locators" minOccurs="0">
					<complexType>
						<sequence>
							<element name="locator" maxOccurs="unbounded">
								<complexType>
									<complexContent>
										<extension base="tns:ResourceLocator">
											<attribute name="name" type="string" />
										</extension>
									</complexContent>
								</complexType>
							</element>
						</sequence>
					</complexType>
				</element>
			</sequence>
		</complexType>
		<keyref name="locator-key-ref" refer="tns:locator-key">
			<selector xpath=".//tns:response/tns:locatorRef" />
			<field xpath="@ref" />
		</keyref>
		<key name="locator-key">
			<selector xpath="tns:locators/tns:locator" />
			<field xpath="@name" />
		</key>
	</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" type="tns:AbstractResult"
						minOccurs="0" />
				</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">
		<complexContent>
			<extension base="tns:MethodBinding">
				<attribute name="name" type="string" />
			</extension>
		</complexContent>
	</complexType>


	<complexType name="transformation">
		<attribute name="class" type="string" />
	</complexType>

	<complexType name="ResourceLocator">
		<sequence>
			<element name="var" type="tns:BindingVariable" minOccurs="0"
				maxOccurs="unbounded" />
			<element name="template" type="string" />
		</sequence>
	</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">
				<choice>
					<element name="locator" type="tns:ResourceLocator" />
					<element name="locatorRef">
						<complexType>
							<attribute name="ref" type="string" />
						</complexType>
					</element>
					<element name="status" type="tns:RedirectCodes" minOccurs="0" />
				</choice>
			</extension>
		</complexContent>
	</complexType>

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

</schema>