Community
Participate
Working Groups
Hi, Some XPath functions always returns the same result, especially if you start from the root element or if you have a generic functions such as "//". For example I consider the following function "//Interface" beeing static. Meaning it will always return the same result for a given model. Putting a cache on this fonction will only consume process the first time it's executed. This cache would be place before the XPath function eval inside "XPathExpressionImpl". In this example the XPath expression is passed to the XPathExpressionImpl constructor : public Object evaluate(Object contextObject) { if (this.expression != null && isStaticExpr(this.expression)) { // Look up cache. if (Cache.getXPathCache(expression) == null) { Cache.getXpathCache().put( expression, node.evalAsObject(new Context(contextObject, variableResolver, annotationManager, functionResolver))); } return Cache.getXPathCache(expression); } else { return node.evalAsObject(new Context(contextObject, variableResolver, annotationManager, functionResolver)); } } Best regards, Jean