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


Java XPathEvaluator.setNamespaceContext方法代码示例

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


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

示例3: _createXPathContext

import net.sf.saxon.xpath.XPathEvaluator; //导入方法依赖的package包/类
@Nonnull
private XPath _createXPathContext ()
{
  final MapBasedNamespaceContext aNamespaceContext = getNamespaceContext ();
  final XPath aXPathContext = XPathHelper.createNewXPath (m_aXPathFactory,
                                                          m_aXPathVariableResolver,
                                                          m_aXPathFunctionResolver,
                                                          aNamespaceContext);

  if ("net.sf.saxon.xpath.XPathEvaluator".equals (aXPathContext.getClass ().getName ()))
  {
    // Saxon implementation special handling
    final XPathEvaluator aSaxonXPath = (XPathEvaluator) aXPathContext;

    // Since 9.7.0-4 it must implement NamespaceResolver
    aSaxonXPath.setNamespaceContext (new SaxonNamespaceContext (aNamespaceContext));

    // Wrap the PSErrorHandler to a ErrorListener
    aSaxonXPath.getConfiguration ().setErrorListener (new PSErrorListener (getErrorHandler ()));
  }
  return aXPathContext;
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:23,代码来源:PSXPathBoundSchema.java

示例4: isContained

import net.sf.saxon.xpath.XPathEvaluator; //导入方法依赖的package包/类
private boolean isContained(TestAssertion assertion, String fileLocation)
		throws XPathExpressionException,
		XPathFactoryConfigurationException, XPathException {
	XPathFactory xpathFactory = XPathFactory
			.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON);
	XPathEvaluator xpath = (XPathEvaluator) xpathFactory.newXPath();
	xpath.getConfiguration().setLineNumbering(true);
	xpath.setNamespaceContext(new BpelNamespaceContext());
	XPathExpression expr = xpath.compile(assertion.getTarget());
	InputSource inputSource = new InputSource(
			new File(fileLocation).toString());
	SAXSource saxSource = new SAXSource(inputSource);
	NodeInfo doc = xpath.getConfiguration().buildDocument(saxSource);

	@SuppressWarnings("unchecked")
	List<NodeInfo> matchedLines = (List<NodeInfo>) expr.evaluate(doc,
			XPathConstants.NODESET);
	if (matchedLines.size() > 0) {
		return true;
	}

	return false;
}
 
开发者ID:uniba-dsg,项目名称:bpp,代码行数:24,代码来源:TestRunner.java

示例5: createXPathEvaluator

import net.sf.saxon.xpath.XPathEvaluator; //导入方法依赖的package包/类
private void createXPathEvaluator()
		throws XPathFactoryConfigurationException {
	XPathFactory xpathFactory = XPathFactory
			.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON);
	xpath = (XPathEvaluator) xpathFactory.newXPath();
	xpath.getConfiguration().setLineNumbering(true);
	xpath.setNamespaceContext(new BpmnNamespaceContext());
}
 
开发者ID:uniba-dsg,项目名称:prope,代码行数:9,代码来源:XPathNodeCounter.java

示例6: isContained

import net.sf.saxon.xpath.XPathEvaluator; //导入方法依赖的package包/类
private boolean isContained(AdaptableElement element, String fileLocation) {
	try {
		XPathFactory xpathFactory = XPathFactory
				.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON);
		XPathEvaluator xpath = (XPathEvaluator) xpathFactory.newXPath();
		xpath.getConfiguration().setLineNumbering(true);
		xpath.setNamespaceContext(new BpmnNamespaceContext());
		XPathExpression expr = xpath
				.compile(element.getLocatorExpression());
		InputSource inputSource = new InputSource(
				new File(fileLocation).toString());
		SAXSource saxSource = new SAXSource(inputSource);
		NodeInfo doc = xpath.getConfiguration().buildDocument(saxSource);;

		@SuppressWarnings("unchecked")
		List<NodeInfo> matchedLines = (List<NodeInfo>) expr.evaluate(doc,
				XPathConstants.NODESET);
		if (matchedLines.size() > 0) {
			return true;
		}

		return false;
	} catch (XPathFactoryConfigurationException | XPathExpressionException
			| XPathException e) {
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:uniba-dsg,项目名称:prope,代码行数:29,代码来源:ElementXPathTests.java

示例7: createXPathEvaluator

import net.sf.saxon.xpath.XPathEvaluator; //导入方法依赖的package包/类
private void createXPathEvaluator()
		throws XPathFactoryConfigurationException {
	XPathFactory xpathFactory = XPathFactory
			.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON);
	xpath = (XPathEvaluator) xpathFactory.newXPath();
	xpath.getConfiguration().setLineNumbering(true);
	xpath.setNamespaceContext(new BpelNamespaceContext());
}
 
开发者ID:lenhard,项目名称:pete,代码行数:9,代码来源:XPathNodeCounter.java

示例8: isContained

import net.sf.saxon.xpath.XPathEvaluator; //导入方法依赖的package包/类
private boolean isContained(AdaptableElement element, String fileLocation) {
	try {
		XPathFactory xpathFactory = XPathFactory
				.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON);
		XPathEvaluator xpath = (XPathEvaluator) xpathFactory.newXPath();
		xpath.getConfiguration().setLineNumbering(true);
		xpath.setNamespaceContext(new BpmnNamespaceContext());
		XPathExpression expr = xpath
				.compile(element.getLocatorExpression());
		InputSource inputSource = new InputSource(
				new File(fileLocation).toString());
		SAXSource saxSource = new SAXSource(inputSource);
		NodeInfo doc = xpath.setSource(saxSource);

		@SuppressWarnings("unchecked")
		List<NodeInfo> matchedLines = (List<NodeInfo>) expr.evaluate(doc,
				XPathConstants.NODESET);
		if (matchedLines.size() > 0) {
			return true;
		}

		return false;
	} catch (XPathFactoryConfigurationException | XPathExpressionException
			| XPathException e) {
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:lenhard,项目名称:pete,代码行数:29,代码来源:ElementXPathTests.java

示例9: init

import net.sf.saxon.xpath.XPathEvaluator; //导入方法依赖的package包/类
private void init() throws XPathExpressionException {
    XPathEvaluator xPathEvaluator = new XPathEvaluator();
    xPathEvaluator.setNamespaceContext(XPath2NamespaceContext.INSTANCE);
    xPathExpression = xPathEvaluator.compile(xpathStr);
}
 
开发者ID:yuany,项目名称:en-webmagic,代码行数:6,代码来源:Xpath2Selector.java


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