当前位置: 首页>>代码示例>>Java>>正文


Java XPathEvaluator.setXPathVariableResolver方法代码示例

本文整理汇总了Java中net.sf.saxon.xpath.XPathEvaluator.setXPathVariableResolver方法的典型用法代码示例。如果您正苦于以下问题:Java XPathEvaluator.setXPathVariableResolver方法的具体用法?Java XPathEvaluator.setXPathVariableResolver怎么用?Java XPathEvaluator.setXPathVariableResolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.saxon.xpath.XPathEvaluator的用法示例。


在下文中一共展示了XPathEvaluator.setXPathVariableResolver方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getXPathEvaluator

import net.sf.saxon.xpath.XPathEvaluator; //导入方法依赖的package包/类
/**
 * Get a Saxon XPathEvaluator for the purposes of compiling an XPath.
 *
 * @param pBackwardsCompatible If true, turns XPath 1.0 backwards compatibility mode on.
 * @param pNamespaceMap        Optional NamespaceContext for resolution of arbitrary namespaces. Leave null to use default.
 * @return A new single-use XPathEvaluator.
 */
public static XPathEvaluator getXPathEvaluator(boolean pBackwardsCompatible, DynamicNamespaceContext pNamespaceMap) {

  XPathEvaluator lXPE = new XPathEvaluator(SaxonEnvironment.getSaxonConfiguration());
  lXPE.getStaticContext().setBackwardsCompatibilityMode(pBackwardsCompatible);

  //All XPath expressions should use the ThreadLocal variable resolver if one exists - setup the proxy for accessing it here
  lXPE.setXPathVariableResolver(VariableResolverProxy.INSTANCE);

  if (pNamespaceMap == null) {
    lXPE.setNamespaceContext(gFoxNamespaceContext);
  }
  else {
    lXPE.setNamespaceContext(pNamespaceMap);
  }
  return lXPE;
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:24,代码来源:SaxonEnvironment.java

示例2: evaluate

import net.sf.saxon.xpath.XPathEvaluator; //导入方法依赖的package包/类
@Override
public List<Object> evaluate(TestCase testCase, String file) throws Exception{
    XPathFactoryImpl xpf = new XPathFactoryImpl();
    XPathEvaluator xpe = (XPathEvaluator)xpf.newXPath();
    xpe.getConfiguration().setVersionWarning(false);
    ((StandardErrorListener)xpe.getConfiguration().getErrorListener()).setRecoveryPolicy(Configuration.RECOVER_SILENTLY);
    xpe.getStaticContext().setBackwardsCompatibilityMode(true);
    xpe.setXPathVariableResolver(testCase.variableResolver);
    xpe.setXPathFunctionResolver(testCase.functionResolver);
    xpe.setNamespaceContext(testCase.nsContext);
    NodeInfo doc = xpe.getConfiguration().buildDocument(new SAXSource(new InputSource(file)));

    List<Object> results = new ArrayList<Object>(testCase.xpaths.size());
    for(XPathInfo xpathInfo: testCase.xpaths){
        if(xpathInfo.forEach==null)
            results.add(xpe.evaluate(xpathInfo.xpath, doc, xpathInfo.resultType));
        else{
            List<Object> list = new ArrayList<Object>();
            List nodeList = (List)xpe.evaluate(xpathInfo.forEach, doc, XPathConstants.NODESET);
            for(Object context: nodeList)
                list.add(xpe.evaluate(xpathInfo.xpath, context, xpathInfo.resultType));
            results.add(list);
        }
    }
    return results;
}
 
开发者ID:santhosh-tekuri,项目名称:jlibs,代码行数:27,代码来源:SaxonEngine.java


注:本文中的net.sf.saxon.xpath.XPathEvaluator.setXPathVariableResolver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。