在 VTD-XML 中与 AutoPilot 一起使用时,concat() 函数 XPath 评估失败

concat() function XPath Evaluation fails while using with AutoPilot in VTD-XML

使用 VTD-XML 2.11 (Java) API,在对简单文本计算 XPath 表达式 concat() 时或 xml 元素,而不是得到 2.0 的结果,它失败并出现以下异常:

Exception in thread "main" 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)

下面是程序:

private static String getElementValue() throws XPathParseException, XPathEvalException, NavException {
    String value = null;

    VTDGen gen = new VTDGen();
    gen.setDoc(data.getBytes());
    gen.parse(false);

    VTDNav nav = gen.getNav();

    AutoPilot pilot = new AutoPilot(nav);
    pilot.selectXPath("concat(\"Hello\", \"Mr Buddy\")");

    int bufferIndex = NO_MATCH;
    if((bufferIndex = pilot.evalXPath()) != NO_MATCH) {
        value= nav.getXPathStringVal();
    }
    System.out.println(value);
} // end of getElementValue()

这是我的代码,它似乎对我来说工作得很好......看看它并告诉我你的想法......

import com.ximpleware.*;
public class concatTest{
    public static void main(String s1[]) throws Exception {
        VTDGen vg= new VTDGen();
        String s = "<users><user><firstName>some </firstName><lastName> one</lastName></user></users>";
        vg.setDoc(s.getBytes());
        vg.parse(false);
        VTDNav vn = vg.getNav();
        AutoPilot ap = new AutoPilot();
        ap.selectXPath("concat('good', ' luck')");
        System.out.println(" concat output ==>"+ap.evalXPathToString());
        ap.selectXPath("concat(/, '')");
        ap.bind(vn);
        System.out.println(" concat output ==>"+ap.evalXPathToString());
    }

}