XPath: oxy_xpath() Function
This function is used to evaluate XPath expressions.
- Syntax:
- 
            oxy_xpath ( XPathExpression [, processChangeMarkers , value ] [, evaluate , value ])It evaluates the given XPath 3.1 expression using the latest Saxon XSLT processor bundled with the application and returns the result. XPath expressions that depend on the cursor location can be successfully evaluated only when the cursor is located in the actual XML content. The parameters of the function are as follows:- A required expressionparameter, which is the XPath expression to be evaluated.
- An optional processChangeMarkersparameter, followed by its value, which can be eithertrueorfalse(default value). When you set the parameter totrue, the function returns the resulting text with all the change markers accepted (delete changes are removed and insert changes are preserved).
- An optional evaluateparameter, followed by its value, which can be one of the following:- dynamic - Evaluates the XPath
                      each time there is a change in the document. This is the default evaluation
                        value.Important:If the edited XML document is large, using dynamic XPath evaluation may induce performance issues while editing the content.
- dynamic-once - Separately evaluates the XPath for each node that matches the CSS selector. It will not re-evaluate the expression when changes are made to other nodes in the document. This will lead to improved performance, but the displayed content may not be updated to reflect the actual document content.
- static - If the same XPath is evaluated on several nodes, the result for the first evaluation will be used for all other matches. Use this only if the XPath does not contain a relationship with the node on which the CSS property is evaluated. This will lead to improved performance, but the static displayed content may not be updated to reflect the actual document content.
 
- dynamic - Evaluates the XPath
                      each time there is a change in the document. This is the default evaluation
                        value.
 
- A required 
When XPath expressions are evaluated, the entities and
        
    <xi:include> elements are replaced with the actual content that is
      referenced. For example, consider the following code
      snippet:<article>
  <xi:include href="section1.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</article><section>
  <p>Referenced content</p>
</section>Example: oxy_xpath Function
The following example counts the number of words from a paragraph (including tracked changes) and displays the
      result in front of
      it:
      para:before{ 
  content: 
   concat("|Number of words:", 
    oxy_xpath(
        "count(tokenize(normalize-space(string-join(text(), '')), ' '))",
        processChangeMarkers,
       true),
    "| "); 
}The 
      oxy_xpath() function supports editor variables, as in
        the following
        example:* {
    content: 
    oxy_concat("Result: ", 
        oxy_xpath('count(collection("${cfdu}/?select=*.xml"))')
    );
}You can split the XPath expression on multiple lines by adding a
        backslash before each new
        line:
  * {
    content: oxy_xpath('count(\
                     collection(\
                        "${cfdu}/?select=*.xml"))')
}