Altova XMLSpy 2024 Enterprise Edition

Whitespace

Home Prev Top Next

Whitespace characters are the space, tab, carriage return, and linefeed characters. You can switch on the display of whitespace markers (space, tab, and end-of-line (EOL) markers) in the Text View Settings dialog (View | Text View Settings).

 

In an XML document, whitespace characters occur for the following reasons:

 

For XML syntax reasons, usually to delimit XML constructs. Such whitespace is marked yellow in the screenshot below.

Significant whitespace, which occurs within an element, attribute, or processing instruction, and should not be ignored because it has meaning. These are marked blue in the screenshot below.

Insignificant whitespace, which occurs between two elements that have no sibling text nodes. Insignificant whitespace would therefore occur only in elements that are not mixed content. It is usually used for formatting purposes and does not have any meaning. Insignificant whitespace is marked green in the screenshot below.

XSWhitespace

In XMLSpy, whitespace is added when you pretty-print a document (Edit | Pretty-Print). The pretty-print action adds insignificant whitespace in order to format the document so that the document structure is clearly shown. Pretty-printing might also collapse significant whitespace depending on the options that are currently set for pretty-printing (see screenshot below).

xswhitespaceoptions_zoom73

In the pretty-printing options, the following settings affect how whitespace is handled:

 

Significant whitespace can be preserved or collapsed. If this option is set to Collapse, you can, however, still preserve whitespace in specific elements by adding these elements to the Preserve whitespace list.

The Preserve whitespace option enables you to create a list of elements in which all whitespace (both significant and insignificant) is preserved.

If significant whitespace exists in an empty element, then it will be removed if Significant whitespace has been set to Collapse. The setting of the Empty elements option would determine how the empty element is displayed when its significant whitespace has been removed.

 

Note:When you change view between Text View and Grid View, any change that results from pretty-printing will be retained. In the case of a change to/from one of these views to another view, changes will not be applied.

 

© 2017-2023 Altova GmbH