Edit online

Using XPath in CSS

You can collect and process the document contents using XPath directly from CSS. The following example counts the words from a section and shows it in a static text after the section:

section:after {
  content: "Number of words: " 
            oxy_xpath("count(tokenize(normalize-space(string-join(text(), '')), ' '))");
}
The following is an example of using the oxy_xpath function in a page rule property:
@page {
    @top-center{
      content: oxy_xpath('/book/title');
   }
}

All of the standard XPath 2.0 functions are supported.