Web Feature Service Implementation Specification

OpenGIS Consortium Inc.

1.0.0

WARNING: The Open GIS Consortium (OGC) releases this specification to the public without warranty. It is subject to change without notice. This specification is currently under active revision by the OGC Technical Committee.

Requests for clarification and/or revision can be made by contacting the OGC at .

Permission to use, copy, and distribute this document in any medium for any purpose and without fee or royalty is hereby granted, provided that you include the above list of copyright holders and the entire text of this NOTICE.

We request that authorship attribution be provided in any software, documents, or other items or products that you create pursuant to the implementation of the contents of this document, or any portion thereof.

No right to create modifications or derivatives of OGC documents is granted pursuant to this license. However, if additional requirements (as documented in the Copyright FAQ at http://www.opengis.org/legal/ipr_faq.htm) are satisfied, the right to create modifications or derivatives is sometimes granted by the OGC to individuals complying with those requirements.

THIS DOCUMENT IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.

COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.

The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to this document or its contents without specific, written prior permission. Title to copyright in this document will at all times remain with copyright holders.

RESTRICTED RIGHTS LEGEND. Use, duplication, or disclosure by government is subject to restrictions as set forth in subdivision (c)(1)(ii) of the Right in Technical Data and Computer Software Clause at DFARS 252.227.7013

OpenGIS® is a trademark or registered trademark of Open GIS Consortium, Inc. in the United States and in other countries.

This document does not represent a commitment to implement any portion of this specification in any company's products.

OGC® Legal, IPR and Copyright Statements are found at http://www.opengis.org/legal/ipr.htm

The companies listed below have granted the Open GIS Consortium, Inc. (OGC) a nonexclusive, royalty-free, paid up, worldwide license to copy and distribute this document and to modify this document and distribute copies of the modified version.

Revision History
Revision 1.0.02002-09-19
Address RFC comments.
Revision 0.0.14?
Reformat document in ISO format; Relate document to OGC abstract specification (specifically Topic 12 / 19119); Include rules for property naming; Use XPath expressions for referencing properties in complex attributes; More synchronization between WMS and WFS with respect to keyword-value pair encoding; Add annex for conformance testing.
Revision 0.0.13?
Prepare document for RFC submission; include XML-Schema encoding of WFS interfaces; align URL-encoding with BSM
Revision 0.0.12?
Add complete list of contributors; align with latest GML 2.0 draft specification; add lock controls and versioning.
Revision 0.0.11?
Correct typographical errors.
Revision 0.0.10?
Server FeatureId and Filter elements into their own specification documents.
Revision 0.0.9?
Review U.S.Census revisions
Revision 0.0.8?
Review Galdos revisions
Revision 0.0.7?
Review LaserScan revisions
Revision 0.0.6?
Remove "Small XML-Schema Description Language"
Revision 0.0.5?
Define "Small XML-Schema Description Language"
Revision 0.0.4?
Use GML2 with application defined schema using XML-Schema. Remove dependency on featureType attribute.
Revision 0.0.3?
Define GET request semantics.
Revision 0.0.2?
Update <FeatureId> element to include <Scope>. Make handle attribute #IMPLIED. Add functions on properties and literals to <Filter>.
Revision 0.0.1?
First version derived from the OpenGIS Transaction Encoding Specification [3] and the Spatial Object Transfer Format (SOTF) [4] specification.

Table of Contents

1. Preface
2. Submitting organizations
3. Submission contact points
4. Changes to the OpenGIS Abstract Specification
5. Future work
6. Forward
7. Introduction
8. Scope
8.1. Geographic features
8.2. Processing requests
8.3. Operations
9. Conformance
10. Normative references
11. Terms and definitions
12. Conventions
12.1. Normative verbs
12.2. Abbreviated terms
12.3. Use of examples
13. Basic service elements
13.1. Introduction
13.2. Version numbering and negotiation
13.2.1. Version number form
13.2.2. Version changes
13.2.3. Appearance in requests and in service metadata
13.3. General HTTP request rules
13.3.1. Introduction
13.3.2. HTTP GET
13.3.3. HTTP POST
13.4. General HTTP response rules
13.5. Request encoding
13.6. Namespaces
14. Common elements
14.1. Feature identifier
14.1.1. Globally unique identifiers (Informative)
14.2. Feature state
14.3. Property names
14.4. Property references
14.4.1. Introduction
14.4.2. Xpath expressions
14.5. <Native> element
14.6. Filter
14.7. Exception reporting
14.8. Common XML attributes
14.8.1. Version attribute
14.8.2. Service attribute
14.8.3. Handle attribute
15. DescribeFeatureType operation
15.1. Introduction
15.2. Request
15.3. Response
15.3.1. Supporting multiple namespaces
15.4. Exception
15.5. Examples
16. GetFeature Operation
16.1. Introduction
16.2. Request
16.3. Response
16.4. Exception
16.5. Examples
17. LockFeature operation
17.1. Introduction
17.2. Request
17.2.1. Schema definition
17.2.2. State machine notation from UML
17.2.3. State machine for WFS locking
17.3. Response
17.4. Exception
17.5. Examples
18. Transaction operation
18.1. Introduction
18.2. Request
18.2.1. Schema definition
18.2.2. Attribute descriptions
18.2.3. <Transaction> element
18.2.4. <Insert> element
18.2.5. <Update> element
18.2.6. <Delete> element
18.3. Response
18.4. Exception
18.5. Examples
19. GetCapabilities
19.1. Introduction
19.2. Request
19.3. Response
19.3.1. Response schema
19.3.2. Capabilities
19.3.3. Service section
19.3.4. Capabilities Section
19.3.5. FeatureTypeList section
19.4. Exception
19.5. Examples
20. Keyword-value pair encoding
20.1. Introduction
20.1.1. A note about the examples
20.2. Request parameter rules
20.2.1. Parameter ordering and case
20.2.2. Parameter lists
20.3. Common request parameters
20.3.1. Version parameter
20.3.2. Request parameter
20.3.3. Bounding box
20.3.4. Vendor-specific parameters
20.4. Common parameters
20.5. Response
20.6. Exceptions
20.7. Operations
20.7.1. Introduction
20.7.2. DescribeFeatureType operation
20.7.2.1. Request
20.7.2.2. Examples
20.7.3. GetFeature & GetFeatureWithLock operation
20.7.3.1. Request
20.7.3.2. Examples
20.7.4. LockFeature operation
20.7.4.1. Request
20.7.4.2. Examples
20.7.5. Transaction
20.7.5.1. Request
20.7.5.2. Examples
20.7.6. GetCapabilities Operation
20.7.6.1. Request
20.7.6.2. Response
21. XML Schema definitions (Normative)
21.1. Introduction
21.2. OGC-exception.xsd
21.3. WFS-basic.xsd
21.4. WFS-transaction.xsd
21.5. WFS-capabilities.xsd
22. Conformance tests (normative)
Glossary
Bibliography

One important achievement of the Open GIS Consortium (OGC) Web Mapping Test bed (WMT1) initiative was the development of a large consensus around open web based interface specifications. Such specifications allow software vendors to implement their products using interoperable interfaces and provide end-users a larger pool of interoperable web based tools for geodata access and related geoprocessing services.

During the OGC WMT1 project, two web based draft specification documents were developed:

The first document specifies web interfaces based on a model supporting general request and response rules using Hypertext Transfer Protocol (HTTP) and the eXtensible Markup Language (XML). Web Map Server products have been developed as the result of the adoption by OGC of the OpenGIS Web Map Service Implementation Specification [1]. The interfaces defined in that specification include GetCapabilities, GetMap and GetFeatureInfo. The second document describes an encoding specification for geodata in XML. The encoding described in that specification is intended to enable the transport and storage of geographic information in XML including both properties and the geometry of geographic features.

This document (OpenGIS Web Feature Service Implementation Specification) takes the next logical step and proposes interfaces for describing data manipulation operations on geographic features using HTTP as the distributed computing platform. Data manipulation operations include the ability to:

A Web Feature Service (WFS) request consists of a description of query or data transformation operations that are to be applied to one or more features. The request is generated on the client and is posted to a web feature server using HTTP. The web feature server then reads and (in a sense) executes the request.

The following companies submitted this specification to the OGC as a Request for Comment:

CubeWerx Inc. Edric Keighan 200 Rue Montcalm, Suite R-13 Hull, Quebec Canada J8Y 3B5 Intergraph Corp. Jonathan Clark 1881 Campus Commons Drive Reston, VA 20191 U.S.A IONIC Software Serge Margoulies 128 Avenue de l'Observatoire B-4000 LIEGE Belgium Laser-Scan Ltd. Peter Woodsford 101 Cambridgbe Science Park Milton Road Cambridge CB4 0FY U.K.

All questions regarding this submission should be directed to the Editor or to the WWW Mapping SIG chair:

Panagiotis A. Vretanos CubeWerx, Inc. 200 Rue Montcalm, Suite R-13 Hull, Quebec J8Y 3B5 CANADA +1 416 701 1985

Allan Doyle (WWW Mapping SIG Chair) International Interfaces, Inc. 948 Great Plain Ave. PMB-182 Needham, MA 02492 USA +1 781 433 2695

Additional contributors

Rob Atkinson (Social Change Online) Craig Bruce (CubeWerx) Jonathan Clark (Intergraph) Adrian Cuthbert (SpotOn MOBILE) Paul Daisey (U.S. Census) John Davidson John D. Evans (NASA) Ron Fresne (ObjectFX) Ignacio Guerrero (Intergraph) John Herring (Oracle Corp.) Sandra Johnson (Mapinfo) Edric Keighan (CubeWerx) Ron Lake (Galdos Systems Inc.) Jeff Lansing (Polexis) Seb Lessware (Laser-Scan Ltd.) Marwa Mabrouk (ESRI) Serge Margoulies (Ionic) Brian May (CubeWerx) Richard Martell (Galdos Systems Inc.) Aleksander Milanovic (Glados Systems Inc.) Dimitri Monie (Ionic) Paul Pilkington (Laser-Scan Ltd.) Keith Pomakis (CubeWerx) Christopher C. Pried (Polexis) Lou Reich (NASA) Carl Reed (Open GIS Consortium) Martin Schaefer (Cadcorp Ltd.) Lacey T. Sharpe (Intergraph Corp.) Raj R. Singh (Syncline Inc.) Bernard Snyers (Ionic) Daniel Specht (TEC) James T. Stephens (Lockheed Martin) Glenn Stowe (CubeWerx) Tom Strickland (Byers) Shuichi Takino (Dawn Corp.) Milan Trninic (Galdos Systems Inc.) John T. Vincent (Intergraph Corp.) Peter Woodsford (Laser-Scan Ltd.) Arliss Whitesize (BAE Systems) Nami Yamashita (Dawn Corp.)

This document describes the OGC Web Feature Service (WFS) operations. The WFS operations support INSERT, UPDATE, DELETE, QUERY and DISCOVERY operations on geographic features using HTTP as the distributed computing platform.

In the context of this document, a transaction is a logical unit of work that is composed of one or more data manipulation operations. Since the manner in which geographic features are persistently stored is not addressed in this document, no transaction semantics, such as atomic failure, are assumed to exist. It is the function of a web feature service, in its interaction with the data storage system used to persistently store features, to ensure that changes to data are consistent. However, the document also acknowledges the fact that many systems do support standard concurrent transaction semantics and so proposes optional operations that will allow a web feature service to take advantage of such systems (e.g. relational database systems based on SQL).

This document adopts the same concept of a geographic feature as described in the OGC Abstract Specification (http://www.opengis.org/techno/spec.htm) and interpreted in the OpenGIS© Geographic Markup Language(GML) Implementation Specification [2]. That is to say that the state of a geographic feature is described by a set of properties where each property can be thought of as a {name, type, value} tuple. The name and type of each feature property is determined by its type definition. Geographic features are those that may have at least one property that is geometry-valued. This, of course, implies that features can be defined with no geometric properties at all. The geometries of geographic features are restricted to what OGC calls simple geometries. A simple geometry is one for which coordinates are defined in two dimensions and the delineation of a curve is subject to linear interpolation. The traditional 0, 1 and 2-dimensional geometries defined in a 2-dimensional spatial reference system are represented by points, line strings and polygons. In addition, the OGC geometry model allows for geometries that are collections of other geometries - either homogeneous multi-point, multi-line string, and multi-polygon collections or heterogeneous geometry collections. Finally, GML allows features that have complex or aggregate non-geometric properties.

To support transaction and query processing, the following operations are defined:

Based on the operation descriptions above, two classes of web feature services can be defined:

Figure 2 is a simplified protocol diagram illustrating the messages that might be passed back and forth between a client application and a web feature service in order to process a typical transaction request. The elements referenced in the diagram are defined in this document.

  1. Bradner, Scott, "RFC 2119 Key words for use in RFCs to Indicate Requirement Levels," March 1997, ftp://ftp.isi.edu/in-notes/rfc2119.txt.

  2. Cox, S., Cuthbert, A., Lake, R., and Martell, R. (eds.), "OpenGIS Implementation Specification #02-009: OpenGIS© Geography Markup Language (GML) Implementation Specification, version 2.1.1", April 2002

  3. Vretanos, Panagiotis (ed.), "OpenGIS Implementation Specification #01-067: Filter Encoding Implementation Specification", May 2001

  4. Percivall, George, ed., “The OpenGIS Abstract Specification, Topic 12: OpenGIS Service Architecture”, 2002

  5. Bray, Paoli, Sperberg-McQueen, eds., "Extensible Markup Language (XML) 1.0", 2nd edition, October 2000, W3C Recommendation, http://www.w3.org/TR/2000/REC-xml.

  6. Beech, David, Maloney, Murry, Mendelson, Noah, Thompson, Harry S., “XML Schema Part 1: Structures”, May 2001, W3C Recommendation, http://www.w3c.org/TR/xmlschema-1.

  7. Bray, Hollander, Layman, eds., “Namespaces In XML”, January 1999, W3C Recommendation, http://www.w3.org/TR/2000/REC-xml-names.

  8. Clark, James, DeRose, Steve, “XML Path Language (XPATH), Version 1.0”, November 1999, W3C Recommendation, http://www.w3c.org/TR/XPath.

  9. Fielding et. al., "Hypertext Transfer Protocol – HTTP/1.1," IETF RFC 2616, June 1999, http://www.ietf.org/rfc/rfc2616.txt.

  10. Berners-Lee, T., Fielding, N., and Masinter, L., "Uniform Resource Identifiers (URI): Generic Syntax", IETF RFC 2396, http://www.ietf.org/rfc/rfc2396.txt.

  11. National Center for Supercomputing Applications, "The Common Gateway Interface," http://hoohoo.ncsa.uiuc.edu/cgi/.

  12. Freed, N. and Borenstein N., "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", IETF RFC 2045, November 1996, http://www.ietf.org/rfc/rfc2045.txt.

  13. Internet Assigned Numbers Authority, http://www.isi.edu/in-notes/iana/assignments/media-types/.

An OWS Client may negotiate with a Service Instance to determine a mutually agreeable specification version. Negotiation is performed using the GetCapabilities operation [sec. 12] according to the following rules.

All Capabilities XML must include a protocol version number. In response to a GetCapabilities request containing a version number, an OGC Web Service must either respond with output that conforms to that version of the specification, or negotiate a mutually agreeable version if the requested version is not implemented on the server. If no version number is specified in the request, the server must respond with the highest version it understands and label the response accordingly.

Version number negotiation occurs as follows:

The process is repeated until a mutually understood version is reached, or until the client determines that it will not or cannot communicate with that particular server.

An Online Resource URL intended for HTTP GET requests, is, in fact, only a URL prefix to which additional parameters must be appended in order to construct a valid Operation request. A URL prefix is defined as an opaque string including the protocol, hostname, optional port number, path, a question mark '?', and, optionally, one or more server-specific parameters ending in an ampersand '&'. The prefix uniquely identifies the particular service instance. A client appends the necessary request parameters as name/value pairs in the form "name=value&". The resulting URL must be valid according to the HTTP Common Gateway Interface (CGI) standard [7], which mandates the presence of '?' before the sequence of query parameters and the '&' between each parameter. As with all CGI applications, the query URL is encoded [10] to protect special characters.

The URL prefix must end in either a '?' (in the absence of additional server-specific parameters) or a '&'. In practice, however, Clients should be prepared to add a necessary trailing '?' or '&' before appending the Operation parameters defined in this specification in order to construct a valid request URL.

Table 1 summarizes the components of an operation request URL.

This document assumes that every feature instance that a particular WFS implementation can operate upon is uniquely identifiable. That is to say, when a WFS implementation reports a feature identifier for a feature instance, that feature identifier is unique to the server and can be used to repeatedly reference the same feature instance (assuming it has not been deleted). It is further assumed that a feature identifier is encoded as described in the OpenGIS© Filter Encoding Implementation Specification [3]. A feature identifier can be used wherever a feature reference is required. For reference purposes, the XML Schema fragment that defines the feature identifier element is copied from the filter encoding specification:

<xsd:element name="FeatureId" type="ogc:FeatureIdType"/>
<xsd:complexType name="FeatureIdType">
   <xsd:attribute name="fid" type="xsd:anyURI" use="required"/>
</xsd:complexType>

The purpose of the feature identifier is to make database operations possible.

For the purposes of a web feature service, a locally unique identifier is sufficient. However, there is a need within OGC web services to have unique identifiers for objects of all kinds. The approach thus far has been to reference objects using independent scope and feature-id components, where the scope it the URL of the server serving a feature and the feature-id is the local identifier for the feature. This approach, however, may be awkward to transport and use in other contexts, such as in a registry if one wanted to create metadata for a single repository data instance (such as a satellite image).

The purpose of this section of the specification is to point out that a single globally-unique string would be more convenient to use in multiple contexts, and that such a string may be generated by a web feature service using some combination of the URL of the service and the local identifier.

This string could be used as if it were fully opaque in many contexts, but it would be more useful if it were actually a URL or URN which could be used to directly access the object it identifies in the native format of the object. The encoding of the URL or URN would be entirely implementation-specific. One note on the use of URNs: not many implementations will actually be able to resolve and fetch data objects; it may be mostly only usable as a unique identifier string.

Using a URL or URN is helpful for applications that need only simple access to the raw objects since no interface details need to be known. This mode of access/identification is also helpful for integration with high-level XML technologies such as RDF or XSLT, and even for debugging purposes.

The XML Path Language [8] specification is a language for addressing parts of a XML document, or in the case of this specification, for referencing feature properties referred to by means of XML elements or attributes.

This specification does not require a WFS implementation to support the full XPath language. In order to keep the implementation entry cost as low as possible, this specification mandates that a WFS implementation must support the following subset of the XPath language:

Example 4. Example

To practically illustrate the use of XPath expressions for referencing the properties of a complex feature (encoded as elements or attributes), consider the fictitious complex feature Person defined by the following XML Schema document:

<?xml version="1.0" ?>
<schema
   targetNamespace="http://www.someserver.com/myns"
   xmlns:myns="http://www.someserver.com/myns"
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns="http://www.w3.org/2001/XMLSchema"
   elementFormDefault="qualified"
   version="1.0">

   <import namespace="http://www.opengis.net/gml"
           schemaLocation="../gml/2.1/feature.xsd"/>

   <element name="Person" type="myns:PersonType"
            substitutionGroup="gml:_Feature"/>
   <complexType name="PersonType">
      <complexContent>
         <extension base="gml:AbstractFeatureType">
            <sequence>
               <element name="LastName" nillable="true">
                  <simpleType>
                     <restriction base="string">
                        <maxLength value="30"/>
                     </restriction>
                  </simpleType>
               </element>
               <element name="FirstName" nillable="true">
                  <simpleType>
                     <restriction base="string">
                        <maxLength value="10"/>
                     </restriction>
                  </simpleType>
               </element>
               <element name="Age" type="integer" nillable="true"/>
               <element name="Sex" type="string"/>
               <element name="Spouse">
                  <complexType>
                     <attribute name="sin" type="xsd:anyURI" use="required" />
                  </complexType>
               </element>
               <element name="Location" 
                        type="gml:PointPropertyType"
                        nillable="true"/>
               <element name="Address" type="myns:AddressType" nillable="true"/>
               <element name="Phone" type="xsd:string"
                        minOccurs="0" maxOccurs="unbounded"/>
            </sequence>
            <attribute name="sin" type="xsd:anyURI" use="required"/>
         </extension>
      </complexContent>
   </complexType>

   <complexType name="AddressType">
      <sequence>
         <element name="StreetName" nillable="true">
            <simpleType>
               <restriction base="string">
                  <maxLength value="30"/>
               </restriction>
            </simpleType>
         </element>
         <element name="StreetNumber" nillable="true">
            <simpleType>
               <restriction base="string">
                  <maxLength value="10"/>
               </restriction>
            </simpleType>
         </element>
         <element name="City" nillable="true">
            <simpleType>
               <restriction base="string">
                  <maxLength value="30"/>
               </restriction>
            </simpleType>
         </element>
         <element name="Province" nillable="true">
            <simpleType>
               <restriction base="string">
                  <maxLength value="30"/>
               </restriction>
            </simpleType>
         </element>
         <element name="PostalCode" nillable="true">
            <simpleType>
               <restriction base="string">
                  <maxLength value="15"/>
               </restriction>
            </simpleType>
         </element>
         <element name="Country" nillable="true">
            <simpleType>
               <restriction base="string">
                  <maxLength value="30"/>
               </restriction>
            </simpleType>
         </element>
      </sequence>
   </complexType>
</schema>

Note that the property Address is a complex property of type AddressType. An example instance of the feature Person might be:

<?xml version="1.0" ?>
<myns:Person
   sin="111222333" 
   xmlns:myns="http://www.opengis.net/myns"
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.opengis.net/myns Person.xsd">

   <myns:LastName>Smith</myns:LastName>
   <myns:FirstName>Fred</myns:FirstName>
   <myns:Age>35</myns:Age>
   <myns:Sex>Male</myns:Sex>
   <myns:Spouse sin="444555666" />
   <myns:Location>
      <gml:Point><gml:coordinates>15,15</gml:coordinates></gml:Point>
   </myns:Location>
   <myns:Address>
      <myns:StreetName>Main St.</myns:StreetName>
      <myns:StreetNumber>5</myns:StreetNumber>
      <myns:City>SomeCity</myns:City>
      <myns:Province>SomeProvince</myns:Province>
      <myns:PostalCode>X1X 1X1</myns:PostalCode>
      <myns:Country>Canada</myns:Country>
   </myns:Address>
   <myns:Phone>416-123-4567</myns:Phone>
   <myns:Phone>416-890-1234</myns:Phone>
</myns:Person>

Using XPath [8] expressions, each property of a Person feature can be referenced as follows (omitting the namespace qualifiers for clarities sake):

LastName
FirstName
Age
Sex
Source
Location
Address
Address/StreetNumber
Address/StreetName
Address/City
Address/Province
Address/Postal_Code
Address/Country
Phone[1]
Phone[2]

Notice that in this instance, each relative location path begins with the root element of the feature property being referenced. This simply corresponds to the name of the feature property. Optionally, each feature property may be referenced with the relative location path beginning with root element of the feature (i.e. the name of the feature type). Thus the LastName property could be reference as Person/LastName, the City property could be referenced as Person/Address/City and so on.

Each step of the path is composed of the abbreviated child:: axis specifier (i.e. the axis specifier child:: is omitted) and the name of the specified property which is of node type element.

The element Phone appears multiple times and the predicates [1] and [2] are used to indicate the specific elements. The predicate [1] is used to indicate the first occurrence of the Phone element. The predicate [2] is used to indicate the second occurrence of the Phone element.

In addition, the sin [1] attribute on the <Person> and <Spouse> elements can be referenced using the following XPath [8] expressions:

Person/@sin
Person/Spouse/@sin

In these cases the final step of the path contains the abbreviated axis specifier attribute:: (i.e. @) and the node type is attribute (i.e. sin in this case).

It is clear that an open interface can only support a certain common set of capabilities. The <Native> element is intended to allow access to vendor specific capabilities of any particular web feature server or datastore.

The <Native> element is defined by the following XML Schema fragment:

<xsd:element name="Native" type="wfs:NativeType"/>
<xsd:complexType name="NativeType">
   <xsd:any />
   <xsd:attribute name="vendorId" type="xsd:string" use="required"/>
   <xsd:attribute name="safeToIgnore" type="xsd:boolean" use="required"/>
</xsd:complexType>

The <Native> element simply contains the vendor specific command or operation.

The vendorId attribute is used to identify the vendor that recognizes the command or operation enclosed by the <Native> element. The attribute is provided as a means of allowing a web feature service to determine if it can deal with the command or not.

The safeToIgnore attribute is used to guide the actions of a web feature service when the <Native> command or operation is not recognized. The safeToIgnore attribute has two possible values True or False. The values have the following meanings:

safeToIgnore=False

A value of False indicates that the <Native> element cannot be ignored and the operation that the element is associated with must fail if the web feature service cannot deal with it.

safeToIgnore=True

A value of True indicates that the <Native> element can be safely ignored.

In the event that a web feature service encounters an error while processing a request or receives an unrecognized request, it shall generate an XML document indicating that an error has occurred. The format of the XML error response is specified by, and must validate against, the exception response schema defined in section A.2.

A <ServiceExceptionReport> element can contain one or more WFS processing exceptions. The mandatory version attribute is used to indicate the version of the service exception report schema. For this version of the specification, this value is fixed at 1.2.0.

Individual exception messages are contained within the <ServiceException> element. The optional code attribute may be used to associate an exception code with the accompanying message. The optional locator attribute may be used to indicate where an exception was encountered in the request that generated the error. A number of elements defined in this document include a handle attribute that can be used to associate a mnemonic name with the element. If such a handle exists, its value may be reported using the locator attribute of the <ServiceException> element. If the handle attribute is not specified, then a web feature server implementation may attempt to locate the error using other means such as line numbers, etc...

A DescribeFeatureType element contains zero or more TypeName elements that encode the names of feature types that are to be described. If the content of the DescribeFeatureType element is empty, then that shall be interpreted as requesting a description of all feature types that a WFS can service. The XML encoding of a DescribeFeatureType request is defined by the following XML Schema fragment:

   <xsd:element name="DescribeFeatureType" type="wfs:DescribeFeatureTypeType"/>
   <xsd:complexType name="DescribeFeatureTypeType">
      <xsd:sequence>
         <xsd:element name="TypeName" type="xsd:QName"
                      minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="version"
                     type="xsd:string" use="required" fixed="1.0.0"/>
      <xsd:attribute name="service"
                     type="xsd:string" use="required" fixed="WFS"/>
      <xsd:attribute name="outputFormat"
                     type="xsd:string" use="optional" default="XMLSCHEMA"/>
   </xsd:complexType>

The outputFormat attribute, is used to indicate the schema description language that should be used to describe feature type schemas. The only mandatory output format in response to a DescribeFeatureType operation is XML Schema, denoted by the value XMLSCHEMA for the outputFormat attribute. Other vendor specific formats are also possible, but they must be advertised on the capabilities document [sec. 12].

As specified by GML [2], the feature schema definition is entirely at the discretion of the particular WFS implementation that is describing its feature types. The only caveats are:

In response to a DescribeFeatureType request, where the value of the outputFormat attribute has been set to XMLSCHEMA, a WFS implementation must be able to present an XML Schema [6] document that is a valid GML [2] application schema and defines the schema of the feature types listed in the request. The document(s) presented by the DescribeFeatureType request may be used to validate feature instances generated by the WFS in the form of feature collections on output or feature instances specified as input for transaction operations.

Schema descriptions using other schema description languages, such as DTD, are also possible as long as such capabilities are declared in the capabilities document [sec. 12].

An XML Schema[6] document can only describe elements that belong to a single namespace. This means that a Web Feature Service cannot describe features from multiple namespaces in a single XML Schema document. To overcome this limitation, a WFS may generate an XML Schema document that is a “wrapper” schema that imports the schemas of the features from the various namespaces in the request. For example, consider the following request:

<?xml version="1.0" ?>
<DescribeFeatureType
   version="1.0.0"
   service="WFS"
   xmlns="http://www.opengis.net/wfs"
   xmlns:ns01="http://www.server01.com/ns01"
   xmlns:ns02="http://www.server02.com/ns02"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.0.0/WFS-basic.xsd">
   <TypeName>ns01:TREESA_1M</TypeName>
   <TypeName>ns02:ROADL_1M</TypeName>
</DescribeFeatureType>

A WFS may generate the following response to this request:

<?xml version="1.0" ?>
<schema
   xmlns="http://www.w3.org/2001/XMLSchema"
   elementFormDefault="qualified"
   attributeFormDefault="unqualified">

   <import namespace="http://www.server01.com/ns01"
           schemaLocation="http://www.myserver.com/wfs.cgi?
                           request=DescribeFeatureType&amp;typeName=ns01:TREESA_1M"/>

   <import namespace="http://www.server02.com/ns02"
           schemaLocation="http://www.yourserver.com/wfs.cgi?
                           request=DescribeFeatureType&amp;typeName=ns02:ROADL_1M"/>

</schema>

In this example, the WFS is using a DescribeFeatureType request to obtain the schemas of the features in the various namespaces. This is simply an example, other methods of obtaining the schemas may be implemented (for example: referencing static schema documents).

Example 7. Example 1

Consider geographic features of types TREESA_1M and ROADL_1M that are defined in a SQL database. The description of these feature types is reported by the database to be:

SQL> describe TREESA_1M
Name                   Null?    Type
---------------------- -------- -------------
WKB_GEOM               NOT NULL  LONG RAW
ID                               NUMBER(10)
TREE_TYPE                        VARCHAR2(80)

SQL> describe ROADL_1M
Name                      Null?    Type
------------------------- -------- ------------
WKB_GEOM                  NOT NULL LONG RAW
DESIGNATION                        VARCHAR2(30)
SURFACE_TYPE                       VARCHAR2(30)
NLANES                             NUMBER(2)

In response to the DescribeFeatureType request:

<?xml version="1.0" ?>
<DescribeFeatureType
   version="1.0.0"
   service="WFS"
   xmlns="http://www.opengis.net/wfs"
   xmlns:myns="http://www.myserver.com/myns"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.0.0/WFS-basic.xsd">
   <TypeName>myns:TREESA_1M</TypeName>
   <TypeName>myns:ROADL_1M</TypeName>
</DescribeFeatureType>

a web feature service may generate the following XML Schema document:

<?xml version="1.0" ?>
<schema
   targetNamespace="http://www.someserver.com/myns"
   xmlns:myns="http://www.someserver.com/myns"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns="http://www.w3.org/2001/XMLSchema"
   xmlns:gml="http://www.opengis.net/gml"
   elementFormDefault="qualified" version="0.1">

   <import namespace="http://www.opengis.net/gml"
           schemaLocation="../gml/2.1/feature.xsd"/>

   <!-- =============================================
        define global elements
        ============================================= -->
   <element name="TREESA_1M"
            type="myns:TREESA_1M_Type"
            substitutionGroup="gml:_Feature"/>

   <element name="ROADL_1M"
            type="myns:ROADL_1M_Type"
            substitutionGroup="gml:_Feature"/>

   <!-- ============================================
        define complex types (classes)
        ============================================ -->
   <complexType name="TREESA_1M_Type">
      <complexContent>
         <extension base="gml:AbstractFeatureType">
            <sequence>
               <element name="WKB_GEOM"
                        type="gml:PolygonPropertyType" nillable="false"/>
               <element name="ID" nillable="true" minOccurs="0">
                  <simpleType>
                     <restriction base="integer">
                        <totalDigits value="10"/>
                     </restriction>
                  </simpleType>
               </element>
               <element name="TREE_TYPE" nillable="true" minOccurs="0">
                  <simpleType>
                     <restriction base="string">
                        <maxLength value="80"/>
                     </restriction>
                  </simpleType>
               </element>
            </sequence>
         </extension>
      </complexContent>
   </complexType>

   <complexType name="ROADL_1M_Type">
      <complexContent>
         <extension base="gml:AbstractFeatureType">
            <sequence>
               <element name="WKB_GEOM"
                        type="gml:LineStringPropertyType"
                        nillable="false"/>
               <element name="DESIGNATION" nillable="true" minOccurs="0">
                  <simpleType>
                     <restriction base="string">

                        <maxLength value="30"/>
                     </restriction>
                  </simpleType>
               </element>
               <element name="SURFACE_TYPE" nillable="true" minOccurs="0">
                  <simpleType>
                     <restriction base="string">
                        <maxLength value="30"/>
                     </restriction>
                  </simpleType>
               </element>
               <element name="NLANES" nillable="true" minOccurs="0">
                  <simpleType>
                     <restriction base="integer">
                        <totalDigits value="2"/>
                     </restriction>
                  </simpleType>
               </element>
            </sequence>
         </extension>
      </complexContent>
   </complexType>
</schema>

Using this schema description, a client could then express the state of a TREESA_1M feature instance and/or a ROADL_1M feature instance as shown in the following example:

<?xml version="1.0" ?>
<wfs:FeatureCollection
   xmlns="http://www.someserver.com/myns"
   xmlns:myns="http://www.someserver.com/myns"
   xmlns:wfs="http://www.opengis.net/wfs"
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.0.0/WFS-basic.xsd
                       http://www.someserver.com/myns ex07.xsd">
   <gml:boundedBy>
      <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
         <gml:coordinates>-180.0,-90.0 180.0,90.0</gml:coordinates>
      </gml:Box>
   </gml:boundedBy>
   <gml:featureMember>
      <TREESA_1M>
         <WKB_GEOM>
            <gml:Polygon>
               <gml:outerBoundaryIs>
                  <gml:LinearRing>
                     <gml:coordinates decimal="." cs="," ts=" ">-120.000000,65.588264
 -120.003571,65.590782 -120.011292,65.590965 -120.022491,65.595215 -120.031212,65.592880
 -120.019363,65.586121 -120.030350,65.585365 -120.045082,65.581848 -120.059540,65.584938
 -120.067284,65.590500 -120.067284,65.595436 -120.067337,65.613441 -120.067337,65.613777
 -120.060997,65.606346 -120.045517,65.605545 -120.022675,65.599777 -120.003975,65.601036
 -120.000000,65.602081 -120.000000,65.602081 -120.000000,65.588264</gml:coordinates>
                  </gml:LinearRing>
               </gml:outerBoundaryIs>
            </gml:Polygon>
         </WKB_GEOM>
         <ID>0000000002</ID>
         <TREE_TYPE>Maple</TREE_TYPE>
      </TREESA_1M>
   </gml:featureMember>
   <gml:featureMember>
      <ROADL_1M>
         <WKB_GEOM>
            <gml:LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
               <gml:coordinates decimal="." cs="," ts=" ">-59.478340,-52.226578
 -59.484871,-52.223564 -59.488991,-52.198524 -59.485958,-52.169559 -59.480400,-52.152615
 -59.465576,-52.141491 -59.462002,-52.136417 -59.447968,-52.127190 -59.422928,-52.120701
 -59.411915,-52.117844 -59.397972,-52.116440 -59.371311,-52.121300</gml:coordinates>
            </gml:LineString>
         </WKB_GEOM>
         <DESIGNATION>HYW 401</DESIGNATION>
         <SURFACE_TYPE>ASPHALT</SURFACE_TYPE>
         <NLANES>12</NLANES>
      </ROADL_1M>
   </gml:featureMember>
</wfs:FeatureCollection>

Example 8. Example 2

This example describes a collection type, People, composed of feature instances of the feature type Person, that includes a complex property Address.

In response to the DescribeFeatureType request:

<?xml version="1.0" ?>
<DescribeFeatureType
   version="1.0.0"
   service="WFS"
   outputFormat="XMLSCHEMA"
   xmlns="http://www.opengis.net/wfs"
   xmlns:myns="http://www.myserver.com/myns"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.0.0/WFS-basic.xsd">
   <TypeName>myns:People</TypeName>
</DescribeFeatureType>

a web feature service might generate an XML Schema document that looks like:

<?xml version="1.0" ?>
<xsd:schema
   targetNamespace="http://www.someserver.com/myns"
   xmlns:myns="http://www.someserver.com/myns"
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns="http://www.w3.org/2001/XMLSchema"
   elementFormDefault="qualified" version="0.1">

   <xsd:import namespace="http://www.opengis.net/gml"
               schemaLocation="../gml/2.1/feature.xsd"/>

   <xsd:element name="Person"
                type="myns:PersonType"
                substitutionGroup="gml:_Feature"/>

   <xsd:complexType name="PersonType">
      <xsd:complexContent>
         <xsd:extension base="gml:AbstractFeatureType">
            <xsd:sequence>
               <xsd:element name="LastName" nillable="true">
                  <xsd:simpleType>
                     <xsd:restriction base="string">
                        <xsd:maxLength value="30"/>
                     </xsd:restriction>
                  </xsd:simpleType>
               </xsd:element>
               <xsd:element name="FirstName" nillable="true">
                  <xsd:simpleType>
                     <xsd:restriction base="string">
                        <xsd:maxLength value="10"/>
                     </xsd:restriction>
                  </xsd:simpleType>
               </xsd:element>
               <xsd:element name="Age"
                            type="integer"
                            nillable="true"/>
               <xsd:element name="Sex"
                            type="string"/>
               <xsd:element name="Location"
                            type="gml:PointPropertyType"
                            nillable="true"/>
               <xsd:element name="Address"
                            type="myns:AddressType"
                            nillable="true"/>
            </xsd:sequence>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>

   <xsd:complexType name="AddressType">
      <xsd:sequence>
         <xsd:element name="StreetName" nillable="true">
            <xsd:simpleType>
               <xsd:restriction base="string">
                  <xsd:maxLength value="30"/>
               </xsd:restriction>
            </xsd:simpleType>
         </xsd:element>
         <xsd:element name="StreetNumber" nillable="true">
            <xsd:simpleType>
               <xsd:restriction base="string">
                  <xsd:maxLength value="10"/>
               </xsd:restriction>
            </xsd:simpleType>
         </xsd:element>
         <xsd:element name="City" nillable="true">
            <xsd:simpleType>
               <xsd:restriction base="string">
                  <xsd:maxLength value="30"/>
               </xsd:restriction>
            </xsd:simpleType>
         </xsd:element>
         <xsd:element name="Province" nillable="true">
            <xsd:simpleType>
               <xsd:restriction base="string">
                  <xsd:maxLength value="30"/>
               </xsd:restriction>
            </xsd:simpleType>
         </xsd:element>
         <xsd:element name="PostalCode" nillable="true">
            <xsd:simpleType>
               <xsd:restriction base="string">
                  <xsd:maxLength value="15"/>
               </xsd:restriction>
            </xsd:simpleType>
         </xsd:element>
         <xsd:element name="Country" nillable="true">
            <xsd:simpleType>
               <xsd:restriction base="string">
                  <xsd:maxLength value="30"/>
               </xsd:restriction>
            </xsd:simpleType>
         </xsd:element>
      </xsd:sequence>
   </xsd:complexType>
</xsd:schema>

A sample instance document that validates against this schema might be:

<?xml version="1.0" ?>
<wfs:FeatureCollection
xmlns="http://www.someserver.com/myns"
xmlns:myns="http://www.someserver.com/myns"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.0.0/WFS-basic.xsd
                    http://www.someserver.com/myns ex10.xsd">
   <gml:boundedBy>
      <gml:Box>
         <gml:coord>
            <gml:X>10</gml:X>
            <gml:Y>10</gml:Y>
         </gml:coord>
       <gml:coord>
            <gml:X>20</gml:X>
            <gml:Y>20</gml:Y>
         </gml:coord>
      </gml:Box>
   </gml:boundedBy>
   <gml:featureMember>
      <Person>
         <myns:LastName>Smith</myns:LastName>
         <myns:FirstName>Fred</myns:FirstName>
         <myns:Age>35</myns:Age>
         <myns:Sex>Male</myns:Sex>
         <myns:Location>
            <gml:Point><gml:coordinates>15,15</gml:coordinates></gml:Point>
         </myns:Location>
         <myns:Address>
            <myns:StreetName>Main St.</myns:StreetName>
            <myns:StreetNumber>5</myns:StreetNumber>
            <myns:City>SomeCity</myns:City>
            <myns:Province>SomeProvince</myns:Province>
            <myns:PostalCode>X1X 1X1</myns:PostalCode>
            <myns:Country>Canada</myns:Country>
         </myns:Address>
      </Person>
   </gml:featureMember>
</wfs:FeatureCollection>

The XML encoding of a GetFeature request is defined by the following XML Schema fragment:

   <xsd:element name="GetFeature" type="wfs:GetFeatureType"/>
   <xsd:complexType name="GetFeatureType">
      <xsd:sequence>
         <xsd:element ref="wfs:Query" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="version"
                     type="xsd:string" use="required" fixed="1.0.0"/>
      <xsd:attribute name="service"
                     type="xsd:string" use="required" fixed="WFS"/>
      <xsd:attribute name="handle"
                     type="xsd:string" use="optional"/>
      <xsd:attribute name="outputFormat"
                     type="xsd:string" use="optional" default="GML2"/>
      </xsd:attribute>
      <xsd:attribute name="maxFeatures" type="xsd:positiveInteger"
                     use="optional"/>
   </xsd:complexType>
   <xsd:element name="Query" type="wfs:QueryType"/>
   <xsd:complexType name="QueryType">
     <xsd:sequence>
       <xsd:element ref="ogc:PropertyName" minOccurs="0" maxOccurs="unbounded"/>
       <xsd:element ref="ogc:Filter" minOccurs="0" maxOccurs="1"/>
     </xsd:sequence>
     <xsd:attribute name="handle"
                    type="xsd:string" use="optional"/>
     <xsd:attribute name="typeName"
                    type="xsd:QName" use="required"/>
     <xsd:attribute name="featureVersion"
                    type="xsd:string" use="optional"/>
   </xsd:complexType>

The <GetFeature> element contains one or more <Query> elements, each of which in turn contain the description of a query. The results of all queries contained in a GetFeature request are concatenated to produce the result set.

The outputFormat attribute defines the format to use to generate the result set. The default value is GML2 indicating that GML [2] shall be used. Vendor specific formats (including non-XML and binary formats), declared in the capabilities document are also possible.

The optional maxFeatures attribute can be used to limit the number of features that a GetFeature request retrieves. Once the maxFeatures limit is reached, the result set is truncated at that point.

Each individual query packaged in a GetFeature request is defined using the <Query> element. The <Query> element defines which feature type to query, what properties to retrieve and what constraints (spatial and non-spatial) to apply to those properties.

The typeName attribute is used to indicate the name of the feature type or class to be queried.

The featureVersion attribute is included in order to accommodate systems that support feature versioning. A value of ALL indicates that all versions of a feature should be fetched. Otherwise, an integer, n, can be specified to return the nth version of a feature. The version numbers start at 1, which is the oldest version. If a version value larger than the largest version number is specified, then the latest version is returned. The default action shall be for the query to return the latest version. Systems that do not support versioning can ignore the parameter and return the only version that they have.

The <PropertyName> element is used to enumerate the feature properties that should be selected during a query and whose values should be included in the response to a GetFeature request. A client application can determine the properties of a feature by making a DescribeFeatureType request before composing a GetFeature request. The DescribeFeatureType operation [sec. 8] will generate a GML application schema defining the schema of the feature type. The client can then select the properties to be fetched. In addition, the client can determine which feature properties are mandatory and must be fetched in order for the WFS to be able to generate an instance of the feature type that will validate againt the generated GML application schema. In the event that a WFS encounters a query that does not select all mandatory properties of a feature, the WFS will internally augment the property name list to include all necessary property names. A WFS client must thus be prepared to deal with a situation where it receives more property values than it requests.

If no <PropertyName> elements are specified, then all feature properties should be fetched.

The <Filter> element can be used to define constraints on a query. Both spatial and/or non-spatial constraints can be specified as described in the Filter Encoding Specification [3]. If no <Filter> element is contained within the <Query> element, then the query is unconstrained and all feature instances should be retrieved.

The <GetFeatureWithLock> element is functionally similar to the <GetFeature> element, except that it indicates to a web feature service to attempt to lock the features that are selected; presumably to update the features.

The format of the response to a GetFeature request is controlled by the outputFormat attribute. The default value for the outputFormat attribute shall be GML2. This will indicate that a WFS must generate a GML document of the result set that conforms to the OpenGIS® Geography Markup Language Implementation Specification, version 2.1.1 [2], and more specifically, the output must validate againt the GML application schema generated by the DescribeFeatureType operation [sec. 8].

Any GML document generated by a WFS implementation, in response to a query where the outputFormat is GML2, must reference an appropriate GML application schema document so that the output can be validated. This can be accomplished using the schemaLocation attribute, as defined in [6]. This attribute provides hints as to the physical location of one or more schema documents which may be used for local validation and schema-validity assessment. The schemaLocation attribute value contains pairs of values. The first member of each pair is the namespace for which the second member is the hint describing where to find to an appropriate schema document. The physical location of the schema documents is specified using a URI [10].

The following XML fragment shows the use of the schemaLocation attribute on the root element indicating the location of the an XML Schema document that can be used for validation:

<?xml version="1.0" ?>
<wfs:FeatureCollection
   xmlns="http://www.opengis.net/myns"
   xmlns:myns="http://www.opengis.net/myns"
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
   xsi:schemaLocation="http://www.opengis.net/myns
                       http://www.someserver.com/wfs.cgi?
                       request=DescribeFeatureType&typename=TREESA_1M,ROADL_1M"> …

In this instance, the schema document corresponding to the myns namespace is dynamically generated by making a DescribeFeatureType request back to the server that generated the output, requesting the schema. This DescribeFeatureType operation [sec. 8] requests the schema of the feature types TREESA_1M and ROADL_1M, both in the myns namespace.

It is up to each WFS implementation to arrange that the GML output makes the appropriate schemaLocation reference(s) such that the output can be validated.

For the <GetFeatureWithLock> request, a WFS must generate a result that includes the lock identifier. The lock identifier is encoded using the lockId attribute that is defined on the <wfs:FeatureCollection> element. The following XML fragment illustrates how to include the lockId attribute in the response to the operation:

<wfs:FeatureCollection lockId="00A01"… >
…
</wfs:FeatureCollection>

The ellipses are meant to represent all the other components included in the GetFeatureWithLock response which are identical to the components included in the GetFeature response.

This section contains numerous examples of the GetFeature request. Some examples include sample output.