javax.xml.xpath.XPath.setXPathFunctionResolver()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中javax.xml.xpath.XPath.setXPathFunctionResolver()方法的一些代码示例,展示了XPath.setXPathFunctionResolver()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XPath.setXPathFunctionResolver()方法的具体详情如下:
包路径:javax.xml.xpath.XPath
类名称:XPath
方法名:setXPathFunctionResolver

XPath.setXPathFunctionResolver介绍

[英]Establish a function resolver.

A NullPointerException is thrown if resolver is null.
[中]建立一个函数解析器。
如果resolver是[$2$],则会抛出NullPointerException

代码示例

代码示例来源:origin: kiegroup/jbpm

public Object evaluate(final ProcessContext context) throws Exception {        
  XPathFactory factory = XPathFactory.newInstance();
  XPath xpathEvaluator = factory.newXPath();
  xpathEvaluator.setXPathFunctionResolver( 
      new  XPathFunctionResolver() {
        public XPathFunction resolveFunction(QName functionName, int arity)

代码示例来源:origin: com.googlecode.totallylazy/totallylazy

private static XPath internalXpath() {
  XPath xPath = XPathFactory.newInstance().newXPath();
  xPath.setXPathFunctionResolver(resolver);
  return xPath;
}

代码示例来源:origin: org.apache.servicemix/servicemix-core

public void setXPathFunctionResolver(XPathFunctionResolver resolver) {
  getXPath().setXPathFunctionResolver(resolver);
}

代码示例来源:origin: org.jooq/joox-java-6

/**
 * Make a given {@link XPath} object "xalan-extension aware", if Xalan is on
 * the classpath.
 */
static final void xalanExtensionAware(XPath xpath) {
  // Load xalan extensions thread-safely for all of jOOX
  if (!xalanExtensionLoaded) {
    synchronized (Util.class) {
      if (!xalanExtensionLoaded) {
        xalanExtensionLoaded = true;
        try {
          xalanNamespaceContext = (NamespaceContext)
            Class.forName("org.apache.xalan.extensions.ExtensionNamespaceContext").newInstance();
          xalanFunctionResolver = (XPathFunctionResolver)
            Class.forName("org.apache.xalan.extensions.XPathFunctionResolverImpl").newInstance();
        }
        catch (Exception ignore) {
        }
      }
    }
  }
  if (xalanNamespaceContext != null && xalanFunctionResolver != null) {
    xpath.setNamespaceContext(xalanNamespaceContext);
    xpath.setXPathFunctionResolver(xalanFunctionResolver);
  }
}

代码示例来源:origin: org.jboss.windup.rules.apps/rules-xml

XmlFile()
{
  this.namespaces.put(WINDUP_NS_PREFIX, WINDUP_NS_URI);
  this.xpathEngine = factory.newXPath();
  final XPathFunctionResolver originalResolver = this.xpathEngine.getXPathFunctionResolver();
  xmlFileFunctionResolver = new XmlFileFunctionResolver(originalResolver);
  this.xpathEngine.setXPathFunctionResolver(xmlFileFunctionResolver);
}

代码示例来源:origin: windup/windup

public XmlFileXpathValidator()
{
  this.namespaces.put(WINDUP_NS_PREFIX, WINDUP_NS_URI);
  this.xpathEngine = factory.newXPath();
  final XPathFunctionResolver originalResolver = this.xpathEngine.getXPathFunctionResolver();
  xmlFileFunctionResolver = new XmlFileFunctionResolver(originalResolver);
  this.xpathEngine.setXPathFunctionResolver(xmlFileFunctionResolver);
}

代码示例来源:origin: com.phloc/phloc-commons-jdk5

/**
 * Create a new {@link XPath} with the passed variable resolver, function
 * resolver and namespace context.
 * 
 * @param aXPathFactory
 *        The XPath factory object to use. May not be <code>null</code>.
 * @param aVariableResolver
 *        Variable resolver to be used. May be <code>null</code>.
 * @param aFunctionResolver
 *        Function resolver to be used. May be <code>null</code>.
 * @param aNamespaceContext
 *        Namespace context to be used. May be <code>null</code>.
 * @return The created non-<code>null</code> {@link XPath} object
 */
@Nonnull
public static XPath createNewXPath (@Nonnull final XPathFactory aXPathFactory,
                  @Nullable final XPathVariableResolver aVariableResolver,
                  @Nullable final XPathFunctionResolver aFunctionResolver,
                  @Nullable final NamespaceContext aNamespaceContext)
{
 ValueEnforcer.notNull (aXPathFactory, "XPathFactory");
 final XPath aXPath = aXPathFactory.newXPath ();
 if (aVariableResolver != null)
  aXPath.setXPathVariableResolver (aVariableResolver);
 if (aFunctionResolver != null)
  aXPath.setXPathFunctionResolver (aFunctionResolver);
 if (aNamespaceContext != null)
  aXPath.setNamespaceContext (aNamespaceContext);
 return aXPath;
}

代码示例来源:origin: com.helger/ph-xml

/**
 * Create a new {@link XPath} with the passed variable resolver, function
 * resolver and namespace context.
 *
 * @param aXPathFactory
 *        The XPath factory object to use. May not be <code>null</code>.
 * @param aVariableResolver
 *        Variable resolver to be used. May be <code>null</code>.
 * @param aFunctionResolver
 *        Function resolver to be used. May be <code>null</code>.
 * @param aNamespaceContext
 *        Namespace context to be used. May be <code>null</code>.
 * @return The created non-<code>null</code> {@link XPath} object
 */
@Nonnull
public static XPath createNewXPath (@Nonnull final XPathFactory aXPathFactory,
                  @Nullable final XPathVariableResolver aVariableResolver,
                  @Nullable final XPathFunctionResolver aFunctionResolver,
                  @Nullable final NamespaceContext aNamespaceContext)
{
 ValueEnforcer.notNull (aXPathFactory, "XPathFactory");
 final XPath aXPath = aXPathFactory.newXPath ();
 if (aVariableResolver != null)
  aXPath.setXPathVariableResolver (aVariableResolver);
 if (aFunctionResolver != null)
  aXPath.setXPathFunctionResolver (aFunctionResolver);
 if (aNamespaceContext != null)
  aXPath.setNamespaceContext (aNamespaceContext);
 return aXPath;
}

代码示例来源:origin: org.jbpm/jbpm-flow

public Object evaluate(final ProcessContext context) throws Exception {        
  XPathFactory factory = XPathFactory.newInstance();
  XPath xpathEvaluator = factory.newXPath();
  xpathEvaluator.setXPathFunctionResolver( 
      new  XPathFunctionResolver() {
        public XPathFunction resolveFunction(QName functionName, int arity)

代码示例来源:origin: net.sf.practicalxml/practicalxml

/**
 *  Compiles the expression, if it has not already been compiled. This is
 *  called from the various <code>evaluate</code> methods, and ensures
 *  that the caller has completely configured the wrapper prior to use.
 */
private void compileIfNeeded()
{
  if (_compiled != null)
    return;
  try
  {
    XPathFactory fact = null;
    synchronized (XPathFactory.class)
    {
      fact = XPathFactory.newInstance();
    }
    XPath xpath = fact.newXPath();
    xpath.setNamespaceContext(_nsResolver);
    xpath.setXPathVariableResolver(new MyVariableResolver());
    xpath.setXPathFunctionResolver(_functions);
    _compiled = xpath.compile(_expr);
  }
  catch (XPathExpressionException ee)
  {
    throw new XmlException("unable to compile: " + _expr, ee);
  }
}

代码示例来源:origin: net.avcompris.commons/avc-binding-dom

.setXPathFunctionResolver(new javax.xml.xpath.XPathFunctionResolver() {

代码示例来源:origin: in.jlibs/jlibs-examples

xpathObj.setXPathFunctionResolver(testCase.functionResolver);
xpathObj.setNamespaceContext(testCase.nsContext);

代码示例来源:origin: wso2/wso2-synapse

public synchronized String evaluateDOMXPath(MessageContext synCtx) throws XPathExpressionException {
  OMElement element = synCtx.getEnvelope().getBody().getFirstElement();
  OMElement doomElement;
  if (element == null) {
    doomElement = new DOMSOAPFactory().createOMElement(new QName(""));
  } else {
    doomElement = convertToDOOM(element);
  }
  domXpath.setNamespaceContext(domNamespaceMap);
  domXpath.setXPathFunctionResolver(new GetPropertyFunctionResolver(synCtx));
  domXpath.setXPathVariableResolver(new DOMSynapseXPathVariableResolver(this.getVariableContext(), synCtx));
  /* Compile the original expression again with Saxon to be evaluated with XPath 2.0 */
  XPathExpression expr = domXpath.compile(getExpression());
  Object result = expr.evaluate(doomElement);
  if (result != null) {
    return result.toString();
  }
  return null;
}

代码示例来源:origin: org.jboss.soa.bpel/riftsaw-bpel-runtime

JaxpVariableResolver varResolver = new JaxpVariableResolver(ctx, oxpath20, ((XPathFactoryImpl) _xpf).getConfiguration());
XPath xpe = _xpf.newXPath();
xpe.setXPathFunctionResolver(funcResolver);
xpe.setXPathVariableResolver(varResolver);
xpe.setNamespaceContext(oxpath20.namespaceCtx);

代码示例来源:origin: org.jboss.soa.bpel/riftsaw-bpel-compiler

_compilerContext, out);
XPath xpe = xpf.newXPath();
xpe.setXPathFunctionResolver(funcResolver);
xpe.setXPathVariableResolver(varResolver);
xpe.setNamespaceContext(source.getNamespaceContext());

代码示例来源:origin: org.apache.tuscany.sca/tuscany-assembly-xml

private void readAttachTo(ExternalAttachment attachment,
    XMLStreamReader reader, ProcessorContext context) {
  Monitor monitor = context.getMonitor();
  
  String attachTo = reader.getAttributeValue(null, ATTACH_TO);
  if ( attachTo != null ) {
    try {
      XPath path = xpathHelper.newXPath();
      NamespaceContext nsContext = xpathHelper.getNamespaceContext(attachTo, reader.getNamespaceContext());
      path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(nsContext));                
                   
      attachTo = PolicyXPathFunction.normalize(attachTo,getSCAPrefix(nsContext));
      XPathExpression expression = xpathHelper.compile(path, nsContext, attachTo);
      attachment.setAttachTo(attachTo);
      attachment.setAttachToXPathExpression(expression);
    } catch (XPathExpressionException e) {
      ContributionReadException ce = new ContributionReadException(e);
      error(monitor, "ContributionReadException", attachment, ce);              
    }
  }
  
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

private void readAttachTo(ExternalAttachment attachment,
    XMLStreamReader reader, ProcessorContext context) {
  Monitor monitor = context.getMonitor();
  
  String attachTo = reader.getAttributeValue(null, ATTACH_TO);
  if ( attachTo != null ) {
    try {
      XPath path = xpathHelper.newXPath();
      NamespaceContext nsContext = xpathHelper.getNamespaceContext(attachTo, reader.getNamespaceContext());
      path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(nsContext));                
                   
      attachTo = PolicyXPathFunction.normalize(attachTo,getSCAPrefix(nsContext));
      XPathExpression expression = xpathHelper.compile(path, nsContext, attachTo);
      attachment.setAttachTo(attachTo);
      attachment.setAttachToXPathExpression(expression);
    } catch (XPathExpressionException e) {
      ContributionReadException ce = new ContributionReadException(e);
      error(monitor, "ContributionReadException", attachment, ce);              
    }
  }
  
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-assembly-xml

XPath path = xpathHelper.newXPath();
NamespaceContext nsContext = xpathHelper.getNamespaceContext(attachTo, reader.getNamespaceContext());
path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(nsContext));

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

XPath path = xpathHelper.newXPath();
NamespaceContext nsContext = xpathHelper.getNamespaceContext(attachTo, reader.getNamespaceContext());
path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(nsContext));

相关文章