37. xpath
Prev | Chapter 5. Content objects | Next

## 37. xpath

xpath(`XPath_expression`)

Generalization of standard construct attr(`attribute_name`). Inserts in generated content the value of `XPath_expression`, an XPath 1.0 expression using the target of the CSS rule (element, comment or processing instruction) at its context node.

Example:

    xpath("id(@linkend)/@xreflabel")

Note that xpath(), like attr(), is evaluated once and this happens when the view of the element is built. This means that in most cases, manually refreshing the view of the element after a change in the document will be needed (use Select → Redraw (Ctrl+L)).

Specifying attr(`foo`) in a CSS rule implicitly creates a dependency between the value of attribute `foo` and the element which is the target of the CSS rule: the view of the element is automatically rebuilt when the value of its attribute `foo` is changed.

Similarly, specifying xpath(`whatever`) in a CSS rule implicitly creates a dependency between the element which is the target of the CSS rule and all its attributes: the view of the element is automatically rebuilt when the value of any of its attributes is changed (which too much or not enough depending on the value of the `whatever` XPath expression!).

See also label().

### Tip

You are not restricted to the standard functions of XPath 1.0. A few XSLT 1.0 functions such as `document()` are also supported, as well as many very useful extension functions documented in Section 1, “Extension functions” in <ttl>XMLmind XML Editor - Commands</ttl>.

Prev | Up | Next
36. value-editor | Home | Chapter 6. Content layouts