last content is


Return type:
Returns true if the last content of the element was one of the specified elements or #DATA, and false otherwise. Replacing is with isnt reverses the result.
proper? content (of element-expression)? (is | isnt) (#DATA | element-name | content-identifier-list)


last content is an element test that evaluates to true in two cases:

  • if the last content of the specified element was one of the elements specified, or
  • if the last content was data content, if #data was specified.

last content evaluates to false otherwise. Replacing is with isnt will reverse these results.

When the keyword proper is specified, the last content is test ignores included elements. If all the subelements of the referenced element have been included elements, and if there was no data content in the element, the test fails.

Note that at the start of an element rule, there is no last content of that element, so any test for it will fail.

The test last content is #data is true in a data-content rule only if the data content is immediately preceded by either an external data entity reference or one or more processing instructions, which are in turn preceded either by data content or by an external data entity reference. It never applies to the content processed by the data-content rule.

The following is an example of a data-content rule that uses the last content is test:

     output "%c"
     output " (again) " 
        when last content is #data

Related Syntax