|Editing Documents / Editing XML Documents|
In structured markup languages, the whitespace between elements that is created using the Space bar, Tab or multiple line breaks is not recognized by the parsing tools. Often this means that when structured markup documents are opened, they are arranged as one long, unbroken line, that seems to be a single paragraph.
While this is a perfectly acceptable practice, it makes editing difficult and increases the likelihood of errors being introduced. It also makes the identification of exact error positions difficult. Formatting and Indenting, also called Pretty Print, enables such documents to be neatly arranged, in a manner that is consistent and promotes easier reading on screen and in print output.
Pretty print is in no way associated with the layout or formatting that will be used in the transformed document. This layout and formatting is supplied by the XSL stylesheet specified at the time of transformation.
To change the indenting of the current selected text see the Indent selection action.
For user preferences related to formatting and indenting like Detect indent on open and Indent on paste see the corresponding Preferences panel.
XML elements can be excepted from the reformatting performed by the pretty-print operation by including them in the Preserve space elements (XPath) list. That means that when the Format and Indent (pretty-print) action encounters in the document an element with the name contained in this list, the whitespace is preserved inside that element. This is useful when most of the elements must be reformatted with the exception of a few ones which are listed here.
For the situation when whitespace should be preserved in most elements with the exception of a few elements, the names of these elements must be added to the Strip space elements (XPath) list.
In addition to simple element names, both the Preserve space elements (XPath) list and the Strip space elements (XPath) one accept a restricted set of XPath expressions to cover a pattern of XML elements with only one expression. The allowed types of expressions are:
the XPath descendant axis can be used only at the beginning of the expression; the namespace prefix can be attached to any namespace, no namespace binding check is performed when applying the pretty-print operation
note the use of the XPath child axis
the descendant axis can be followed by the child axis
The value of an xml:space attribute present in the XML document on which the pretty-print operation is applied always takes precedence over the Preserve space elements (XPath) and the Strip space elements (XPath) lists.