.. _wfs_schema_mapping:
WFS schema mapping
==================
One of the functions of the GeoServer WFS is to automatically map the internal schema of a dataset to a feature type schema. This mapping is performed according to the following rules:
* The name of the feature element maps to the name of the dataset.
* The name of the feature type maps to the name of the dataset with the string "Type" appended to it.
* The name of each attribute of the dataset maps to the name of an element particle contained in the feature type.
* The type of each attribute of the dataset maps to the appropriate XML schema type (``xsd:int``, ``xsd:double``, and so on).
For example, a dataset has the following schema::
myDataset(intProperty:Integer, stringProperty:String, floatProperty:Float, geometry:Point)
This schema would be mapped to the following XML schema, available via
a ``DescribeFeatureType`` request for the ``topp:myDataset`` type:
.. code-block:: xml
Schema customization
--------------------
The GeoServer WFS supports a limited amount of schema output customization. A custom schema may be useful for the following:
* Limiting the attributes which are exposed in the feature type schema
* :ref:`Changing ` the types of attributes in the schema
* Changing the structure of the schema (for example, changing the base feature type)
For example, it may be useful to limit the exposed attributes in the example dataset described above. Start by retrieving the default output as a benchmark of the complete schema. With the feature type schema listed above, the ``GetFeature`` request would be as follows:
.. code-block:: xml
1
one
1.1
1.0 1.0
To remove ``floatProperty`` from the list of attributes, the following steps would be required:
#. The original schema is modified to remove the ``floatProperty``, resulting in the following type definition:
.. code-block:: xml
#. The modification is saved in a file named ``schema.xsd``.
#. The ``schema.xsd`` file is copied into the feature type directory for the
``topp:myDataset`` which is::
$GEOSERVER_DATA_DIR/workspaces///myDataset/
where ```` is the name of the workspace containing your data store and ```` is the name of the data store which contains ``myDataset``
The modified schema will only be available to GeoServer when the configuration is reloaded or GeoServer is restarted.
A subsequent ``DescribeFeatureType`` request for ``topp:myDataset`` confirms the ``floatProperty`` element is absent:
.. code-block:: xml
A ``GetFeature`` request will now return features that don't include the ``floatProperty`` attribute:
.. code-block:: xml
1
one
1.0 1.0
.. _wfs_schema_type_changing:
Type changing
-------------
Schema customization may be used to perform some **type changing**, although this is limited by the fact that a changed type must be in the same *domain* as the original type. For example, integer types must be changed to integer types, temporal types to temporal types, and so on.
The most common change type requirement is for geometry attributes. In many cases the underlying data set does not have the necessary metadata to report the specific geometry type of a geometry attribute. The automatic schema mapping would result in an element definition similar to the following:
.. code-block:: xml
However if the specific type of the geometry is known, the element definition above could be altered. For point geometry, the element definition could be altered to :
.. code-block:: xml