6.6.4.9 Escaping

The names of elements and attributes (corresponding to nodes and properties, respectively) within an XPath statement must correspond to the form in which they (notionally) appear in the document view. This means that spaces (and any other non-XML characters) within names must be encoded according to the rules described in 6.4.3 Escaping of Names.

The values of attributes, on the other hand, are not escaped in the XPath usage of document view (as opposed to the export usage, see 6.4.2.5 Multi-value Properties, 6.4.4 Escaping of Values and 6.6.4.10 Searching Multi-value Properties). As a result, string literals in XPath predicates that test those attribute values are not escaped either. They may contain whitespace as well as the characters ampersand (&), less-than (<), greater-than (>), quotation mark (") and apostrophe ('). In XPath the entity references that would be used within an XML document (&lt;, &gt; etc..) are not used. However, the apostrophe (') and quotation mark(") must be escaped according to the standard rules of XPath with regard to string literals: If the literal is delimited by apostrophes, two adjacent apostrophes within the literal are interpreted as a single apostrophe. Similarly, if the literal is delimited by quotation marks, two adjacent quotation marks within the literal are interpreted as one quotation mark.6