Edit online

XML Preferences

To configure the XML Formatting options, open the Preferences dialog box and go to Editor > Format > XML.

The following options are available:
Format and Indent Section

This section includes the following drop-down boxes:

Preserve empty lines
The Format and Indent operation preserves all empty lines found in the document.
Preserve text as it is
The Format and Indent operation preserves text content as it is, without removing or adding any white space.
Preserve line breaks in attributes
Line breaks found in attribute values are preserved.
Note: When this option is selected, the Break long attributes option is automatically disabled.
Break long attributes
The Format and Indent operation breaks long attribute values.
Indent inline elements

The inline elements are indented on separate lines if they are preceded by white spaces and they follow another element start or end tag. For example:

Original XML:
<root>
  text <parent> <child></child> </parent>
</root>
Indent inline elements selected:
<root> text <parent>
    <child/>
  </parent>
</root>
Indent inline elements not selected:
<root> text <parent> <child/> </parent> </root>
Expand empty elements
If not selected (default), the Format and Indent operation results in an empty XML element being serialized in a compact form (<a atr1="v1"/>). If selected, the same operation results in empty XML elements being serialized in expanded form (for example, <a atr1="v1"></a>).
Notes:
  • When using the Format and Indent operation in Text mode, if the Schema-aware format and indent option is enabled, Oxygen XML Author Eclipse plugin will use information from the associated schema and avoid expanding tags for elements that are defined as empty in the schema.
  • When saving a document in Author mode, if the Schema-aware normalization, format, and indent option in the Schema-Aware preferences page is enabled, Oxygen XML Author Eclipse plugin will use information from the associated schema and avoid expanding tags for elements that are defined as empty in the schema (therefore, text or other elements are not allowed inside them).
Sort attributes
The Format and Indent operation sorts the attributes of an element lexicographically.
Add space before slash in empty elements
Inserts a space character before the trailing / and > of empty elements.
Break line before an attribute name
When selected, the Format and Indent operation always breaks the line before any attribute name in an XML element. By default, the setting is not selected, which means that new lines might still be added before the attribute names but only if the line of content would overflow the maximum line width specified in the Format preferences page.
Element Spacing Section

This section controls how the application handles whitespaces found in XML content. You can Add or Remove element names or simplified XPath expressions in the various tabs.

The XPath expressions can accept multiple attribute conditions and inside each condition you can use AND/OR boolean operators and parentheses to override the priority.

You can use one or more of the following attribute conditions (default attribute values are not taken into account):
  • element[@attr] - Matches all instances of the specified element that include the specified attribute.
  • element[not(@attr)] - Matches all instances of the specified element that do not include the specified attribute.
  • element[@attr = "value"] - Matches all instances of the specified element that include the specified attribute with the given value.
  • element[@attr != "value"] - Matches all instances of the specified element that include the specified attribute and its value is different than the one given.
Example: The following is an example of how you could use multiple boolean operators and parentheses inside an attribute condition:
*[@a and @b or @c and @d]
*[@a and (@b or @c) and @d]
The following are just examples of how simplified XPath expressions might look like:
  • elementName
  • //elementName
  • /elementName1/elementName2/elementName3
  • //xs:localName Note: The namespace prefixes (such as xs) are treated as part of the element name without taking its binding to a namespace into account.
  • //xs:documentation[@lang="en"]
The tabs are as follows:
Preserve space
List of elements that will have the Format and Indent operation preserve the whitespaces (such as blanks, tabs, and newlines).
Default space
List of elements that will have the content normalized (multiple contiguous whitespaces are replaced by a single space), before applying the Format and Indent operation.
Mixed content
The elements from this list are treated as mixed content when applying the Format and Indent operation. The lines are split only when whitespaces are encountered.
Line break
List of elements that will have line breaks inserted, regardless of their content. You can choose to break the line before the element, after, or both.
Schema-aware format and indent
The Format and Indent operation takes the schema information into account with regard to the space preserve, mixed, or element only properties of an element.
Indent Section

Includes the following options:

Indent (when typing) in preserve space elements
Normally, the Preserve space elements (identified by the xml:space attribute set to preserve or by their presence in the Preserve space tab of the Element Spacing list) are ignored by the Format and Indent operation. When this option is selected and you edit one of these elements, its content is formatted.
Indent on paste - sections with number of lines less than 300
When you paste a chunk of text that has fewer than 300 lines, the inserted content is indented. To keep the original indent style of the document you copy content from, deselect this option.