26. label
Prev | Chapter 5. Content objects | Next

## 26. label

label(`key`, `value`, ..., `key`, `value`)

Inserts in generated content the value of specified attribute or XPath expression.

### Difference with standard construct attr() and with extension xpath():

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

Unlike xpath() and attr(), label() is automatically updated when the document is modified.

For efficiency reasons, the update of label(xpath, `XPath_expression`) is delayed until the editing context changes.

Key | Value | Default | Description
--- | --- | --- | ---
attribute | Qualified name of an attribute of the element which is the target of the rule | No default One of attribute or xpath must be specified. | Display the value of this attribute as styled text.
xpath | Literal string specifying an XPath expression using the target of the rule as its context node | No default One of attribute or xpath must be specified. | Display the value of this XPath expression as styled text.

`Key`, `value`, ..., `key`, `value` may also specify style parameters.

XHTML examples:

    p.msg:before {
        content: label(attribute, title,
                       text-decoration, underline);
        display: marker;
    }

    a.showtarget {
        content: icon(pop-right)
                 label(xpath, "//a[@name = substring-after(current()/@href, '#')]",
                       text-decoration, underline);
    }

    caption.formal:before {
        content: "Table "
                 label(xpath, "1 + count(../preceding::table[caption])")
                 ": ";
        display: inline;
    }

See also indicator which is similar to `label` except that `indicator` rendered using a set of images rather than text.

Prev | Up | Next
25. image-viewport | Home | 27. list