XML Extensions normally strips trailing spaces from COBOL data items when exporting data, and restores trailing spaces to COBOL data items when importing data. Leading spaces are also removed and added for justified data items. This default behavior can be modified using the XML SET FLAGS statement, but the default behavior is generally best. The normal treatment of leading and trailing spaces does not apply to FILLER data items or edited data items.
Once the data is in XML, further consideration must be given to XML treatment of whitespace. XML defines whitespace as space, line feed, carriage return and tab characters. XML Extensions has various rules for handling of the individual whitespace characters:
Version 12.10 of XML Extensions preserves such characters when received from the parser for import. Please note that XML parsers that follow the W3C Recommendation for Extensible Markup Language (XML) translate the two-character sequence CR/LF and any CR that is not followed by a LF to a single LF character. Thus, CR characters are not normally present in imported content. During export to a file, any LF character may be translated to a CR/LF sequence depending on the operating system convention where the parser is running (for example, on Windows).
XML provides a built-in attribute named xml:space, which takes a value of "preserve" or "default." The value, “preserve” or “collapse” of the XML reserved attribute XML-space is ignored by XML Extensions unless the parser acts on this attribute. The value "preserve" specifies that whitespace in an element should be preserved. The value "default" specifies that leading and trailing whitespace may be removed and embedded whitespace may be normalized to a single space wherever it occurs. The value "default" is the default treatment of whitespace in XML and is generally not changed unless one is trying to produce poetry or other special output.
When using XSLT stylesheets, the xsl:strip-space and xsl:preserve-space elements indicate how whitespace should be handled while transforming a document. Preserving whitespace is the default, but tools that generate XSLT stylesheets might insert xsl:strip-space elements.
Be aware that when documents are transformed to HTML for display by a browser, many browsers strip whitespace as they are allowed to do. Displaying data in tables is generally necessary to align data in columns rather than using whitespace as it is generally done in COBOL report output.