XML

Synopsis

HELP:   Format data stream in XML elements (tags, attributes, data, ...)
TYPE:   OBJECT
SYNTAX: XML(CHRSET=NONE/SYSTEM/ASCII/UCS1/UTF8/EBCDIC/UCS2BE/UTF16BE/UCS2LE/UTF16LE/UCS4BE/UTF32BE/UCS4LE/UTF32LE/LOCAL,FMTERR,NOCMNT,NODFLT,NOEMPD,ADDEMP,NOPINS,NODTD,CCDATA,NAMSPC[=num/LF2/LF3/TAB2/TAB3/PIPE2/PIPE3/COLON2/COLON3/SLASH2/SLASH3/REMOVE],USELCH,DATLEN=num,LENERR,BUFSIZ=num,INICNT=num)

Description

The object "format XML" parses block of text data containing an XML document. The XML data is parsed using the Expat library and transformed into FLAM elements, which allows various formatting options when writing, including minimizing and pretty printing the XML data.

The text data must be in UTF-8 or ASCII. Lines must be delimited with 0x0A, 0x0D or 0x0D0A. During parsing, all line delimiters are normalized to line feed characters (0xA) as defined by the XML specification.

There are several switches available to exclude certain types of XML elements from the parsed element list.

When reading XML documents through the byte or record interface using the element formatter (format.element()), the character data between starting and closing tags may be split into multiple XML data elements as the data can be of an arbitrary length. The DATLEN parameter controls the minimum length of a data element before being split (default is 1024). Note that this a minimum, so the data elements returned may be actually much larger. As a rule of thumb, the maximum length of data elements is close to the input buffer size (but may exceed it). If you want to get all data between any pair of starting and closing tags as a single data element, simply set the DATLEN parameter to a large number. You must be aware, however, that this might require considerable amounts of memory, depending the maximum data length in tag bodies. With the LENERR parameter, an error occurs if a data element exceeds the specified length. If the ignore empty data (NOEMPD) switch is set, data elements containing only whitespace are suppressed. With the ADDEMP switch, an empty data element is inserted to the element list if an end tag follows directly after a start tag (only relevant when writing custom applications using the APIs).

A special parameter can be used for namespace handling. The parameter NAMSPC only makes sense when using our APIs, because the result is no longer valid XML. With the parameter, the tags can be built up in doubles from URI and tag name or as a triple from URI tag name and NS prefix or you can only get the tag name (REMOVE). The namespace handling thus serves to simplify the machine processing of tags.

Translated with www.DeepL.com/Translator (free version)

XML formatting supports a lot of powerful features which can be accessed with the parameters below.

Arguments