Java 类javax.xml.xpath.XPathFunctionResolver 实例源码

项目:Camel    文件:XPathTest.java   
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");
    }

}
项目:ph-commons    文件:XPathHelper.java   
/**
 * 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;
}
项目:ph-schematron    文件:PSBoundSchemaCacheKey.java   
public PSBoundSchemaCacheKey (@Nonnull final IReadableResource aResource,
                              @Nullable final String sPhase,
                              @Nullable final IPSErrorHandler aErrorHandler,
                              @Nullable final XPathVariableResolver aVariableResolver,
                              @Nullable final XPathFunctionResolver aFunctionResolver,
                              @Nullable final EntityResolver aEntityResolver)
{
  ValueEnforcer.notNull (aResource, "Resource");

  m_aResource = aResource;
  m_sPhase = sPhase;
  m_aErrorHandler = aErrorHandler;
  m_aVariableResolver = aVariableResolver;
  m_aFunctionResolver = aFunctionResolver;
  m_aEntityResolver = aEntityResolver;
}
项目:mulgara    文件:ExternalFn.java   
/**
 * Look for a function in the registered XPathFunctionResolvers.
 * @param iri The URI of the function to find.
 * @return The requested XPathFunction, or <code>null</code> if not found.
 */
private XPathFunction findFunction(IRI iri, int argCount) {
  String label = iri.toString() + "/" + argCount;
  XPathFunction result = fnCache.get(label);
  if (result == null) {
    QName fnName = iri.getQName();
    if (fnName == null) return null;
    for (XPathFunctionResolver resolver: FunctionResolverRegistry.getFunctionResolverRegistry()) {
      try {
        result = resolver.resolveFunction(fnName, argCount);
        if (result != null) {
          fnCache.put(label, result);
          break;
        }
      } catch (Exception e) {
        // this resolver is unable to handle the given QName
        result = null;
      }
    }
  }
  return result;
}
项目:lolxml-common    文件:XPathEvaluator.java   
public void init(Node ctx, final Map<String, Object> properties, 
        final ReferenceResolver referenceResolver){
    XPathFactory factory = XPathFactory.newInstance();
    xpath = factory.newXPath();
    xpath.setXPathVariableResolver(new XPathVariableResolver(){
        @Override
        public Object resolveVariable(QName variableName) {
            return properties.get(variableName.getLocalPart());
        }
    });
    xpath.setXPathFunctionResolver(new XPathFunctionResolver(){

        @Override
        public XPathFunction resolveFunction(QName name, int arity) {
            if (FUNC_RANDOM.equals(name.getLocalPart())){
                return new XPathFunctionRandom();                                           
            }
            if (FUNC_EVALUATE.equals(name.getLocalPart())){
                return new XPathFunctionEvaluate(referenceResolver);
            }
            return null;
        }
    });
    this.ctx=ctx;
}
项目:OpenJSharp    文件:JAXPExtensionsProvider.java   
public JAXPExtensionsProvider(XPathFunctionResolver resolver,
    boolean featureSecureProcessing, FeatureManager featureManager ) {
    this.resolver = resolver;
    if (featureSecureProcessing &&
            !featureManager.isFeatureEnabled(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION)) {
        this.extensionInvocationDisabled = true;
    }
}
项目:OpenJSharp    文件:XPathImpl.java   
XPathImpl( XPathVariableResolver vr, XPathFunctionResolver fr,
        boolean featureSecureProcessing, boolean useServiceMechanism,
        FeatureManager featureManager) {
    this.origVariableResolver = this.variableResolver = vr;
    this.origFunctionResolver = this.functionResolver = fr;
    this.featureSecureProcessing = featureSecureProcessing;
    this.useServiceMechanism = useServiceMechanism;
    this.featureManager = featureManager;
}
项目:OpenJSharp    文件:XPathImpl.java   
/**
 * <p>Establishes a function resolver.</p>
 *
 * @param resolver XPath function resolver
 */
