[QGIS-Developer] WFS and NULL values

Even Rouault even.rouault at spatialys.com
Wed Jan 23 02:02:57 PST 2019

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" ?>
     xsi:schemaLocation="http://ogr.maptools.org/ foo.xsd"
    <ogr:foo fid="foo.0">
      <ogr:null_prop xsi:nil="true"/>
    <ogr:foo fid="foo.1">

$ 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:
Geometry Column = geometryProperty
fid: String (0.0) NOT NULL
a: Integer (16.0)
null_prop: String (0.0)
b: Integer (16.0)
  fid (String) = foo.0
  a (Integer) = 1
  null_prop (String) = (null)

  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

More information about the QGIS-Developer mailing list