<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://api.textwise.com"
            xmlns:tns="http://api.textwise.com"
            elementFormDefault="qualified">
							
	<!--
    Item - represents an object that a management operation will
			be performed on. 
		
		externalId - The Id the caller uses to identify the item. This
			is an alpha numeric field with a max length of 1024
        
		item[operation]  - The operation to perform on the item. 
           ADD - adds the item 
           DELETE- deletes the item 
           UPDATE - updates the item 
           ADD_OR_UPDATE - updates or adds the item if it doesn't exist
    attribute [name] -  the name of the attribute(E.g. title) 
  -->
	<xs:attributeGroup name="itemAttributes">
		<xs:attribute name="externalId" type="xs:string" use="required"/>
		<xs:attribute name="operation" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="ADD"/>
					<xs:enumeration value="DELETE"/>
					<xs:enumeration value="UPDATE"/>
					<xs:enumeration value="ADD_OR_UPDATE"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
	</xs:attributeGroup>

	<!--
   ContentPayload - represents the data sent by the caller
	 
   clearIndex - an attribute that is only supported for Batch calls and
	   instructs the system to clean offline index before processing the 
		 content file. This results in an index that contains only the
		 content items provided within the file.
   deleteItemsOlderThan - an attribute that is only supported for Batch
	   calls and instructs the system to remove items from the index 
     that are older than the specified time period.
	-->
	<xs:attributeGroup name="payloadOptions">
		<xs:attribute name="clearIndex" type="xs:boolean"/>
		<!-- http://www.w3.org/TR/xmlschema-2/#duration -->
		<xs:attribute name="deleteItemsOlderThan" type="xs:duration"/>
	</xs:attributeGroup>
	
	<xs:element name="content-payload">
		<xs:complexType>
			<xs:sequence>
				
		  <!--
				ItemSignatureAttributes - represents the attribute names of the
					items that are used for creating a signature. This node, and
					at least one child node, must exist within the content payload
					or the call will be rejected.
			-->
				<xs:element name="item-signature-attributes" minOccurs="0" maxOccurs="1">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="attribute" type="xs:string" maxOccurs="unbounded"/>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			
			<!--
				StoredItemAttributes - represents the attribute names of the items
					that will be stored by the system. By default no item information
					will be stored for an item (other than externalId) unless this node
					exists within payload file with 1 or more attributes are listed.
			-->
				<xs:element name="item-stored-attributes" minOccurs="0" maxOccurs="1">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="attribute" type="xs:string" maxOccurs="unbounded"/>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				
			<!--
				Facets - defines the item attributes that will be configured as
				         facets for the index for use in match requests.  Note
				         that attributes defined as facets will automatically be
				         added to the set of stored item attributes for the
				         index.
			 -->
				<xs:element name="facets" minOccurs="0" maxOccurs="1">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="facet" minOccurs="0" maxOccurs="unbounded">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="ranges" minOccurs="0" maxOccurs="1">
											<xs:complexType>
												<xs:sequence>
													<xs:element name="range" minOccurs="1" maxOccurs="unbounded">
														<xs:complexType>
															<xs:attribute name="start" type="xs:string" />
															<xs:attribute name="end" type="xs:string" />
														</xs:complexType>
													</xs:element>
												</xs:sequence>
											</xs:complexType>
										</xs:element>
									</xs:sequence>
									<xs:attribute name="name" type="xs:string" use="required" />
									<xs:attribute name="multivalue" type="xs:boolean" default="false" />
									<xs:attribute name="multivalueDelimiter" type="xs:string" default="," />
									<xs:attribute name="dateformat" type="xs:string" />
									<xs:attribute name="type" use="required">
										<xs:simpleType>
											<xs:restriction base="xs:string">
												<xs:enumeration value="string"/>
												<xs:enumeration value="short"/>
												<xs:enumeration value="int"/>
												<xs:enumeration value="long"/>
												<xs:enumeration value="float"/>
												<xs:enumeration value="price"/>
												<xs:enumeration value="timestamp"/>
											</xs:restriction>
										</xs:simpleType>
									</xs:attribute>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				
				<xs:element name="item" minOccurs="0" maxOccurs="unbounded">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="attribute" minOccurs="0" maxOccurs="unbounded">
								<xs:complexType>
									<xs:simpleContent>
										<xs:extension base="xs:string">
											<xs:attribute name="name" type="xs:string" />
										</xs:extension>
									</xs:simpleContent>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
						<xs:attributeGroup ref="tns:itemAttributes"/>
					</xs:complexType>
				</xs:element>
				
			</xs:sequence>
			<xs:attributeGroup ref="tns:payloadOptions"/>
		</xs:complexType>
	</xs:element>
</xs:schema>