public void setXPathFunctionResolver(XPathFunctionResolver resolver) {
    if ( resolver == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
                XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
                new Object[] {"XPathFunctionResolver"} );
        throw new NullPointerException( fmsg );
    }
    this.functionResolver = resolver;
}
项目:OpenJSharp    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
        JAXPPrefixResolver prefixResolver,
        XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver ) {
    this(xpath, prefixResolver, functionResolver, variableResolver,
         false, true, new FeatureManager());
}
项目:OpenJSharp    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
        JAXPPrefixResolver prefixResolver,XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver, boolean featureSecureProcessing,
        boolean useServicesMechanism, FeatureManager featureManager ) {
    this.xpath = xpath;
    this.prefixResolver = prefixResolver;
    this.functionResolver = functionResolver;
    this.variableResolver = variableResolver;
    this.featureSecureProcessing = featureSecureProcessing;
    this.useServicesMechanism = useServicesMechanism;
    this.featureManager = featureManager;
}
项目:openjdk-jdk10    文件:JAXPExtensionsProvider.java   
public JAXPExtensionsProvider(XPathFunctionResolver resolver,
    boolean featureSecureProcessing, JdkXmlFeatures featureManager ) {
    this.resolver = resolver;
    if (featureSecureProcessing &&
            !featureManager.getFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION)) {
        this.extensionInvocationDisabled = true;
    }
}
项目:openjdk-jdk10    文件:XPathImpl.java   
XPathImpl(XPathVariableResolver vr, XPathFunctionResolver fr,
        boolean featureSecureProcessing, boolean useServiceMechanism,
        JdkXmlFeatures featureManager) {
    this.origVariableResolver = this.variableResolver = vr;
    this.origFunctionResolver = this.functionResolver = fr;
    this.featureSecureProcessing = featureSecureProcessing;
    this.useServiceMechanism = useServiceMechanism;
    this.featureManager = featureManager;
}
项目:openjdk-jdk10    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
        JAXPPrefixResolver prefixResolver,
        XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver) {
    this(xpath, prefixResolver, functionResolver, variableResolver,
         false, true, new JdkXmlFeatures(false));
}
项目:openjdk-jdk10    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
        JAXPPrefixResolver prefixResolver,XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver, boolean featureSecureProcessing,
        boolean useServiceMechanism, JdkXmlFeatures featureManager) {
    this.xpath = xpath;
    this.prefixResolver = prefixResolver;
    this.functionResolver = functionResolver;
    this.variableResolver = variableResolver;
    this.featureSecureProcessing = featureSecureProcessing;
    this.useServiceMechanism = useServiceMechanism;
    this.featureManager = featureManager;
}
项目:openjdk9    文件:JAXPExtensionsProvider.java   
public JAXPExtensionsProvider(XPathFunctionResolver resolver,
    boolean featureSecureProcessing, FeatureManager featureManager ) {
    this.resolver = resolver;
    if (featureSecureProcessing &&
            !featureManager.isFeatureEnabled(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION)) {
        this.extensionInvocationDisabled = true;
    }
}
项目:openjdk9    文件:XPathImpl.java   
XPathImpl(XPathVariableResolver vr, XPathFunctionResolver fr,
        boolean featureSecureProcessing, boolean useServiceMechanism,
        FeatureManager featureManager) {
    this.origVariableResolver = this.variableResolver = vr;
    this.origFunctionResolver = this.functionResolver = fr;
    this.featureSecureProcessing = featureSecureProcessing;
    this.useServiceMechanism = useServiceMechanism;
    this.featureManager = featureManager;
}
项目:openjdk9    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
        JAXPPrefixResolver prefixResolver,
        XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver) {
    this(xpath, prefixResolver, functionResolver, variableResolver,
         false, true, new FeatureManager());
}
项目:openjdk9    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
        JAXPPrefixResolver prefixResolver,XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver, boolean featureSecureProcessing,
        boolean useServiceMechanism, FeatureManager featureManager) {
    this.xpath = xpath;
    this.prefixResolver = prefixResolver;
    this.functionResolver = functionResolver;
    this.variableResolver = variableResolver;
    this.featureSecureProcessing = featureSecureProcessing;
    this.useServiceMechanism = useServiceMechanism;
    this.featureManager = featureManager;
}
项目:lookaside_java-1.8.0-openjdk    文件:JAXPExtensionsProvider.java   
public JAXPExtensionsProvider(XPathFunctionResolver resolver,
    boolean featureSecureProcessing, FeatureManager featureManager ) {
    this.resolver = resolver;
    if (featureSecureProcessing &&
            !featureManager.isFeatureEnabled(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION)) {
        this.extensionInvocationDisabled = true;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:XPathImpl.java   
XPathImpl( XPathVariableResolver vr, XPathFunctionResolver fr,
        boolean featureSecureProcessing, boolean useServiceMechanism,
        FeatureManager featureManager) {
    this.origVariableResolver = this.variableResolver = vr;
    this.origFunctionResolver = this.functionResolver = fr;
    this.featureSecureProcessing = featureSecureProcessing;
    this.useServiceMechanism = useServiceMechanism;
    this.featureManager = featureManager;
}
项目:lookaside_java-1.8.0-openjdk    文件:XPathImpl.java   
/**
 * <p>Establishes a function resolver.</p>
 *
 * @param resolver XPath function resolver
 */
public void setXPathFunctionResolver(XPathFunctionResolver resolver) {
    if ( resolver == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
                XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
                new Object[] {"XPathFunctionResolver"} );
        throw new NullPointerException( fmsg );
    }
    this.functionResolver = resolver;
}
项目:lookaside_java-1.8.0-openjdk    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
        JAXPPrefixResolver prefixResolver,
        XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver ) {
    this(xpath, prefixResolver, functionResolver, variableResolver,
         false, true, new FeatureManager());
}
项目:lookaside_java-1.8.0-openjdk    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
        JAXPPrefixResolver prefixResolver,XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver, boolean featureSecureProcessing,
        boolean useServicesMechanism, FeatureManager featureManager ) {
    this.xpath = xpath;
    this.prefixResolver = prefixResolver;
    this.functionResolver = functionResolver;
    this.variableResolver = variableResolver;
    this.featureSecureProcessing = featureSecureProcessing;
    this.useServicesMechanism = useServicesMechanism;
    this.featureManager = featureManager;
}
项目:javify    文件:XPathImpl.java   
XPathImpl(NamespaceContext namespaceContext,
          XPathVariableResolver variableResolver,
          XPathFunctionResolver functionResolver)
{
  parser = new XPathParser();
  this.namespaceContext = namespaceContext;
  this.variableResolver = variableResolver;
  this.functionResolver = functionResolver;
  reset();
}
项目:javify    文件:FunctionCall.java   
public FunctionCall(XPathFunctionResolver resolver, String name, List<Expr> args)
{
  this.resolver = resolver;
  this.name = name;
  if (args == null)
    this.args = Collections.emptyList();
  else
    this.args = args;
}
项目:Camel    文件:XPathBuilder.java   
/**
 * Creates a new xpath expression as there we no available in the pool.
 * <p/>
 * This implementation must be synchronized to ensure thread safety, as this XPathBuilder instance may not have been
 * started prior to being used.
 */
