XML Preferences
To configure the XML Formatting options, open the Preferences dialog box and go to .
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 enabled, the Break long attributes option is automatically disabled. - 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 enabled:
<root> text <parent> <child/> </parent> </root>
Indent inline elements disabled:
<root> text <parent> <child/> </parent> </root>
- Expand empty elements
- The Format and Indent operation outputs empty elements
with a separate closing tag (for example,
<a atr1="v1"></a>
). When not enabled, the same operation represents an empty element in a more compact form (<a atr1="v1"/>
). - 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
- The Format and Indent operation breaks the line before the attribute name.
- 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 asxs
) 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 for which the Format and Indent operation preserves the whitespaces (such as blanks, tabs, and newlines).
- Default space
- List of elements for which the content is 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 for which line breaks will be 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 regards 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 topreserve
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 enabled 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, disable this option.