Copyright © 2010 Open Geospatial Consortium
41
SortBy + sortProperty [1. .] : SortProperty
from ISO 19143 Filter Encoding
SortOrder + ascending
+ descending from ISO 19143 Filter Encoding
Enumeration SortProperty
+ valueReference : ValueReference + sort Order : SortOrder
from ISO 19143 Filter Encoding
Figure 10 — Query sorting clause 7.9.2.5.4.2
XML encoding
In XML, the sorting clause of an ad hoc query expression shall be encoded using the fes:SortBy element see ISO 19143:2010, Clause 8.
An ad hoc query expression shall have a minimum of zero and a maximum of one fes:SortBy child elements.
7.9.2.5.4.3 KVP encoding
For KVP-encoded request, the sorting clause shall be encoded using the keyword SORTBY keyword see ISO 19143:2010, Table 2.
7.9.2.5.4.4 Sort processing
A web feature service that receives an ad hoc query expression without a sorting clause, shall generate a response document in which features are presented in whatever order the server chooses. However, to
comply with this International Standard, servers shall ensure that whatever order is presented when an ad hoc query, not containing a sort clause, is first executed is preserved across subsequent executions of the same
ad hoc query expression on the same set of features.
EXAMPLE A server may choose to sort the features by their gml:id if the client has not specified a specific sorting
clause. Subsequent invocations of the same query expression on the same set of data should result in a response document that presents the features in the same order.
In the event that a web feature service receives a request containing an ad hoc query with a sorting clause, the service shall respond by presenting features in the response document in the requested order.
Sorting is only supported within the scope of a single ad hoc query expression. Global sorting over all features in a result set, generated by multiple ad hoc query expressions being encoded in the request, shall not be
supported. The trivial exception to this statement, of course, is the case where the request contains a single query expression.
When processing a query with a sorting clause, the sort shall be executed in the context of all the data that matches the request parameters before the response is possibly reduced to a set within the limits of the count
attribute see 7.6.3.5.
42
Copyright © 2010 Open Geospatial Consortium
7.9.3 Stored query expression 7.9.3.1
Request Semantics
A stored query expression may be used in a GetPropertyValue see Clause 10, GetFeature see Clause 11, GetFeatureWithLock see Clause 13 or LockFeature see Clause 12 operation to identify a set of features to
be operated upon.
A stored query expression see Figure 11 is a persistent, parameterized, identifiable query expression. A stored query can be repeatedly invoked using its identifier with different values bound to its parameters each
time.
All servers shall implement the ability to list, describe and execute stored queries. All server implementations shall offer a stored query that fetches features based on their identifier. Additional
stored queries that are packaged with the server may also be offered. Clause 14 describes a set of operations for managing stored query expressions.
StoredQuery + id : URI
+ parameter [ 0..] : Parameter
Parameter + name : LocalName
+ value : Any QueryExpression
+ handle [0..1] : CharacterString from ISO 19143 Filter Encoding
Figure 11 — StoredQuery 7.9.3.2
XML encoding
The following XML Schema fragment defines the XML encoding of a stored query expression:
xsd:element name=StoredQuery type=wfs:StoredQueryType substitutionGroup=fes:AbstractQueryExpression
xsd:complexType name=StoredQueryType xsd:complexContent
xsd:extension base=fes:AbstractQueryExpressionType xsd:sequence
xsd:element name=Parameter type=wfs:ParameterType minOccurs=0 maxOccurs=unbounded
xsd:sequence