protected synchronized XPathExpression createXPathExpression() throws XPathExpressionException, XPathFactoryConfigurationException {
    // ensure we are started
    try {
        start();
    } catch (Exception e) {
        throw new RuntimeExpressionException("Error starting XPathBuilder", e);
    }

    // XPathFactory is not thread safe
    XPath xPath = getXPathFactory().newXPath();

    if (!logNamespaces && LOG.isTraceEnabled()) {
        LOG.trace("Creating new XPath expression in pool. Namespaces on XPath expression: {}", getNamespaceContext().toString());
    } else if (logNamespaces && LOG.isInfoEnabled()) {
        LOG.info("Creating new XPath expression in pool. Namespaces on XPath expression: {}", getNamespaceContext().toString());
    }
    xPath.setNamespaceContext(getNamespaceContext());
    xPath.setXPathVariableResolver(getVariableResolver());

    XPathFunctionResolver parentResolver = getFunctionResolver();
    if (parentResolver == null) {
        parentResolver = xPath.getXPathFunctionResolver();
    }
    xPath.setXPathFunctionResolver(createDefaultFunctionResolver(parentResolver));
    return xPath.compile(text);
}
项目:kc-rice    文件:XPathHelper.java   
/**
 * A utility to extract the WorkflowFunctionResolver from the given XPath instances.  If the XPath instance
 * does not contain a WorkflowFunctionResolver, then this method will throw a WorkflowRuntimeException.
 * 
 * @throws WorkflowRuntimeException if the given XPath instance does not contain a WorklflowFunctionResolver
 */
public static WorkflowFunctionResolver extractFunctionResolver(XPath xPath) {
    XPathFunctionResolver resolver = xPath.getXPathFunctionResolver();
    if (!hasWorkflowFunctionResolver(xPath)) {
        throw new WorkflowRuntimeException("The XPathFunctionResolver on the given XPath instance is not an instance of WorkflowFunctionResolver, was: " + resolver);
    }
    return (WorkflowFunctionResolver)resolver;
}
项目:jvm-stm    文件:XPathImpl.java   
XPathImpl(NamespaceContext namespaceContext,
          XPathVariableResolver variableResolver,
          XPathFunctionResolver functionResolver)
{
  parser = new XPathParser();
  this.namespaceContext = namespaceContext;
  this.variableResolver = variableResolver;
  this.functionResolver = functionResolver;
  reset();
}
项目:jvm-stm    文件:FunctionCall.java   
public FunctionCall(XPathFunctionResolver resolver, String name, List<Expr> args)
{
  this.resolver = resolver;
  this.name = name;
  if (args == null)
    this.args = Collections.emptyList();
  else
    this.args = args;
}
项目:infobip-open-jdk-8    文件:JAXPExtensionsProvider.java   
public JAXPExtensionsProvider(XPathFunctionResolver resolver,
    boolean featureSecureProcessing, FeatureManager featureManager ) {
    this.resolver = resolver;
    if (featureSecureProcessing &&
            !featureManager.isFeatureEnabled(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION)) {
        this.extensionInvocationDisabled = true;
    }
}
项目:infobip-open-jdk-8    文件:XPathImpl.java   
XPathImpl( XPathVariableResolver vr, XPathFunctionResolver fr,
        boolean featureSecureProcessing, boolean useServiceMechanism,
        FeatureManager featureManager) {
    this.origVariableResolver = this.variableResolver = vr;
    this.origFunctionResolver = this.functionResolver = fr;
    this.featureSecureProcessing = featureSecureProcessing;
    this.useServiceMechanism = useServiceMechanism;
    this.featureManager = featureManager;
}
项目:infobip-open-jdk-8    文件:XPathImpl.java   
/**
 * <p>Establishes a function resolver.</p>
 *
 * @param resolver XPath function resolver
 */
