KB Article #167807

Libxml warning: XPath complexity limit exceeded

Problem

You receive an error like this:


libxml warning at line 0: XPath complexity limit exceeded
libxml error: xmlXPathCompiledEval: 2 objects left on the stack.
java exception: 
org.xml.sax.SAXException: libxml error xmlXPathCompiledEval: 1621000000 objects left on the stack.
    at com.vordel.jaxprovider.libxml.XPathExpressionImpl.evaluate(Native Method)
    at com.vordel.common.xml.XPathExecutor.runXPathCheck(XPathExecutor.java:120)
    at com.vordel.circuit.contentfiltering.XPathContentProcessor.invoke(XPathContentProcessor.java:73)


Or an error like this:


ERROR  xmlXPathCompiledEval: 1 objects left on the stack.
ERROR  java exception: org.xml.sax.SAXException: libxml error xmlXPathCompiledEval: %d objects left on the stack.
    at com.vordel.jaxprovider.libxml.XPathExpressionImpl.evaluate(Native Method) 
    at com.vordel.common.xml.XPathExecutor.getNodeContent(XPathExecutor.java:140) 
    at com.vordel.circuit.attribute.AttributeExtractXPathProcessor.invoke(AttributeExtractXPathProcessor.java:150)


Resolution

This issue is caused if the number of XPath transformations have exceeded the default value, which is 4096. Complex requests may require a higher limit. To increase the limit, open Policy Studio then navigate to Settings on the Default Settings tab and change the value that says Allowed number of operations to limit XPath transforms.



NOTE: There is no way to programmatically determine the value required. It is recommended to increase the value in 2000 to 5000 increments until you are able to process the document. In newer versions of Java, there are also some unrelated XPath complexity limits, see KB 182545 for more details.