[GIS] Exporting XSD from GML using QGIS or ArcGIS for Desktop

arcgis-desktopgmlqgisxml

I want to export a XSD from a GML.
I already have the GML and I want to export a XSD that fits the GML

For an ETL tool we've programmed, people have to deliver a GML, XML and XSD. Those people already have a GML and XML, the ETL tool also requires an XSD. So I'm looking for an easy way to export an XSD that fits the GML

Is it possible to make an export in QGIS or ArcMap?

Best Answer

You can create .xsd schema file by rewriting your GML with ogr2ogr. Writing schema into .xsd file is the default in GML driver http://www.gdal.org/drv_gml.html so you can simply use this command:

ogr2ogr -f GML output.gml input.gml

You do not need the output.gml file for anything so you can delete it and use the .xsd. If your source GML is big you can create .xsd faster by converting just one feature into the dummy gml:

ogr2ogr -f gml output.gml input.gml -dialect sqlite -sql "select * from input_layer limit 1"

The layer name to be used instead of "input_layer" can be checked by listing the layers with ogrinfo:

ogrinfo input.gml
Related Question