INSPIRE GML Basic Writing and Validation Example

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2021.0


With FME, it is possible to obtain INSPIRE compliant GML within one small workspace. For this demo, a single feature is created with polygon geometry and attributes. The feature is then structured to match the INSPIRE Natural Risk Zones Core schema. Finally, the INSPIRE GML Writer is used to write a Hazard Area feature, part of Annex III's Natural Risk Zones theme. The demo exemplifies the ease of creating valid INSPIRE GML based on the application schemas. This workflow can be adapted to suit other INSPIRE themes, since workspaces to write INSPIRE GML usually contain similar steps.

Step-by-step Instructions

 1. Read source data

Source data is read with the appropriate reader. In this example, for simplicity, a polygon is created to represent a sample feature, in this case a flood risk area, using the Creator transformer. This is also a good way to create a reproduction case when reporting bugs to support.

2. ID generation

Unique IDs are generated, as required by INSPIRE. Sometimes data will contain unique identifiers and those can be used and formatted as required. If no unique IDs are available they can be generated with FME as we do here using the UUIDGenerator transformer. Remember to validate the INSPIRE GML which will ensure uniqueness of IDs, or use a DuplicateRemover to detect them. Note that some IDs such as GML IDs must begin with a letter, not a number, so a prefix is added in the AttributeCreator ( U_@Value(_uuid) ).

3. Addition of required fields and schema mapping

Necessary attributes are created, populated and schema is mapped. Source data will likely contain attributes which can be renamed to match the INSPIRE destination attributes, a process referred to as schema mapping. However, certain attributes required by the INSPIRE data specifications are often lacking in the source data, for example date and area information. These attributes can be given default values, generated, or obtained from schema mapping. A variety of transformers may be involved in attribute addition and modification, including Attribute Creator, AttributeCopier, SchemaMapper, as well as a number of calculator transformers.

The AttributeCreator structures data to meet the INSPIRE data model requirements: 


4. Reprojection

Data is reprojected to the INSPIRE specified coordinate system. The INSPIRE Directive requires that data be published in ETRS89 (EPSG:4258), or for systems outside of ETRS89, in the ITRS reference system.

5. Geometry transformation

Source geometry is named to match the appropriate xml_geometry name(s) in the destination feature type. Frequently, multiple xml_geometry names will exist, but often it is acceptable to only write out to one xml_geometry. For this demo, the geometry we want to populate is named 'geometry'. The other xml_geometry geometries are optional, such as gml_boundedBy or gml_location. Geometry transformation may also consist of combining, restructuring, generalizing or simplifying geometries. In FME, the transformers most commonly used for this include GeometryPropertySetter for naming geometries and defining traits, Aggregator for nesting geometries, and GeometryCoercer for changing geometry types.

The GeometryPropertySetter is used to set the geometry name to 'geometry', to match one of the Hazard Area's xml_geometry types: 



The INSPIRE GML Writer is used to write the Hazard Area destination feature type. The XML schema document (XSD) can be specified either by selecting the INSPIRE theme, or by specifying the file path for the XSD. In this example, the built-in application schema Natural Risk Zones Core is utilized. Source attributes with the same name as destination attributes are implicitly mapped directly to the destination fields. Note that the xml_geometry field remains red even though the geometry itself has been mapped.

The following writer settings are used:

  • INSPIRE Themes: NaturalRiskZonesCore
  • Application schema: not set since NaturalRiskZonesCore is set above
  • GML pretty printing = Yes: makes the GML more human readable for diagnostic purposes
  • Validate output file = Yes: verifies that the output is compliant with the selected INSPIRE schema
  • Coordinate System = not set: The coordinate system is set per feature so we don't need to set it on the dataset




After writing INSPIRE GML, it is important to validate it to ensure that it complies with XML syntax and XSD standards. You can check the GML against syntax and schema using the XMLValidator transformer. If the XML is not valid, in the log the error or errors will be briefly reported, including details such as the line, column number and a brief description of the error. For INSPIRE data, errors are often a result of missing attributes or values. Once an error is corrected, the data can be validated again to check whether the fix worked.

XML errors may seem somewhat misleading. For example, an error such as the following may be reported: “element 'namespace' is not allowed for content model '(localId,namespace,versionId?)’” In fact, this is often caused by a missing element which is expected earlier, since order matters. In this case, ‘inspireId.Identifier.localId’ must be defined before the namespace element, even though both are required. Try removing the ‘inspireId.Identifier.localId’ field to reproduce the above validation error. You can also get similar errors if the schema expects an element to be contained within a parent and you have not defined the correct gml_parent_id. Other common errors include missing IDs, incorrectly formatted date fields, null values without the required xsi_nil set to 'true', and invalid values or improper case for fields with restricted domains such as nilReason set to 'unknown'.

Note that validation can initially produce a list of many errors. Simplify the diagnostic process by limiting your output to a few typical features and then working through the errors one by one. Again, pretty-printing and viewing the output GML in a good XML editor like Notepad++ will make it a lot easier to find problems since the error list contains line and row numbers.

Validation workspace using the XML Validator transformer: 
Schema Validation.png

It is also possible to validate the XML output with the INSPIRE Writer. In the Navigator window, validation of the output file can be specified in the writer parameters. Note that once you are happy with the output, turning off validation can help improve writing performance.

INSPIRE GML Writer parameters in the Navigator, which include the option to validate the output file: 


FME Server can be used to provide an online INSPIRE data validation service driven by a workspace similar to the one shown above. A demo is available where you can upload data corresponding to any of the Annex I themes and validate the schema. The source code and workspace used in this demo can be downloaded from the site and modified for deployment on your own FME Server. You can add in other validation tests as needed using FME transformers.



In the Data Inspector, view the INSPIRE GML result using the INSPIRE GML Reader. For quicker display time, under reader parameters select feature types by themes, with no INSPIRE themes selected, or only the NaturalRiskZonesCore theme selected.

In the Data Inspector, select feature types by themes, with no INSPIRE theme selected, or only NaturalRiskZonesCore: 


Note: This example is for demonstration purposes only. The resulting data is not to be used for any operational purposes. * INSPIRE or Infrastructure for Spatial Information in Europe, is a European Union directive that aims to create a spatial data infrastructure of EU data, which would be used for policy making. The directive also aims to improve public access to spatial information. For more information please visit the INSPIRE website.

Was this article helpful?



Please sign in to leave a comment.