Skip to main content

Module generate

Module generate 

Source
Expand description

XML GENERATE – a deterministic serializer of an explicit element tree to XML text.

This is a clean, general XML serializer. It is independent of GnuCOBOL/libcob – the output policy is ours (stable, explicit, no namespace magic, no schema, no hidden inference), not a reproduction of any COBOL runtime’s exact bytes.

§Determinism

For a given tree and GenerateOptions the output bytes are a pure function of the input – attributes are emitted in tree order (never reordered), no timestamps, no locale. That is what makes the output safe for migration diffs and golden-file tests (EXT.XML.GENERATE.1).

Structs§

GenerateOptions
Serialization options.
XmlElement
An XML element: a name, ordered attributes, and ordered children. Groups carry child elements; leaves carry a single XmlNode::Text child (or none, for an empty element).

Enums§

XmlNode
A node in the XML tree: an element subtree or a run of text.

Functions§

escape_attr
EXT.XML.ESCAPE.1 – escape an attribute value (double-quoted): text escaping plus "->" and the whitespace controls TAB/LF/CR as character references (so an attribute round-trips its exact value).
escape_text
EXT.XML.ESCAPE.1 – escape a run of element character data: &->&amp;, <->&lt;, >->&gt;. (> is escaped too, though only required after ]], for a conservative, unambiguous output.)
generate
EXT.XML.GENERATE.1 – serialize an element tree to XML text. Deterministic: the output is a pure function of root + opts (attributes in tree order, no timestamps/locale). Leaves render inline (<n>text</n>); empty elements self-close (<n/>); groups nest (indented when opts.indent is set).