[gdal-dev] GML (created via ogr2ogr) validation with OpenGIS XSD

Even Rouault even.rouault at spatialys.com
Mon Jul 4 11:09:53 PDT 2016


Le lundi 04 juillet 2016 17:04:53, Jonathan Beliën a écrit :
> Hi everyone,
> 
> 
> 
> I’m trying to validate a GML file produced with ogr2ogr with OpenGIS GML
> XSD files.
> 
> 
> 
> For every file I try to validate I have the same error message : « element
> FeatureCollection: Schemas validity error : Element
> '{http://ogr.maptools.org/}FeatureCollection': No matching global
> declaration available for the validation root. »
> 
> 
> 
> I suspect I do something wrong but I can’t figure what !?!

As far as I know, files produces with OGR GML driver validate against the 
schemas. You didn't specify which tool you used to do the validation and how 
do you invoked it.

You must validate explictly against the .xsd file generated along side of the 
.gml. This xsd will import the appropriate GML schemas.

Example of successful validation with xmllint/libxml2 :

$ ogr2ogr -f GML poly.gml poly.shp

$ xmllint -noout -schema poly.xsd poly.gml
poly.gml validates

$ ogr2ogr -f GML poly.gml poly.shp -dsco FORMAT=GML3

$ xmllint -noout -schema poly.xsd poly.gml
poly.gml validates


> 
> 
> 
> I tried several -dsco FORMAT parameter and tried to validate on every
> schema I could find here http://schemas.opengis.net/gml/ without any
> success.
> 
> 
> 
> Does someone know what I’m doing wrong or could help me to validate my file
> ?
> 
> 
> 
> Thanks a lot !
> 
> 
> 
> Copy of my test file :
> 
> 
> 
> <?xml version="1.0" encoding="utf-8" ?>
> 
> <ogr:FeatureCollection
> 
>      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 
>      xsi:schemaLocation="http://ogr.maptools.org/ test.xsd"
> 
>      xmlns:ogr="http://ogr.maptools.org/"
> 
>      xmlns:gml="http://www.opengis.net/gml">
> 
>   <gml:boundedBy>
> 
>     <gml:Box>
> 
> 
> <gml:coord><gml:X>3.38653564453125</gml:X><gml:Y>50.41551870402676</gml:Y><
> / gml:coord>
> 
> 
> <gml:coord><gml:X>4.57305908203125</gml:X><gml:Y>50.89956852220873</gml:Y><
> / gml:coord>
> 
>     </gml:Box>
> 
>   </gml:boundedBy>
> 
> 
> 
> 
>   <gml:featureMember>
> 
>     <ogr:test fid="test.0">
> 
>       <ogr:geometryProperty><gml:Polygon
> srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>4
> . 49066162109375,50.896103955543587 3.38653564453125,50.60415948856101
> 4.57305908203125,50.415518704026759 3.61724853515625,50.899568522208732
> 4.49066162109375,50.896103955543587</gml:coordinates></gml:LinearRing></gm
> l: outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
> 
>       <ogr:userid>userid-1</ogr:userid>
> 
>     </ogr:test>
> 
>   </gml:featureMember>
> 
>   <gml:featureMember>
> 
>     <ogr:test fid="test.1">
> 
>       <ogr:geometryProperty><gml:MultiPolygon
> srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><g
> m l:LinearRing><gml:coordinates>3.921339446183916,50.745568181163129
> 4.57305908203125,50.415518704026759 3.38653564453125,50.60415948856101
> 3.921339446183916,50.745568181163129</gml:coordinates></gml:LinearRing></g
> ml
> 
> :outerBoundaryIs></gml:Polygon></gml:polygonMember><gml:polygonMember><gml:
> :P
> 
> olygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>4.490661621093
> 7 5,50.896103955543587 3.921339446183916,50.745568181163129
> 3.61724853515625,50.899568522208732
> 4.49066162109375,50.896103955543587</gml:coordinates></gml:LinearRing></gml
> :
> outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr
> :g eometryProperty>
> 
>       <ogr:label>label-2</ogr:label>
> 
>     </ogr:test>
> 
>   </gml:featureMember>
> 
> </ogr:FeatureCollection>
> 
> 
> 
> Jonathan Beliën
> 
> GEO-6

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list