Hugo Ledoux

associate-prof in 3D geoinformation at TU Delft
blog contact protégés publications research slides software

Validation of CityGML files against the schemas

While I work a lot on the data quality of 3D city models, I often brush aside the validation of a CityGML file against the schemas (*.xsd) of CityGML as a simple and solved problem. However, while it’s indeed a solved problem, I realised that there are, to my knowledge, no free and easy tools to validate a CityGML file. Which means that in practice we often see files that are not valid. I usually use oXygen XML, but it is not free and rather cumbersome when the xsi:schemaLocation for the schemas are not properly setup as in the following. Then one must manually find the appropriate schemas (v0.4, v1.0 or v2.0) by reading the header, and then find the files locally (“where have I put these again?”)

<?xml version="1.0" encoding="UTF-8"?>
<CityModel 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:pfx0="http://www.citygml.org/citygml/profiles/base/1.0" xmlns:xlink="http://www.w3.org/1999/xlink" 
...
xsi:schemaLocation="http://www.citygml.org/citygml/profiles/base/1.0 http://schemas.opengis.net/citygml/profiles/base/1.0/CityGML.xsd">

So I wrote a small Python script that takes as input a CityGML file, determines which version of CityGML is used, validate the file and give the first error, if any. I think it can be useful to others. Get it there

To use:

$ ./valxsdcitygml.py input.gml

or you can also give a folder and all XML and GML files in that folder (and in all the folders inside that one) are validated

$ ./valxsdcitygml.py /home/elvis/data/


RSSCreative Commons License