[Fdo-trac] [fdo-trac] #740: Properties with NULL Values are not Included in XML Output
FDO
trac_fdo at osgeo.org
Thu Oct 15 06:17:42 PDT 2026
#740: Properties with NULL Values are not Included in XML Output
-----------------------------------------+-----------------------------
Reporter: crispinatime | Owner: brentrobinson
Type: defect | Status: closed
Priority: minor | Milestone: 3.6.0
Component: FDO API | Version: 3.6.0
Severity: 3 | Resolution: fixed
Keywords: xmlFeatureSerialize XML GML | External ID:
-----------------------------------------+-----------------------------
Changes (by jng):
* resolution: => fixed
* status: new => closed
Comment:
In [changeset:"8409" 8409]:
{{{#!CommitTicketReference repository="" revision="8409"
Serialize null property values as xsi:nil elements
Fixes #740.
#740 Properties with NULL Values are not Included in XML Output.
FdoXmlFeatureSerializer::XmlSerialize() discarded every property whose
value the
feature reader reported as null, so the features written by one call had
different shapes: a record with a null property was missing that property
element altogether, and the gml:featureMembers of an export carried
different
properties from record to record.
A property that the reader reports without a value is now written as a
property
element with an xsi:nil="true" attribute, which is how XML Schema and GML
represent a null value, so every feature written by a call carries the
same
property elements. Nothing is written, as before, for a property the
reader does
not report at all - one left out of the select, or one of the GML
name/description/id relate properties, whose names ("gml/name") are not
element
names - and object and association properties still go through their own
sub-writers, which write a feature collection and write nothing when it
has no
members.
The managed wrapper forwards its arguments straight to these classes, so
no
managed code change is needed.
* FeatureSerializer.cpp: _writeProperty() writes a null property that the
reader
reports (GetPropertyIndex() finds it among the properties of the feature
being
read) and that has a value of its own to be missing (a data or a
geometric
property) as a property value with no value, which is FDO's null value
for a
property.
* FeaturePropertyWriter.cpp: WriteProperty() writes an FdoPropertyValue
that has
no value as <prop xsi:nil="true"/>, and declares the xsi prefix on the
property element itself when the caller has not already declared it in
scope.
A value-only write writes nothing, since a null property's only content
is the
attribute.
* FeaturePropertyReaderImpl.cpp: an element carrying xsi:nil="true", or
the
other XML Schema literal "1", is a property with no value: its content
is not
parsed and the property is reported to the feature handler with no
value, so
that the feature reports it as null instead of as an empty value or an
empty
geometry.
* FeatureReaderImpl.cpp: AddDataProperty() registers the name of a
property that
is reported with no value, so that IsNull() reports it as null while it
stays
part of the feature. GetPropertyIndex() and GetPropertyName() reported
the
property list of the reader itself, which for a reader over a feature
collection is empty; they now report that of the feature being read, as
IsNull() and GetString() already did.
* FeatureSerializer.h, FeaturePropertyWriter.h: document what a null
property
value is written as.
Tests: GmlWriteTest::testNullProperty serializes a reader whose int32Prop,
stringProp and geoProp have no value, requires each of its two features to
carry
all three as xsi:nil elements, and then reads the document back and
requires
them to come back as null properties of the feature, with the properties
that do
have values untouched. GmlWriteTest::testWriteNullProperty drives the
property
writer directly, with a property value that has no value and one that has,
and
requires the first to be the xsi:nil element with the XMLSchema-instance
namespace declared on it, since the caller declared none.
GmlTest::testNullProperty
reads a document containing xsi:nil="true", xsi:nil="1", xsi:nil="false"
and an
empty element, and requires the first two to be null and the last two to
keep
their (empty) values. All three failed before the fix: no xsi:nil element
was
written for a null property, the property writer dereferenced a null
value, and
an xsi:nil element in a document was read as an empty value rather than as
a
null.
Validation: FDOCore UnitTest on ubuntu22 amd64, Debug OK (129) and Release
OK
(129), against OK (126) for the same tree before the change; the three new
tests
are the difference. The Debug run reports 0 direct and 50 indirect
LeakSanitizer
records, 220980 bytes in 2418 allocations, the same totals the suite
reported
before the change. UnitTestMySql OK (249), which includes
MySqlFdoImportExportTest OK (4), the suite that round-trips features
through the
XML serializer and the XML reader, and its LeakSanitizer report is also
unchanged (0 direct, 318 indirect, 46236 bytes in 491 allocations).
API/ABI: the cycle is in freeze mode, and no provider-facing surface
moves. The
only shipped headers touched are FeatureSerializer.h and
FeaturePropertyWriter.h, in comments; the new code is file-local. nm -D
over
libFDO against the fdosdk 8364 baseline reports no removed symbols, and
the five
symbols it reports as added are the ones the previous change added.
}}}
--
Ticket URL: <https://trac.osgeo.org/fdo/ticket/740#comment:2>
FDO <http://fdo.osgeo.org/>
Feature Data Objects
More information about the fdo-trac
mailing list