Reputation: 1121
When I run the following
XPathFactory xpathFactory = XPathFactory.instance();
XPathExpression<Double> query =
xpathFactory.compile("count(1)", Filters.fdouble());
List<Double> result = query.evaluate(new Element("test"));
yet the evaluation fails:
Unable to evaluate expression. See cause Cause: Function :count
That is a bit nonsense example, but I wanted something self contained. What is wrong with this?
Upvotes: 1
Views: 630
Reputation: 18445
If you want to count the number of test
elements, try this;
Element root = new Element("test");
Document doc = new Document(root);
XPathFactory xpathFactory = XPathFactory.instance();
XPathExpression<Double> query = xpathFactory.compile("count(//test)", Filters.fdouble());
List<Double> result = query.evaluate(doc);
Upvotes: 1