<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

	<xsd:annotation>
		<xsd:documentation xml:lang="en">
		Open Simulator Export/Import XML schema
		August 2008
		</xsd:documentation>
	</xsd:annotation>

    <!-- WARNING!!!
		 This is currently a draft, it does not reflect
		 what is exported, nor what will be understood
		 on import. It is included as a working document
		 and this comment will be removed at such time as
		 the schema corresponds to reality.
	 -->

	<!--
		REST-related information
		Inventory data is always framed by an 
		inventory element. Consists of zero or
		more elements representing either folders
		or items within those folders. The inventory
		element represents the "real" root folder.
	 -->

	<xsd:element name="inventory" type="inventory_ct" />

    <!--
         The inventory complex type is just an arbitrary
         sequence of folders and items. In reality it is
         typically just folders. Both item and folder 
         have corresponding complex types. It is distinct
         from folders insofar as it has no other defining
         attributes.
     -->

	<xsd:complexType name="inventory_ct">
		<xsd:element name="folder" type="folder_ct" maxOccurs="unbounded"/>
		<xsd:element name="item"   type="item_ct" maxOccurs="unbounded" />
	</xsd:complexType>
 
	<xsd:complexType name="folder_ct">
		<xsd:attribute name="UUID"         type="uuid_st" />
		<xsd:attribute name="name"         type="name_st" />
		<xsd:attribute name="type"         type="folder_type_st" />
		<xsd:attribute name="description"  type="xsd:string" />	<!-- added -->
		<xsd:attribute name="version" 	   type="unsignedShort" />
		<xsd:attribute name="owner"        type="uuid_st" />

		<xsd:attribute name="creator" 	   type="uuid_st" /> <!-- added -->
		<xsd:attribute name="creationdate" type="date_st" /> <!-- added -->

		<xsd:attribute name="parent"  	   type="uuid_st" />

		<xsd:element   name="permissions"  type="permissions_ct" maxOccurs="unbounded" />	<!-- added -->
		<xsd:element   name="folder"       type="folder_ct"      maxOccurs="unbounded" />
		<xsd:element   name="item"         type="item_ct"        maxOccurs="unbounded" />
	</xsd:complexType>

	<xsd:complexType name="item_ct">
		<xsd:attribute name="UUID"         type="uuid_st" />
		<xsd:attribute name="name"         type="name_st" />
		<xsd:attribute name="type"         type="inventory_type_st" />
		<xsd:attribute name="description"  type="xsd:string" />
		<xsd:attribute name="version" 	   type="unsignedShort" />	<!-- added -->
		<xsd:attribute name="owner"        type="uuid_st" />

		<xsd:attribute name="creator" 	   type="uuid_st" />
		<xsd:attribute name="creationdate" type="date_st" />

		<xsd:attribute name="folder"  	   type="uuid_st" />
		<xsd:attribute name="groupid" 	   type="uuid_st" />
		<xsd:attribute name="groupowned"   type="xsd:boolean" />
		<xsd:attribute name="saletype"     type="sale_st" />
		<xsd:attribute name="saleprice"    type="xsd:decimal" />

		<xsd:element   name="permissions"  type="permissions_ct" maxOccurs="unbounded" />
	</xsd:complexType>

	<xsd:complexType name="asset_ct">
		<xsd:attribute name="UUID"         type="uuid_st" />
		<xsd:attribute name="name"         type="name_st" />
		<xsd:attribute name="type"         type="asset_type_st" />
		<xsd:attribute name="description"  type="xsd:string" />
		<xsd:attribute name="version" 	   type="unsignedShort" />	<!-- added -->
		<xsd:attribute name="owner"        type="uuid_st" />

		<xsd:attribute name="creator" 	   type="uuid_st" />
		<xsd:attribute name="creationdate" type="date_st" />

		<xsd:attribute name="temporary"    type="xsd:boolean" />
		<xsd:attribute name="local"        type="xsd:boolean" />
		<xsd:attribute name="inline"       type="xsd:boolean" />
	</xsd:complexType>

	<!-- Constrained Simple Data types -->

    <!--
         We need to specify name as a simple type because on
         some platforms it is constrained by a certain length
         limitation. For completeness we indicate that whitespace
         should be preserved exactly as specified.
     -->

	<xsd:simpleType name="name_st">
		<xsd:restriction base="xsd:string">
		    <whiteSpace value="preserve" />
            <minLength value="0" />
            <maxLength value="64" />
		</xsd:restriction>
	</xsd:simpleType>

    <!--
         Type information in the folder is meant to indicate
         the preferred asset type for this folder. As such, that
         currently corresponds to the type values allowed for
         assets, however that is not mandated, so for
         now at least I'll represent this as a distinct 
         enumeration.
         This seems inappropriate; it seems like the folder's
         content should reflect the InventoryType classifications
         rather than the asset types.
     -->

	<xsd:simpleType name="folder_type_st">
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="Texture" />
			<xsd:enumeration value="Sound" />
			<xsd:enumeration value="CallingCard" />
			<xsd:enumeration value="Landmark" />
			<xsd:enumeration value="Script" />
			<xsd:enumeration value="Clothing" />
			<xsd:enumeration value="Object" />
			<xsd:enumeration value="Notecard" />
			<xsd:enumeration value="LSLText" />
			<xsd:enumeration value="LSLByteCode" />
			<xsd:enumeration value="TextureTGA" />
			<xsd:enumeration value="BodyPart" />
			<xsd:enumeration value="SoundWAV" />
			<xsd:enumeration value="ImageTGA" />
			<xsd:enumeration value="ImageJPEG" />
			<xsd:enumeration value="Animation" />
			<xsd:enumeration value="Gesture" />
			<xsd:enumeration value="Simstate" />
			<xsd:enumeration value="Unknown" />
			<xsd:enumeration value="LostAndFoundFolder" />
			<xsd:enumeration value="SnapshotFolder" />
			<xsd:enumeration value="TrashFolder" />
			<xsd:enumeration value="Folder" />
			<xsd:enumeration value="RootFolder" />
		</xsd:restriction>
	</xsd:simpleType>

    <!--
         Inventory item type designates an asset class, rather
         than a specific asset type. For example, "SnapShot"
         might include a number of asset types such as JPEG, 
         TGA, etc.. This is not a consistent interpretation,
         classifications such as LostAndFound are meta-types
         relative to asset classes. 

         These types should be abstract and not be tied to a 
         specific platform. A world's import facility should be
         responsible for mapping these to meaningful internal
         representations.

         These types were based on information in:
             libsecondlife/InventoryManager.cs
     -->

	<xsd:simpleType name="inventory_type_st">
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="Texture" />
			<xsd:enumeration value="Sound" />
			<xsd:enumeration value="CallingCard" />
			<xsd:enumeration value="Landmark" />
			<xsd:enumeration value="Script" />
			<xsd:enumeration value="Clothing" />
			<xsd:enumeration value="Object" />
			<xsd:enumeration value="Notecard" />
			<xsd:enumeration value="LSL" />
			<xsd:enumeration value="LSLBytecode" />
			<xsd:enumeration value="TextureTGA" />
			<xsd:enumeration value="BodyPart" />
			<xsd:enumeration value="Snapshot" />
			<xsd:enumeration value="Attachment" />
			<xsd:enumeration value="Wearable" />
			<xsd:enumeration value="Animation" />
			<xsd:enumeration value="Gesture" />
			<xsd:enumeration value="Folder" />
			<xsd:enumeration value="Unknown" />
			<xsd:enumeration value="LostAndFound" />
			<xsd:enumeration value="Trash" />
			<xsd:enumeration value="Root" />
		</xsd:restriction>
	</xsd:simpleType>

    <!--
         The asset types seem to be even more disarrayed than
         the inventory types. It seems to be little more than
         a reiteration of the inventory type information,
         which adds little or nothing to the overall data
         model.

         Of course, given that these are drawn from the
         libsecondlife definitions, we aren't at liberty to
         simply redefine them in place. But the XML definitions
         here could be made more useful.

         These types were based on information in:
             libsecondlife/AssetManager.cs
     -->

	<xsd:simpleType name="asset_type_st">
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="Texture" />
			<xsd:enumeration value="Sound" />
			<xsd:enumeration value="CallingCard" />
			<xsd:enumeration value="Landmark" />
			<xsd:enumeration value="Script" />
			<xsd:enumeration value="Clothing" />
			<xsd:enumeration value="Object" />
			<xsd:enumeration value="Notecard" />
			<xsd:enumeration value="LSLText" />
			<xsd:enumeration value="LSLByteCode" />
			<xsd:enumeration value="TextureTGA" />
			<xsd:enumeration value="BodyPart" />
			<xsd:enumeration value="SoundWAV" />
			<xsd:enumeration value="ImageTGA" />
			<xsd:enumeration value="ImageJPEG" />
			<xsd:enumeration value="Animation" />
			<xsd:enumeration value="Gesture" />
			<xsd:enumeration value="Simstate" />
			<xsd:enumeration value="Unknown" />
			<xsd:enumeration value="LostAndFoundFolder" />
			<xsd:enumeration value="SnapshotFolder" />
			<xsd:enumeration value="TrashFolder" />
			<xsd:enumeration value="Folder" />
			<xsd:enumeration value="RootFolder" />
		</xsd:restriction>
	</xsd:simpleType>

    <!-- This is describing the apparent form of a UUID. If
         we ever want a more metaphysical definition we'll 
         need to add to it.
     -->

	<xsd:simpleType name="uuid_st">
		<xsd:restriction base="xsd:string">
		    <xsd:pattern value="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"/>
		</xsd:restriction>
	</xsd:simpleType>

    <!-- This constrains the date representation. Currently
         it is simply an integer representing the elapsed
		 ?? since ??.
     -->

	<xsd:simpleType name="date_st">
		<xsd:restriction base="xsd:positiveInteger">
		</xsd:restriction>
	</xsd:simpleType>

    <!-- This constrains the representation of sale price.
		 Currently it is a simple decimal with no unit
		 specified. 
         Issues: interoperability.
     -->

	<xsd:simpleType name="sale_st">
		<xsd:restriction base="xsd:decimal">
		</xsd:restriction>
	</xsd:simpleType>

</xsd:schema>