<?xml version="1.0" encoding="UTF-8"?>
<!-- BXFS: Basic XML Feature Schema, version 0.0.2 -->
<schema targetNamespace="http://www.opengis.net/bxfs"
        xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        xmlns:bxfs="http://www.opengis.net/bxfs"
        xmlns:gml="http://www.opengis.net/gml"
        elementFormDefault="qualified">

   <import namespace="http://www.w3.org/XML/1998/namespace"/>
   <import namespace="http://www.opengis.net/gml"
           schemaLocation="../../gml/2.1.2/geometry.xsd"/>

   <!--
       Recommended MIME types for BXFS:
         for XML:  application/x-bxfs+xml; version="<bxfsVersion>"
         for BXML: application/x-bxfs+x-bxml; version="<bxfsVersion>"
         (where the version parameter can be omitted if unknown/irrelevant)

       Historical MIME type used:
         text/xml; subtype="bxfs/<bxfsVersion>"
   -->

   <!-- ****************************************************************** -->
   <!-- * FEATURECOLLECTION - A feature collection is a heterogeneous    * -->
   <!-- *                     collection of feature instance sets.       * -->
   <!-- ****************************************************************** -->
   <element name="FeatureCollection">
      <complexType>
         <sequence>
            <element name="Description"
                     type="bxfs:DescriptionType" minOccurs="0"/>
            <element name="FeatureSet"
                     type="bxfs:FeatureSetType" maxOccurs="unbounded"/>
         </sequence>
         <attribute name="version" type="string" use="required" fixed="0.0.2"/>
      </complexType>
   </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.           * -->
   <!-- ****************************************************************** -->
   <complexType name="DescriptionType">
      <sequence>
         <element name="Title" type="bxfs:LangString"
                  minOccurs="0" maxOccurs="unbounded"/>
         <element name="Abstract" type="bxfs:LangString"
                  minOccurs="0" maxOccurs="unbounded"/>
         <element name="MetadataURL" minOccurs="0" maxOccurs="unbounded">
            <complexType>
               <simpleContent>
                  <extension base="anyURI">
                     <attribute name="standard" type="anyURI" use="optional"/>
                  </extension>
               </simpleContent>
            </complexType>
         </element>
         <element name="BoundingBox" type="bxfs:BoundingBoxType"
                  minOccurs="0" maxOccurs="unbounded"/>
      </sequence>
   </complexType>

   <complexType name="LangString">
      <simpleContent>
         <extension base="string">
            <attribute ref="xml:lang" use="optional"/> <!-- see RFC 1766 -->
         </extension>
      </simpleContent>
   </complexType>

   <complexType name="BoundingBoxType">
      <attribute name="srs"  type="string" use="optional"/>
      <attribute name="minx" type="double" use="required"/>
      <attribute name="miny" type="double" use="required"/>
      <attribute name="maxx" type="double" use="required"/>
      <attribute name="maxy" type="double" use="required"/>
   </complexType>

   <!-- ****************************************************************** -->
   <!-- * FEATURESET - A feature set is a homogeneous collection of      * -->
   <!-- *              feature instances.  Homogeneous 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.                        * -->
   <!-- ****************************************************************** -->
   <complexType name="FeatureSetType">
      <sequence>
         <element name="Description"
                  type="bxfs:DescriptionType" minOccurs="0"/>
         <element name="Definition"
                  type="bxfs:DefinitionType"/>
         <element name="Feature"
                  type="bxfs:FeatureType" minOccurs = "0" 
                                          maxOccurs="unbounded"/>
      </sequence>
      <attribute name="name" type="string" use="required"/>
      <attribute name="srsName" type="anyURI" use="optional"/>
   </complexType>

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

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

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

   <!-- ****************************************************************** -->
   <!-- * FEATURE - A feature is a single instance in a feature set.     * -->
   <!-- *           It is a set of property values that positionally     * -->
   <!-- *           match the properties specified by the definition     * -->
   <!-- *           of the feature set.                                  * -->
   <!-- ****************************************************************** -->
   <complexType name="FeatureType">
      <sequence>
         <element name="Description"
                  type="bxfs:DescriptionType" minOccurs="0"/>
         <element name="PropertyVal"
                  type="bxfs:PropertyValType" maxOccurs="unbounded"/>
      </sequence>
      <attribute name="fid" type="anyURI" use="required"/>
   </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.                                     * -->
   <!-- ****************************************************************** -->
   <complexType name="PropertyValType" mixed="true">
      <complexContent mixed="true">
         <extension base="anyType"/>
      </complexContent>
   </complexType>
</schema>

