Almost all of the WFS/WFS-T servers, the feature identifiers -represented as gml:id in the XML document- that I have come across were in this format: [LayerName].[IntegerFeatureID], e.g., BarcelonaBuildings.1453. However, sometimes, it can also be like this: 12400.344.561.1. I have looked at the OGC documentation but it doesn't say anything about the structure of the feature identifiers. Should it be integer? Could it be a string? Could it have alphanumeric characters? Should it contain the layer name as part of it?

Is there a specific standard for WFS feature identifiers or can it be anything depending on the server as long as it is unique?


Rules for gml:id come from the GML standard. This is about GML 3.2 id The attribute gml:id supports provision of a handle for the XML element representing a GML object. Its use is mandatory for all GML objects.

<attribute name="id" type="ID"/>

It is of XML type ID, so is constrained to be unique in the XML document within which it occurs. An external identifier for the XML element representing the GML object in the form of a URI may be constructed using standard methods (IETF RFC 2396). This is done by concatenating the URI for the document, a fragment separator "#", and the value of the attribute of XML type ID.

Rules for xsd:ID type can be checked from http://www.datypic.com/sc/xsd/t-xsd_ID.html

The type xsd:ID is used for an attribute that uniquely identifies an element in an XML document. An xsd:ID value must be an NCName. This means that it must start with a letter or underscore, and can only contain letters, digits, underscores, hyphens, and periods. xsd:ID carries several additional constraints:

  • Their values must be unique within an XML instance, regardless of the attribute's name or its element name.

  • A complex type cannot include more than one attribute of type xsd:ID, or any type derived from xsd:ID.

  • xsd:ID attributes cannot have default or fixed values specified.


After a bit of digging I found that gml:id is of type xml:ID:

For both attributes and simple element content, the lexical domain of these datatypes is the lexical domain of XML nonqualified names (xs:NCName).

An xs:NCName is restricted to \[\i-\[:\]\]\[\c-\[:\]\]* which means that it can't start with a number, . or minus, or contain any of the "special" characters :, @, $, %, &, /, +, ,, ;, whitespace characters or different parenthesis.

Alternatively it can be defined as:

1 NSAttName ::= PrefixedAttName | DefaultAttName

2 PrefixedAttName ::= 'xmlns:' NCName [ NSC: Leading "XML" ]

3 DefaultAttName ::= 'xmlns'

4 NCName ::= (Letter | '_') (NCNameChar)* /* An XML Name, minus the ":" */

5 NCNameChar ::= Letter | Digit | '.' | '-' | '_' | CombiningChar | Extender

So 12400.344.561.1 is not a valid xml:ID so it can't be a valid gml:id as it starts with a number.

From the GML schema the only other constraint is "... constrained to be unique in the XML document within which it occurs" so there is no requirement to use the layer name (but that is a quick and easy way to get some uniqueness into it).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.