public void setXPathFunctionResolver(XPathFunctionResolver resolver) {
    if ( resolver == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
                XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
                new Object[] {"XPathFunctionResolver"} );
        throw new NullPointerException( fmsg );
    }
    this.functionResolver = resolver;
}
项目:infobip-open-jdk-8    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
        JAXPPrefixResolver prefixResolver,
        XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver ) {
    this(xpath, prefixResolver, functionResolver, variableResolver,
         false, true, new FeatureManager());
}
项目:infobip-open-jdk-8    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath,
        JAXPPrefixResolver prefixResolver,XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver, boolean featureSecureProcessing,
        boolean useServicesMechanism, FeatureManager featureManager ) {
    this.xpath = xpath;
    this.prefixResolver = prefixResolver;
    this.functionResolver = functionResolver;
    this.variableResolver = variableResolver;
    this.featureSecureProcessing = featureSecureProcessing;
    this.useServicesMechanism = useServicesMechanism;
    this.featureManager = featureManager;
}
项目:In-the-Box-Fork    文件:XPathImpl.java   
/**
 * <p>Establishes a function resolver.</p>
 *
 * @param resolver XPath function resolver
 */
public void setXPathFunctionResolver(XPathFunctionResolver resolver) {
    if ( resolver == null ) {
        String fmsg = XSLMessages.createXPATHMessage( 
                XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
                new Object[] {"XPathFunctionResolver"} );
        throw new NullPointerException( fmsg );
    }
    this.functionResolver = resolver;
}
项目:In-the-Box-Fork    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(org.apache.xpath.XPath xpath, 
        JAXPPrefixResolver prefixResolver, 
        XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver ) { 
    this.xpath = xpath;
    this.prefixResolver = prefixResolver;
    this.functionResolver = functionResolver;
    this.variableResolver = variableResolver;
    this.featureSecureProcessing = false;
}
项目:In-the-Box-Fork    文件:XPathExpressionImpl.java   
protected XPathExpressionImpl(org.apache.xpath.XPath xpath,
        JAXPPrefixResolver prefixResolver,
        XPathFunctionResolver functionResolver,
        XPathVariableResolver variableResolver,
        boolean featureSecureProcessing ) { 
    this.xpath = xpath;
    this.prefixResolver = prefixResolver;
    this.functionResolver = functionResolver;
    this.variableResolver = variableResolver;
    this.featureSecureProcessing = featureSecureProcessing;
}
项目:ph-commons    文件:XPathHelper.java   
/**
 * Create a new {@link XPath} without any special settings using the default
 * {@link XPathFactory}.
 *
 * @return The created non-<code>null</code> {@link XPath} object
 */
@Nonnull
public static XPath createNewXPath ()
{
  return createNewXPath (s_aXPathFactory,
                         (XPathVariableResolver) null,
                         (XPathFunctionResolver) null,
                         (NamespaceContext) null);
}
项目:ph-commons    文件:XPathHelper.java   
/**
 * Create a new {@link XPath} without any special settings.
 *
 * @param aXPathFactory
 *        The XPath factory object to use. May not be <code>null</code>.
 * @return The created non-<code>null</code> {@link XPath} object
 */
@Nonnull
public static XPath createNewXPath (@Nonnull final XPathFactory aXPathFactory)
{
  return createNewXPath (aXPathFactory,
                         (XPathVariableResolver) null,
                         (XPathFunctionResolver) null,
                         (NamespaceContext) null);
}
项目:ph-commons    文件:XPathHelper.java   
/**
 * Create a new {@link XPath} with the passed namespace context using the
 * default {@link XPathFactory}.
 *
 * @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 (@Nullable final NamespaceContext aNamespaceContext)
{
  return createNewXPath (s_aXPathFactory,
                         (XPathVariableResolver) null,
                         (XPathFunctionResolver) null,
                         aNamespaceContext);
}