[Fdo-trac] [fdo-trac] #675: FeatureSchema/FeatureSchemaCollection WriteXml() disregards indentation settings

FDO trac_fdo at osgeo.org
Thu Oct 15 05:34:25 PDT 2026


#675: FeatureSchema/FeatureSchemaCollection WriteXml() disregards indentation
settings
---------------------+-----------------------------
 Reporter:  jng      |        Owner:  brentrobinson
     Type:  defect   |       Status:  closed
 Priority:  minor    |    Milestone:  3.6.0
Component:  FDO API  |      Version:  3.5.0
 Severity:  3        |   Resolution:  fixed
 Keywords:           |  External ID:
---------------------+-----------------------------
Changes (by jng):

 * resolution:   => fixed
 * status:  new => closed

Comment:

 In [changeset:"8408" 8408]:
 {{{#!CommitTicketReference repository="" revision="8408"
 Honor XML flags and line formatting when serializing features and schemas

 Fixes #675.
 Fixes #738.

 Both tickets were reported against the .NET managed wrapper, which
 forwards its
 arguments straight to these C++ classes, so the defects are in the C++
 implementations and are fixed there. No managed code change is needed.

 #738 XmlFeatureSerialiser Does not Handle XMLFlags.
 FdoXmlFeatureSerializer::XmlSerialize() used its flags only for the
 FeatureCollection and featureMember elements that it writes itself. The
 feature
 writer and its feature property writer kept the flags they were created
 with,
 which is NULL whenever an application sets the flags on the serializer
 alone,
 as the ticket's failing example does. The features were then written with
 the
 default flags: GML 3.1.1 was requested and GML 2.1.2 geometry was
 produced, and
 the flags' default namespace prefix, srs name, coordinate system transform
 and
 gml:id relate properties were all ignored.

 The feature writer and feature property writer gain
 GetFeatureFlags()/SetFeatureFlags() and GetFlags()/SetFlags(), so that the
 serializer can see whether they were given flags of their own; a writer
 that
 already has flags is still left exactly as it is. XmlSerialize() applies
 the
 flags it is given to both writers when they hold none, and restores them
 afterwards, including when an exception unwinds the call. The writers
 carry the
 flags while the features are written, so sub-writers created for object
 and
 association properties inherit them, and the two examples in the ticket
 now
 produce the same document.

 #675 FeatureSchema/FeatureSchemaCollection WriteXml() disregards
 indentation
 settings. A Feature Schema has no external form of its own:
 FdoXmlSerializable::WriteXml() writes it in FDO's internal format to a
 temporary document, converts that to GML with an XSL transform and hands
 the
 transform's output to the caller's writer with WriteBytes(). Those bytes
 go
 straight to the stream, past FdoXmlWriter's line formatting, so a writer
 created with LineFormat_Indent produced a document with no line breaks at
 all.
 The internal writer was also created with the default line format, which
 the
 transform's output inherited.

 FdoXmlWriter gains WriteXmlText(), which writes XML text through the
 writer so
 that its line format is applied to it: a markup element starts a line of
 its
 own, indented to its depth in the document, while content, and the markup
 that
 follows content, are written verbatim. The scan for markup understands
 attribute values that contain '>' under either quoting character,
 comments,
 CDATA sections and processing instructions, and drops the XML declaration,
 since the writer writes its own. GetLineFormat() tells
 FdoXmlSerializable::WriteXml() when a line format was requested; it then
 transforms into a temporary document and writes that document through the
 caller's writer. When no line format is requested the transform's output
 still
 reaches the caller byte for byte as before.

 Tests: XmlTest::testWriteXmlText drives WriteXmlText() directly
 (declaration,
 an attribute value holding '>', a single quoted attribute, a comment, a
 CDATA
 section, a processing instruction, mixed content and an empty element).
 GmlWriteTest::testGML3SimpleFeatureNoWriterFlags serializes the same
 features
 twice, once with the flags on the writer, which worked, and once with them
 only
 on the serializer, and requires the two documents to be identical; it also
 checks that the serializer did not leave the flags it applied behind.
 SchemaTest::testXmlWriteIndent writes a schema, a single schema collection
 and
 a two schema collection to an indenting writer, and requires the
 indentation,
 an unindented document that differs only in the whitespace between
 elements,
 and a result that still parses. All three failed before these fixes, on
 the
 missing indentation and on GML 2.1.2 <gml:coordinates> in the output where
 3.1.1 <gml:posList> was expected.

 Validation: FDOCore UnitTest on ubuntu22 amd64, Debug OK (126) and Release
 OK
 (126), against OK (123) for the same tree before the change. 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.

 API/ABI: the cycle is in freeze mode. Four of the changed headers ship in
 the
 SDK include tree, but the additions are non-virtual member functions and
 inline
 getters, with no change to a data member or to a vtable. nm -D over libFDO
 against the fdosdk 8364 baseline reports no removed symbols and five
 added, no
 provider in that SDK has an undefined FdoXml reference the new library
 does not
 define, and a sizeof probe compiled against the baseline include tree and
 against the new one reports the same sizes for every affected class.
 }}}
-- 
Ticket URL: <https://trac.osgeo.org/fdo/ticket/675#comment:2>
FDO <http://fdo.osgeo.org/>
Feature Data Objects


More information about the fdo-trac mailing list