title: VTD-XML 2.11 XPath expression count() fails with exception com.ximpleware.XPathEvalException: Function Expr can't eval to node set
body: <p>Using the VTD-XML 2.11 (Java) API, when evaluating the XPath expression <code>count(//b)</code> on the XML document <code>&lt;a&gt;&lt;b/&gt;&lt;b/&gt;&lt;/a&gt;</code>, instead getting a result of <code>2.0</code>, it fails with the following exception:</p>
  
  <pre><code>com.ximpleware.XPathEvalException:  Function Expr can't eval to node set
     at com.ximpleware.FuncExpr.evalNodeSet(FuncExpr.java:1033)
     at com.ximpleware.AutoPilot.evalXPath(AutoPilot.java:876)
     at ...testVTDXMLXPathFunctionCount(TestVTDXMLXPath.java:107)
  </code></pre>
  
  <p>Here is a very simple test case to reproduce the problem:</p>
  
  <pre><code>public void testVTDXMLXPathFunctionCount() throws Exception {
      AutoPilot autoPilot = new AutoPilot();
      try {
          VTDGen document = new VTDGen();
          document.setDoc("&lt;a&gt;&lt;b/&gt;&lt;b/&gt;&lt;/a&gt;".getBytes());
          document.parse(true);
          VTDNav navigator = document.getNav();
          autoPilot.selectXPath("count(//b)");
          autoPilot.bind(navigator);
          int j;
          while ((j = autoPilot.evalXPath()) != -1) {
              System.out.println(navigator.toNormalizedXPathString(j));
          }
      } catch (XPathParseException e) {
          e.printStackTrace();
      } catch (XPathEvalException e) {
          e.printStackTrace();
      } catch (NavException e) {
          e.printStackTrace();
      } finally {
          autoPilot.resetXPath();
      }
  }
  </code></pre>
  
  <p>It looks like the count() function can't be used as the start of an XPath expression with VTD-XML, although it is a valid XPath 1.0 expression?</p>
  
  <p>Any hint would be greatly appreciated.</p>