XPathTest.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:Camel 作者:
public void testUsingJavaExtensions() throws Exception {
    Object instance = null;

    // we may not have Xalan on the classpath
    try {
        instance = Class.forName("org.apache.xalan.extensions.XPathFunctionResolverImpl").newInstance();
    } catch (Throwable e) {

        log.debug("Could not find Xalan on the classpath so ignoring this test case: " + e);
    }
    if (instance instanceof XPathFunctionResolver) {
        XPathFunctionResolver functionResolver = (XPathFunctionResolver)instance;

        XPathBuilder builder = xpath("java:" + getClass().getName() + ".func(string(/header/value))")
            .namespace("java", "http://xml.apache.org/xalan/java").functionResolver(functionResolver)
            .stringResult();

        String xml = "<header><value>12</value></header>";
        // it can throw the exception if we put the xalan into the test class path
        assertExpression(builder, xml, "modified12");
    }

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号