<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.opengis.net/bxfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:bxfs="http://www.opengis.net/bxfs" xmlns:gml="http://www.opengis.net/gml" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="0.0.1">

   <xs:import namespace="http://www.opengis.net/gml" schemaLocation="file:/Users/rajsingh/ogc/specs/schemas.opengis.net/gml/2.1.2/geometry.xsd"/>

   <!-- ****************************************************************** -->
   <!-- * FEATURECOLLECTION - A feature collection is a heterogeneous    * -->
   <!-- *                     collection of feature instance sets.       * -->
   <!-- ****************************************************************** -->
   <xs:element name="FeatureCollection">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="Description" type="bxfs:DescriptionType" minOccurs="0"/>
            <xs:element name="FeatureSet" type="bxfs:FeatureSetType" maxOccurs="unbounded"/>
         </xs:sequence>
         <xs:attribute name="version" type="xs:string" use="required" fixed="0.0.1"/>
      </xs:complexType>
   </xs:element>

   <!-- ****************************************************************** -->
   <!-- * DESCRIPTION - A description is a very lightweight structure    * -->
   <!-- *               for attaching metadata to various elements.      * -->
   <!-- *               More detailed metadata (such as that that may    * -->
   <!-- *               be stored in a registry) can be referenced by    * -->
   <!-- *               using the MetadataURL element.  The optional     * -->
   <!-- *               standard attribute may be used to indicate the   * -->
   <!-- *               type of metadata being pointed to.  For example, * -->
   <!-- *               FGDC or ISO19119 or ...  The url content is the  * -->
   <!-- *               pointer to the detailed metadata and may in fact * -->
   <!-- *               point to metadata stored in a catalog.           * -->
   <!-- ****************************************************************** -->
   <xs:complexType name="DescriptionType">
      <xs:sequence>
         <xs:element name="Title" type="xs:string" minOccurs="0" maxOccurs="1"/>
         <xs:element name="Abstract" type="xs:string" minOccurs="0" maxOccurs="1"/>
         <xs:element name="MetadataURL" minOccurs="0" maxOccurs="unbounded">
            <xs:complexType>
               <xs:complexContent>
                  <xs:extension base="xs:anyURI">
                     <xs:attribute name="standard" type="xs:anyURI" use="optional"/>
                  </xs:extension>
               </xs:complexContent>
            </xs:complexType>
         </xs:element>
         <xs:element name="BoundingBox" type="bxfs:BoundingBoxType" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>
   <xs:complexType name="BoundingBoxType">
      <xs:attribute name="srs" type="xs:string" use="optional"/>
      <xs:attribute name="minx" type="xs:double" use="required"/>
      <xs:attribute name="miny" type="xs:double" use="required"/>
      <xs:attribute name="maxx" type="xs:double" use="required"/>
      <xs:attribute name="maxy" type="xs:double" use="required"/>
   </xs:complexType>

   <!-- ****************************************************************** -->
   <!-- * FEATURESET - A feature set is a homogenous collection of       * -->
   <!-- *              feature instances.  Homogenous features have the  * -->
   <!-- *              same properties.                                  * -->
   <!-- *                                                                * -->
   <!-- *              NOTES: the srsName attribute is the name of the   * -->
   <!-- *                     default SRS.  Any geometry in the set not  * -->
   <!-- *                     otherwise labeled should be assumed to be  * -->
   <!-- *                     in the default SRS.                        * -->
   <!-- ****************************************************************** -->
   <xs:complexType name="FeatureSetType">
      <xs:sequence>
         <xs:element name="Description" type="bxfs:DescriptionType" minOccurs="0"/>
         <xs:element name="Definition" type="bxfs:DefinitionType"/>
         <xs:element name="Feature" type="bxfs:FeatureType" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="srsName" type="anyURI" use="optional"/>
   </xs:complexType>

   <!-- ****************************************************************** -->
   <!-- * DEFINITION - The Definition element is used to specify the     * -->
   <!-- *              names and types of all the properties in a        * -->
   <!-- *              feature set.                                      * -->
   <!-- ****************************************************************** -->
   <xs:complexType name="DefinitionType">
      <xs:sequence>
         <xs:element name="Description" type="bxfs:DescriptionType" minOccurs="0"/>
         <xs:element name="PropertyDef" type="bxfs:PropertyDefType" maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>

   <xs:complexType name="PropertyDefType">
      <xs:sequence>
         <xs:element name="Description" type="bxfs:DescriptionType" minOccurs="0"/>
         <xs:element name="ValueDescriptionTable" type="bxfs:ValueDescriptionTableType" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="type">
         <xs:simpleType>
            <xs:restriction base="xs:NMTOKEN">
               <xs:enumeration value="string"/>
               <xs:enumeration value="number"/>
               <xs:enumeration value="date"/>
               <xs:enumeration value="boolean"/>
               <xs:enumeration value="uri"/>
               <xs:enumeration value="raw64"/>
               <xs:enumeration value="geometry"/>
               <xs:enumeration value="Point"/>
               <xs:enumeration value="Line"/>
               <xs:enumeration value="Polygon"/>
               <xs:enumeration value="Box"/>
               <xs:enumeration value="MultiPoint"/>
               <xs:enumeration value="MultiLine"/>
               <xs:enumeration value="MultiPolygon"/>
               <xs:enumeration value="GeomCollection"/>
            </xs:restriction>
         </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="maxLength" type="xs:nonNegativeInteger"/>
      <xs:attribute name="precision" type="xs:positiveInteger"/>
      <xs:attribute name="scale" type="xs:integer"/>
   </xs:complexType>

   <xs:complexType name="ValueDescriptionTableType">
      <xs:sequence>
         <xs:element name="ValueDescription" type="bxfs:ValueDescriptionType" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>
 
   <xs:complexType name="ValueDescriptionType">
      <xs:sequence>
         <xs:element name="PropertyVal" type="bxfs:PropertyValType"/>
         <xs:element name="Description" type="bxfs:DescriptionType"/>
      </xs:sequence>
   </xs:complexType>

   <!-- ****************************************************************** -->
   <!-- * FEATURE - A feature is a named set of properties and values    * -->
   <!-- *           for some or all of those properties.  The definition * -->
   <!-- *           of the properties is specified be a Definition       * -->
   <!-- *           element.                                             * -->
   <!-- ****************************************************************** -->
   <xs:complexType name="FeatureType">
      <xs:sequence>
         <xs:element name="Description" type="bxfs:DescriptionType" minOccurs="0"/>
         <xs:element name="PropertyVal" type="bxfs:PropertyValType" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute name="fid" type="xs:anyURI" use="required"/>
   </xs:complexType>

   <!-- ****************************************************************** -->
   <!-- * The content of the PropertyVal element is either a text string * -->
   <!-- * representing a STRING, NUMBER, DATE or BOOLEAN, or it is a     * -->
   <!-- * geometry expressed in GML.                                     * -->
   <!-- ****************************************************************** -->
   <xs:complexType name="PropertyValType" mixed="true">
      <xs:complexContent mixed="true">
         <xs:extension base="xs:anyType"/>
      </xs:complexContent>
   </xs:complexType>
</xs:schema>
