Expressions in attributes

The syntax of the XPath expression language was carefully crafted to be applicable in a number of circumstances. For example, in some applications of XPath it is useful to be able to add an expression to a URL, and so the syntax needed to be both brief and consistent with the characters allowed in URLs. Similarly, for its use in XSLT, expressions need to be valid attribute values.

Quotation marks often appear in expressions. There must be no conflict between these quotes and the quotes that enclose the attribute value containing the expression. Either single or double quotes can be used, and so when the expression only contains one set of quotes it is a simple matter to avoid using the same quotes as used for the attribute value:

match="id('abc123')/..."


match='id("abc123")/...'

When the expression contains quotes within quotes, however, this solution is not sufficient. Fortunately, the entity references '"' and ''' may also be used.

If an expression contains a left chevron character, '<', this must be avoided by using '&lt;', as the chevron character is not allowed in attribute values:

match="... position() &lt; 6 ..."

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset