[QGIS-Developer] WFS and NULL values

Alessandro Pasotti apasotti at gmail.com
Wed Jan 23 02:55:38 PST 2019


Correct,  thanks for pointing that out!

On Wed, Jan 23, 2019 at 11:45 AM Even Rouault <even.rouault at spatialys.com>
wrote:

> On mercredi 23 janvier 2019 11:42:19 CET Alessandro Pasotti wrote:
> > 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" />
>
> If you want to be able to set xsi:nil="true", the XSD element declaration
> must
> have the nillable="true" attribute.
> minOccurs="0" is to allow the element to be completely absent.
>
> >
> > How does it sounds?
> >
> >
> > On Wed, Jan 23, 2019 at 11:02 AM Even Rouault <
> even.rouault at 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
>
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
>


-- 
Alessandro Pasotti
w3:   www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190123/f152aacf/attachment-0001.html>


More information about the QGIS-Developer mailing list