<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema version="2.0"
	targetNamespace="http://futurs.inria.fr/gemo/axml/"
	xmlns:axml="http://futurs.inria.fr/gemo/axml/"
	xmlns="http://futurs.inria.fr/gemo/axml/"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	elementFormDefault="qualified"
	attributeFormDefault="unqualified">
	
	<xsd:annotation><xsd:documentation>
		The schema defines some types used globally by the system, for instance in Web service WSDL's, in results etc.
	</xsd:documentation></xsd:annotation>
		
	<!-- Service call result -->
	<xsd:element name="result" type="ServiceCallResultType">
		<xsd:annotation><xsd:documentation>
			The tag wraps the incoming message of a service call. It is indispensable in the cases when the result is 
			of mixed content. It also an implementation of a communication protocol between Web service and a service call, 
			i.e. a Web service can return a message which is 'result' marked as 'STREAM' or 'END_OF_STREAM' and the service
			call will be stay active or terminate respectively, because it passes the result to its local RECEIVE Web service.
			
			Basically everything that is returned to a service call is wrapped (if the Web service did not do that) 
			into this tag and passed to the respective RECEIVE which decides what to do. For instance, RECEIVE may update
			the ids. 
		</xsd:documentation></xsd:annotation>
	</xsd:element>
	
	<xsd:attribute name="timestamp" type="xsd:dateTime">
		<xsd:annotation><xsd:documentation>
			Used to mark the result arrival time
		</xsd:documentation></xsd:annotation>
	</xsd:attribute>
	<xsd:attribute name="marker" default="END_OF_STREAM">
		<xsd:annotation><xsd:documentation>
			A Web service can mark a a result and a peer's RECEIVE will deal with it.
		</xsd:documentation></xsd:annotation>
		<xsd:simpleType>
			<xsd:restriction base="xsd:string">
				<xsd:enumeration value="END_OF_STREAM"/>
				<xsd:enumeration value="STREAM"/>
			</xsd:restriction>
		</xsd:simpleType>
	</xsd:attribute>
	<!-- 
	<xsd:attribute name="count" type="xsd:string">
		<xsd:annotation><xsd:documentation>
			The number of results sent by a stream. It is associated to END_OF_STREAM marker, in order to know on the other side
			how many results where sent, in case of processing the results in a wrong order.
		</xsd:documentation></xsd:annotation>
	</xsd:attribute>
	 -->
	<xsd:attribute name="streamSize" type="xsd:string">
		<xsd:annotation><xsd:documentation>
			The number of results sent by a stream. 
		</xsd:documentation></xsd:annotation>
	</xsd:attribute>
		<xsd:attribute name="messNumber" type="xsd:string">
		<xsd:annotation><xsd:documentation>
			the position of a message in a stream. 
		</xsd:documentation></xsd:annotation>
	</xsd:attribute>
	<xsd:attribute name="origin" type="xsd:string">
		<xsd:annotation><xsd:documentation>
			The xs:IDREF type is not used on purpose. This tells which service call the node belongs as a result.
		</xsd:documentation></xsd:annotation>
	</xsd:attribute>
	
	<xsd:complexType name="ServiceCallResultType" mixed="true">
		<xsd:sequence>
			<xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
		</xsd:sequence>
		<xsd:attribute ref="origin" use="required">
		</xsd:attribute>
		<xsd:attribute ref="timestamp" use="required"/>
		<xsd:attribute ref="marker" use="optional"/>
		<xsd:attribute ref="messNumber" use="optional"/>
		<xsd:attribute ref="streamSize" use="optional"/>
		
	</xsd:complexType>
	
	<!-- Service call information header in the soap message -->
	<xsd:element name="sc-communication" type="AddressSpecificationType">
		<xsd:annotation><xsd:documentation>
			This element is put into SOAP header on sending the request to the Web service. 
			This way an ActiveXML-aware Web service can respond asynchronously.
			IMPORTANT: this actually mimics WS-Addressing, maybe it is a good idea to use it
		</xsd:documentation></xsd:annotation>
	</xsd:element>
	
	<xsd:complexType name="AddressSpecificationType">
		<xsd:annotation><xsd:documentation>
			Address of a node (normally a service call node) in the system can be referenced by currentID or originalID.
		</xsd:documentation></xsd:annotation>
		<xsd:sequence minOccurs="0">
			<xsd:choice>
				<xsd:element name="currentID" type="NodeIdentificationType" />
				<xsd:element name="originalID" type="NodeIdentificationType" />
			</xsd:choice>
			<xsd:element name="endpoint" type="xsd:anyURI"/>
		</xsd:sequence>
	</xsd:complexType>
	
	<xsd:complexType name="NodeIdentificationType">
		<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>
</xsd:schema>