Thanks for all the comments! I understand that it depends on the schema, what confuses me is the assertion by Andrea in the (quite old) cited email that "GML and WFS explicitly avoid the use of "xs:nil", I could not find any authoritative support for that claim.
So, if that is not the case, we should probably fix QGIS Server's DescribeFeatureType to return something like this (for a nillable element): <element type="long" name="id_long" minOccours="0" /> And for the getFeature response, in case the value is NULL: <qgs:id xsi:nil="true" /> How does it sounds? On Wed, Jan 23, 2019 at 11:02 AM Even Rouault <even.roua...@spatialys.com> wrote: > Recent versions of OGR make a difference between : > > - a missing XML element, that will be represented in OGR as a "unset > field") > (allowed if the schema has minOccurs="0") > - and a XML element set to <foo xsi:nil="true"/>, that will be represented > in > OGR as a NULL field value (allowed if the schema has nillable="true") > > ( see https://trac.osgeo.org/gdal/wiki/rfc67_nullfieldvalues ) > > The same for JSon actually, between a property that doesn't appear at all, > or > which is set to null. > > Example, given foo.json with > > { "type": "FeatureCollection", > "features": [ > { "type": "Feature", "properties": { "a": 1, "null_prop": null }, > "geometry": null }, > { "type": "Feature", "properties": { "b": 2 }, "geometry": null } > ] > } > > $ ogr2ogr foo.gml foo.json -f gml > > $ cat foo.gml > <?xml version="1.0" encoding="utf-8" ?> > <ogr:FeatureCollection > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://ogr.maptools.org/ foo.xsd" > xmlns:ogr="http://ogr.maptools.org/" > xmlns:gml="http://www.opengis.net/gml"> > <gml:boundedBy><gml:null>missing</gml:null></gml:boundedBy> > > <gml:featureMember> > <ogr:foo fid="foo.0"> > <ogr:a>1</ogr:a> > <ogr:null_prop xsi:nil="true"/> > </ogr:foo> > </gml:featureMember> > <gml:featureMember> > <ogr:foo fid="foo.1"> > <ogr:b>2</ogr:b> > </ogr:foo> > </gml:featureMember> > </ogr:FeatureCollection> > > $ ogr2ogr out.json foo.gml > > $ ogrinfo foo.gml -al > INFO: Open of `foo.gml' > using driver `GML' successful. > > Layer name: foo > Geometry: Unknown (any) > Feature Count: 2 > Layer SRS WKT: > (unknown) > Geometry Column = geometryProperty > fid: String (0.0) NOT NULL > a: Integer (16.0) > null_prop: String (0.0) > b: Integer (16.0) > OGRFeature(foo):0 > fid (String) = foo.0 > a (Integer) = 1 > null_prop (String) = (null) > > OGRFeature(foo):1 > fid (String) = foo.1 > b (Integer) = 2 > > > And yes this is not WFS or GML specific, but XML + XML-Schema generic. > > -- > Spatialys - Geospatial professional services > http://www.spatialys.com > -- Alessandro Pasotti w3: www.itopen.it
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer