<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tmd="urn:astrogrid:schema:dsa:TableMetaDoc:v1.1" elementFormDefault="qualified" targetNamespace="urn:astrogrid:schema:dsa:TableMetaDoc:v1.1" version="1.1">
	<xs:annotation>
		<xs:documentation> 
			This schema defines the 'tabular catalog metadocument' that is used to
			describe tabular catalog. 'Catalog' here is used in the database sense,
         as a collection of tables - they need not be sky catalogs. 
         The schema is self-contained, and might be referred to from other 
         schemas. 
         Element names are similar where possible to the VO-standard metadata
			documents. In a document that informs an AstroGrid skycatserver 
         installation, the root element must be DatasetDescription in this 
         namespace. Other documents may use Catalog or Table as root elements, 
         but these documents will not be usuable in AstroGrid software.
         This version of the schema is similar to version 1.0, but adds
         the capability to express that a given table should be conesearchable,
         and if so which columns should be treated as RA and DEC columns.
		</xs:documentation>
	</xs:annotation>
	
	<xs:element name="DatasetDescription">
		<xs:annotation>
			<xs:documentation>
				Describes a collection of catalogues presumed to be held in the 
            same database; the catalogues need not be logically connected 
            but must be accessible through the same interfaces, such a common 
            JDBC connection. This must be the root element in a document that 
            informs an AstroGrid skycatserver installation.
			</xs:documentation>
		</xs:annotation>
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="tmd:Catalog" maxOccurs="unbounded"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	
   <!-- This element represents an individual database in a DBMS.
   It is *not* possible for a single DBMS database to be represented
   in multiple Catalog elements. -->
	<xs:element name="Catalog">
		<xs:complexType>
			<xs:sequence>
            <!-- The value of Name is used in stating the catalogue name to 
            the outside world, e.g. in VOResource registrations (e.g.
            if you have a copy of USNOB, but the actual database in your
            DBMS is called db1_usnob_2006, you could use "USNOB" here. 

            Catalog names must be unique.
            -->
				<xs:element name="Name" type="xs:string"/>
				<xs:element name="Description" type="xs:string" minOccurs="0"/>
				<xs:element ref="tmd:Table" maxOccurs="unbounded"/>
			</xs:sequence>
         <!-- The value of ID must be the actual database name in the DBMS 
           (so if you have a copy of USNOB, but the actual database in your
            DBMS is called db1_usnob_2006, you should use "db1_usnob_2006"  
            here. 
            Catalog ID attributes must be unique.
            -->
			<xs:attribute name="ID" use="required" type="xs:string"/>
		</xs:complexType>
	</xs:element>

	<xs:element name="Table">
		<xs:complexType>
			<xs:sequence>
            <!-- The value of Name is used in stating the table name to 
            the outside world, e.g. in VOResource registrations.  
            Probably best to use the actual DBMS table name here, 
            but you don't have to (see comments re Catalog element).

            Table names must be unique within a given Catalog element.
            -->
				<xs:element name="Name" type="xs:string"/>
				<xs:element name="Description" type="xs:string" minOccurs="0"/>

            <!-- The conesearch settings for the table:  if present, 
            indicates that the table is conesearchable, and which columns 
            should be treated as the RA and Dec coordinates. -->
            <xs:element ref="tmd:ConeSettings" minOccurs="0" maxOccurs="1"/>

            <!-- The actual columns in the table -->
				<xs:element maxOccurs="unbounded" ref="tmd:Column"/>
			</xs:sequence>
         <!-- The value of ID must be the actual table name in the DBMS.
            Table ID attributes must be unique within the parent Catalog.
         -->
			<xs:attribute name="ID" use="required" type="xs:string"/>
		</xs:complexType>
	</xs:element>

	<xs:element name="Column">
		<xs:complexType>
			<xs:sequence>
            <!-- The value of Name is used in stating the column name to 
            the outside world, e.g. in VOResource registrations.  
            Probably best to use the actual DBMS column name here, 
            but you don't have to (see comments re Catalog element).
            Column names must be unique within the parent Table.
            -->
				<xs:element name="Name" type="xs:string"/>

            <!-- The data type of this column, from a restricted subset
                  of datatypes that may be represented in VOTable. -->
				<xs:element ref="tmd:Datatype"/>

            <!-- A human-readable description of the column -->
				<xs:element name="Description" type="xs:string" minOccurs="0"/>
				<xs:element minOccurs="0" ref="tmd:Units"/>

            <!-- Reserved for future use -->
				<xs:element name="DimEq" type="xs:string" minOccurs="0"/>

            <!-- Reserved for future use -->
				<xs:element name="Scale" type="xs:string" minOccurs="0"/>

            <!-- The UCD(s) for this column -->
				<xs:element ref="tmd:UCD" maxOccurs="unbounded" minOccurs="1"/>

            <!-- Related error column: reserved for future use -->
				<xs:element ref="tmd:ErrorColumn" minOccurs="0"/>

            <!-- Reserved for future use -->
				<xs:choice>
				   <xs:element ref="tmd:SkyPolarCoord" minOccurs="0"/>
					<xs:element name="SkyHtmPos" minOccurs="0"/>
				</xs:choice>
			</xs:sequence>

         <!-- The value of ID must be the actual column name in the DBMS.
            Column ID attributes must be unique within the parent Table.
         -->
			<xs:attribute name="ID" use="required" type="xs:string"/>

         <!-- Is this column indexed?  (Reserved for future use) -->
			<xs:attribute name="indexed" use="required" type="xs:boolean"/>
		</xs:complexType>
	</xs:element>

	<xs:element name="ConeSettings">
		<xs:complexType>
			<xs:sequence>
            <!-- These two fields must have the same value as the "Name" 
            elements of the columns to be treated as RA and Dec (i.e.
            they must correspond to the published column names, if
            these differ from the physical database column names).
            -->
				<xs:element name="RAColName" type="xs:string"/>
				<xs:element name="DecColName" type="xs:string"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>

	<xs:element name="Datatype">
		<xs:annotation>
			<xs:documentation>
				Allowed types of table columns.
			</xs:documentation>
		</xs:annotation>
		<xs:simpleType>
			<xs:restriction base="xs:string">
       <!-- This is the original set of types used by DSA -->
				<xs:enumeration value="float"/>
				<xs:enumeration value="int"/>
				<xs:enumeration value="string"/>
				<xs:enumeration value="dateTime"/>

       <!-- These are an extended list from the ScalarDataTypes in
            VOTable / VOResource schemas;  not all may yet be in use 
            within DSA, but are put here for future schema validation
            compatibility. -->
            <xs:enumeration value="boolean"/>    
            <xs:enumeration value="bit"/>
            <xs:enumeration value="unsignedByte"/>    
            <xs:enumeration value="short"/>
            <xs:enumeration value="long"/>
            <xs:enumeration value="char"/>
            <xs:enumeration value="unicodeChar"/>
            <xs:enumeration value="double"/>
            <xs:enumeration value="floatComplex"/>
            <xs:enumeration value="doubleComplex"/>

			</xs:restriction>
		</xs:simpleType>
	</xs:element>
	<xs:element name="Units" type="xs:string"/>
	<xs:element name="UCD">
		<xs:complexType mixed="true">
			<xs:attribute name="version" use="required" type="xs:string">
				<xs:annotation>
					<xs:documentation>The UCD version describes which version of the UCD dictionary to use, eg
						'1' or '1+'</xs:documentation>
				</xs:annotation>
			</xs:attribute>
		</xs:complexType>
	</xs:element>

	<xs:element name="ErrorColumn" type="xs:string"/>

	<xs:element name="SkyPolarCoord">
		<xs:simpleType>
		<xs:restriction base="xs:string">
		<xs:enumeration value="RA"/>
		<xs:enumeration value="DEC"/>
		</xs:restriction>
		</xs:simpleType>
  </xs:element>

</xs:schema>