<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema version="2.0"
	attributeFormDefault="unqualified"
	elementFormDefault="qualified"
	targetNamespace="http://futurs.inria.fr/gemo/axml/service/Algebra"
	xmlns="http://futurs.inria.fr/gemo/axml/service/Algebra"
	xmlns:axml="http://futurs.inria.fr/gemo/axml/"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
		
	<xsd:annotation><xsd:documentation>
		Defines types and elements needed for the algebra operations of a peer.
	</xsd:documentation></xsd:annotation>

	<xsd:complexType name="AlgebraType">
		<xsd:sequence>
			<xsd:element ref="address" minOccurs="1" maxOccurs="unbounded">
			</xsd:element>
			<xsd:choice>
				<xsd:element name="data">
					<xsd:annotation><xsd:documentation>
							Forrest of xml. When the address is not specified
							NEWNODE installs this element as a lonely root.
					</xsd:documentation></xsd:annotation>
					<xsd:complexType>
						<xsd:sequence>
							<xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
						</xsd:sequence>
					</xsd:complexType>
				</xsd:element>
				<xsd:element name="reference">
					<xsd:annotation><xsd:documentation>
						SEND can refer to a node in the document, instead of having a copy of it underneath
						
						TODO: it might be a better solution to incorporate XPointer for referencing, although we need only
						restricted subset of it
					</xsd:documentation></xsd:annotation>
					<xsd:complexType>
						<xsd:choice>
							<xsd:element name="currentID" type="IDType" />
							<xsd:element name="originalID" type="IDType" />
						</xsd:choice>
					</xsd:complexType>
				</xsd:element>
			</xsd:choice>
		</xsd:sequence>
	</xsd:complexType>
	
	<xsd:element name="address" type="AddressType">
		<xsd:annotation><xsd:documentation>
			SEND/RECEIVE can have multiple destinations.
			NEWNODE can have empty address.
		</xsd:documentation></xsd:annotation>
	</xsd:element>
	
	<xsd:complexType name="AddressType">
		<xsd:sequence minOccurs="0">
			<xsd:choice>
				<xsd:element name="currentID" type="IDType" />
				<xsd:element name="originalID" type="IDType" />			
			</xsd:choice>
			<xsd:element name="endpoint" minOccurs="0" type="xsd:anyURI">
				<xsd:annotation><xsd:documentation>
				SEND: for telling the corresponding RECEIVE
				RECEIVE: for information about SEND, basically is ignored
				NEWNODE: ignored
				</xsd:documentation></xsd:annotation>
			</xsd:element>
		</xsd:sequence>
	</xsd:complexType>
	
	<xsd:complexType name="IDType">
		<xsd:all>
			<xsd:element name="peerID" type="xsd:string"></xsd:element>
			<xsd:element name="docID" type="xsd:string"></xsd:element>
			<xsd:element name="nodeID" type="xsd:string"></xsd:element>
		</xsd:all>
	</xsd:complexType>

	<!-- WSDL -->
	<xsd:element name="receive" type="AlgebraType">
		<xsd:annotation><xsd:documentation>
			This element used in sc/ws-soap/receive declares the RECEIVE service call
		</xsd:documentation></xsd:annotation>
	</xsd:element>

	<!-- WSDL -->
	<xsd:element name="send" type="AlgebraType">
		<xsd:annotation><xsd:documentation>
			This element used in sc/ws-soap/send declares the SEND service call
		</xsd:documentation></xsd:annotation>
	</xsd:element>

	<!-- WSDL -->
	<xsd:element name="newNode" type="AlgebraType">
		<xsd:annotation><xsd:documentation>
			This element used in sc/ws-soap/newNode declares the NEWNODE service call
		</xsd:documentation></xsd:annotation>
	</xsd:element>
</xsd:schema>
