GML overview
The OS MasterMap Topography Layer product is supplied in Geography Markup Language (GML) version 2.1.2. This section describes how OS MasterMap is defined in GML. An understanding of XML
(eXtensible Mark-up Language) and XML schemas is required. The XML specifications that GML is based on are available from the World Wide Web Consortium (W3C) website.
XML schema
Schema overview and Internet location
XML schemas are used to validate the format and content of the GML. The GML 2.1.2 specification provides a set of schemas that define the GML feature constructs and geometric types. These are designed to be used as a basis for building application-specific schemas, which define the data content.
The Ordnance Survey application schemas that are referenced by the data are available from the Ordnance Survey XML schemas page of the OS website.
These schemas make use of XML Schema Definitions (XSDs) and Document Type Definitions (DTDs) produced by the W3C that are available from The XML: Namespace page of the W3C website.
Some recent parsers now fail to validate OS MasterMap Topography Layer using these schemas as working practices and XML schema specification clarifications have led to GML 2.1.2 being rendered invalid.
Schema descriptions
The W3C-provided XSDs and DTDs are:
xml.xsd – To allow the use of the xml:lang attribute for language qualification.
XMLSchema.dtd – Required by xml.xsd.
datatypes.dtd – Required by XMLSchema.dtd.
The OGC-provided schemas are:
feature.xsd – The feature and property constructs.
geometry.xsd – The geometric constructs, such as polygon and point.
xlinks.xsd – A schema based on the W3C XLINK recommendation provided by the OGC to make use of the XLINK constructs.
The Ordnance Survey application schemas are:
OSDNFFeatures.xsd – The definition of the Ordnance Survey features and their properties.
OSComplexTypes.xsd – The complex property types, including changeHistoryType.
OSSimpleTypes.xsd – The basic property types, including descriptiveGroupType and accuracyOfPositionType.
OSMeasures.xsd – The definition of measure-qualified types used in OS MasterMap data.
OSQueryresult.xsd – The definition of a query result with its properties.
OSGeometryTopology.xsd – Geometry and topology extensions to the GML 2.1.2 specification required by Ordnance Survey, including rectangles and polygon topology.
XML namespaces
xlink – http://www.w3.org/1999/xlink
Use of examples
Any examples in this section that mention specific data content are to be taken as examples only. All data content is defined in OS MasterMap Topography Layer separately, and the examples are not necessarily in harmony with the data specification.
XML declaration
The XML declaration to all query results is: <?xml version=‘1.0’ encoding=‘UTF-8’?>
Document type
All information returned from a query is provided in an osgb:FeatureCollection. If no features lie inside a query, then an empty collection is returned with its required collection properties.
The document defines the XML namespaces:
osgb – https://www.ordnancesurvey.co.uk/xml/schema/v9/index.html The location of the schema is defined as: https://www.ordnancesurvey.co.uk/xml/schema/v9/index.html http://www.ordnancesurvey.co.uk/xml/schema/vX/OSDNFFeatures.xsd The fid is set to the Ordnance Survey identifier given to the query.
For example:
Query result properties
The gml:description element is the first property of the feature collection; this contains a copyright statement and the date of the query.
The gml:boundedBy element is the next property of the feature collection; this contains a gml:null element with the value of ‘unknown’.
The start time of the query is specified at GMT as a feature property. The name of the property is queryTime.
The following optional properties are provided for the osgb:FeatureCollection if they were provided as part of the query. The ordering of these properties is according to the order they appear in the table:
queryExtent
Geometric property
gml:Polygon or osgb:Rectangle (see Geometry).
The query extent provided as part of a spatial query.
queryChangeSinceDate
Date
CCYY-MM-DD
The date that was given as part of a change-only query.
For geographically chunked data, if there are features in the collection, the last element in the feature collection is an osgb:boundedBy element. This is a gml:Box defining the minimum bounding rectangle of all items in the collection, including the query extent. If the collection is empty, no osgb:boundedBy element is provided.
For example:
Features
Each feature within the osgb:FeatureCollection is encapsulated in one of the following member elements according to its feature type:
boundaryMember
BoundaryLine
cartographicMember
CartographicText, CartographicSymbol
topographicMember
TopographicPoint, TopographicLine, TopographicArea
departedMember
DepartedFeature (see section on COU)
Each member element contains a single feature element that has the name of the feature type, for example, TopographicPoint, TopographicLine, and so on.
The TOID of the feature is provided in the XML attribute ‘fid’ of the osgb:Feature element. A TOID has a maximum of 16 digits and is prefixed with ‘osgb’. The ‘osgb’ prefix is required to form a valid XML ID type.
A feature element does not contain a name, description or boundedBy element. For example:
Properties
Our application schema defines three main types of properties that are present inside a feature element; these are simple, complex and geometric properties.
The ordering of properties within a feature element is important as XML validation is reliant on elements being in a specified order. The order of properties is specified within the XML schema.
Each type of property may additionally have associated metadata encoded using an XML attribute. This metadata provides some qualification of the status or accuracy of the content provided in the attribute.
Simple
A simple property is one that contains a single piece of non-geometric information. These properties correspond to simple feature attributes. The value of each feature attribute is enclosed in an element that takes its name from the feature attribute.
A feature association is a special type of simple property that defines a relationship between one feature and another. The feature association is defined by the XML attribute xlink:href. This shall refer to a feature as if it was locally available, even though this is not guaranteed to be the case; that is, it shall be set to the character ‘#’ followed by ‘osgb’ and then the TOID of the feature being referenced.
For example:
Geometry
A geometric property is one that describes a specific geometry. All geometric properties are encoded according to the GML specification. We have extended the GML v.2.1.2 specification to include a rectangle that is defined by two points. The first point defines the minimum coordinate, whilst the second point defines the maximum coordinate.
All geometric properties are encoded by placing the GML geometry elements inside an element that takes its name from the feature attribute.
The XML attribute srsName shall be set to ‘osgb:BNG’ (BNG stands for British National Grid), which uses eastings and northings specified in metres.
If a line is broken or a polygon has bled into another because of a partial update (see inconsistent features), then the XML attribute broken shall be set to ‘true’. A line that is broken will be encoded as a gml:MultiLineString.
All polygon outer boundaries have an anticlockwise orientation, and all inner boundaries have a clockwise orientation.
For example:
Complex
A complex property is one that contains more than one piece of information. These properties correspond to the complex feature attributes.
Class model
The definition of a complex property here is recursive, so complex properties may be nested. Currently, within OS MasterMap, this recursion is not used.
Figure 9: Class model diagram showing a complex property in OS MasterMap Topography Layer.
XML mapping
The complex property element takes its name from the complex feature attribute. Each part of a complex property shall be encoded as a simple, complex, geometry or topology property, as appropriate, inside the complex property element.
For example:
Last updated