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

项目:downloadclient    文件:XML.java   
/**
 * Creates a new XPath with a given namespace context.
 *
 * @param namespaceContext The namespace context to be used or null
 *                         if none should be used.
 * @param resolver         The name space resolver.
 * @return The new XPath
 */
public static final XPath newXPath(
        NamespaceContext namespaceContext,
        XPathVariableResolver resolver
) {
    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    if (namespaceContext != null) {
        xpath.setNamespaceContext(namespaceContext);
    }

    if (resolver != null) {
        xpath.setXPathVariableResolver(resolver);
    }
    return xpath;
}
项目:kc-rice    文件:XPathScheme.java   
public Object load(Property property, final RouteContext context) {
    XPath xpath = XPathHelper.newXPath();
    final BranchService branchService = KEWServiceLocator.getBranchService();
    xpath.setXPathVariableResolver(new XPathVariableResolver() {
        public Object resolveVariable(QName name) {
            LOG.debug("Resolving XPath variable: " + name);
            String value = branchService.getScopedVariableValue(context.getNodeInstance().getBranch(), BranchState.VARIABLE_PREFIX + name.getLocalPart());
            LOG.debug("Resolved XPath variable " + name + " to " + value);
            return value;
        }
    });
    try {
        String docContent = context.getDocument().getDocContent();
        LOG.debug("Executing xpath expression '" + property.locator + "' in doc '" + docContent + "'");
        return xpath.evaluate(property.locator, new InputSource(new StringReader(docContent)), XPathConstants.STRING);
    } catch (XPathExpressionException xpee) {
        throw new RuntimeException("Error evaluating xpath expression '" + property.locator + "'", xpee);
    }
}
项目: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;
}
项目:rice    文件:XPathScheme.java   
public Object load(Property property, final RouteContext context) {
    XPath xpath = XPathHelper.newXPath();
    final BranchService branchService = KEWServiceLocator.getBranchService();
    xpath.setXPathVariableResolver(new XPathVariableResolver() {
        public Object resolveVariable(QName name) {
            LOG.debug("Resolving XPath variable: " + name);
            String value = branchService.getScopedVariableValue(context.getNodeInstance().getBranch(), BranchState.VARIABLE_PREFIX + name.getLocalPart());
            LOG.debug("Resolved XPath variable " + name + " to " + value);
            return value;
        }
    });
    try {
        String docContent = context.getDocument().getDocContent();
        LOG.debug("Executing xpath expression '" + property.locator + "' in doc '" + docContent + "'");
        return xpath.evaluate(property.locator, new InputSource(new StringReader(docContent)), XPathConstants.STRING);
    } catch (XPathExpressionException xpee) {
        throw new RuntimeException("Error evaluating xpath expression '" + property.locator + "'", xpee);
    }
}
项目: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;
}
项目:kuali_rice    文件:XPathScheme.java   
public Object load(Property property, final RouteContext context) {
    XPath xpath = XPathHelper.newXPath();
    final BranchService branchService = KEWServiceLocator.getBranchService();
    xpath.setXPathVariableResolver(new XPathVariableResolver() {
        public Object resolveVariable(QName name) {
            LOG.debug("Resolving XPath variable: " + name);
            String value = branchService.getScopedVariableValue(context.getNodeInstance().getBranch(), BranchState.VARIABLE_PREFIX + name.getLocalPart());
            LOG.debug("Resolved XPath variable " + name + " to " + value);
            return value;
        }
    });
    try {
        String docContent = context.getDocument().getDocContent();
        LOG.debug("Executing xpath expression '" + property.locator + "' in doc '" + docContent + "'");
        return xpath.evaluate(property.locator, new InputSource(new StringReader(docContent)), XPathConstants.STRING);
    } catch (XPathExpressionException xpee) {
        throw new RuntimeException("Error evaluating xpath expression '" + property.locator + "'", xpee);
    }
}
项目: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 variable resolver.</p>
 *
 * @param resolver Variable Resolver
 */
public void setXPathVariableResolver(XPathVariableResolver resolver) {
    if ( resolver == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
                XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
                new Object[] {"XPathVariableResolver"} );
        throw new NullPointerException( fmsg );
    }
    this.variableResolver = 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    文件: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    文件: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    文件: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 variable resolver.</p>
 *
 * @param resolver Variable Resolver
 */
public void setXPathVariableResolver(XPathVariableResolver resolver) {
    if ( resolver == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
                XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
                new Object[] {"XPathVariableResolver"} );
        throw new NullPointerException( fmsg );
    }
    this.variableResolver = 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();
}
项目:jvm-stm    文件:XPathImpl.java   
XPathImpl(NamespaceContext namespaceContext,
          XPathVariableResolver variableResolver,
          XPathFunctionResolver functionResolver)
{
  parser = new XPathParser();
  this.namespaceContext = namespaceContext;
  this.variableResolver = variableResolver;
  this.functionResolver = functionResolver;
  reset();
}
项目: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 variable resolver.</p>
 *
 * @param resolver Variable Resolver
 */
public void setXPathVariableResolver(XPathVariableResolver resolver) {
    if ( resolver == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
                XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
                new Object[] {"XPathVariableResolver"} );
        throw new NullPointerException( fmsg );
    }
    this.variableResolver = 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 variable resolver.</p>
 *
 * @param resolver Variable Resolver
 */
public void setXPathVariableResolver(XPathVariableResolver resolver) {
    if ( resolver == null ) {
        String fmsg = XSLMessages.createXPATHMessage( 
                XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
                new Object[] {"XPathVariableResolver"} );
        throw new NullPointerException( fmsg );
    }
    this.variableResolver = 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);
}
项目:ph-commons    文件:XPathHelper.java   
/**
 * Create a new {@link XPath} with the passed namespace context.
 *
 * @param aXPathFactory
 *        The XPath factory object to use. May not 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 NamespaceContext aNamespaceContext)
{
  return createNewXPath (aXPathFactory,
                         (XPathVariableResolver) null,
                         (XPathFunctionResolver) null,
                         aNamespaceContext);
}
项目:ph-commons    文件:XPathHelper.java   
@Nonnull
@Deprecated
@DevelopersNote ("Typo in name")
public static XPathExpression createNewXPathExpresion (@Nullable final XPathVariableResolver aVariableResolver,
                                                       @Nullable final XPathFunctionResolver aFunctionResolver,
                                                       @Nullable final NamespaceContext aNamespaceContext,
                                                       @Nonnull @Nonempty final String sXPath)
{
  return createNewXPathExpression (aVariableResolver, aFunctionResolver, aNamespaceContext, sXPath);
}
项目:ph-commons    文件:XPathHelper.java   
@Nonnull
@Deprecated
@DevelopersNote ("Typo in name")
public static XPathExpression createNewXPathExpresion (@Nullable final XPathVariableResolver aVariableResolver,
                                                       @Nonnull @Nonempty final String sXPath)
{
  return createNewXPathExpression (aVariableResolver, sXPath);
}
项目:ph-commons    文件:XPathExpressionHelper.java   
@Nullable
public static Object evalXPath (@Nullable final XPathVariableResolver aVariableResolver,
                                @Nullable final XPathFunctionResolver aFunctionResolver,
                                @Nullable final NamespaceContext aNamespaceContext,
                                @Nonnull final String sXPath,
                                @Nonnull final Document aDoc,
                                @Nonnull final QName aReturnType)
{
  return evalXPath (XPathHelper.createNewXPath (aVariableResolver, aFunctionResolver, aNamespaceContext),
                    sXPath,
                    aDoc,
                    aReturnType);
}
项目:ph-commons    文件:XPathExpressionHelper.java   
@Nullable
public static Double evalXPathToNumber (@Nullable final XPathVariableResolver aVariableResolver,
                                        @Nullable final XPathFunctionResolver aFunctionResolver,
                                        @Nullable final NamespaceContext aNamespaceContext,
                                        @Nonnull final String sXPath,
                                        @Nonnull final Document aDoc)
{
  return evalXPathToNumber (XPathHelper.createNewXPath (aVariableResolver, aFunctionResolver, aNamespaceContext),
                            sXPath,
                            aDoc);
}
项目:ph-commons    文件:XPathExpressionHelper.java   
@Nullable
public static String evalXPathToString (@Nullable final XPathVariableResolver aVariableResolver,
                                        @Nullable final XPathFunctionResolver aFunctionResolver,
                                        @Nullable final NamespaceContext aNamespaceContext,
                                        @Nonnull final String sXPath,
                                        @Nonnull final Document aDoc)
{
  return evalXPathToString (XPathHelper.createNewXPath (aVariableResolver, aFunctionResolver, aNamespaceContext),
                            sXPath,
                            aDoc);
}
项目:ph-commons    文件:XPathExpressionHelper.java   
@Nullable
public static Boolean evalXPathToBoolean (@Nullable final XPathVariableResolver aVariableResolver,
                                          @Nullable final XPathFunctionResolver aFunctionResolver,
                                          @Nullable final NamespaceContext aNamespaceContext,
                                          @Nonnull final String sXPath,
                                          @Nonnull final Document aDoc)
{
  return evalXPathToBoolean (XPathHelper.createNewXPath (aVariableResolver, aFunctionResolver, aNamespaceContext),
                             sXPath,
                             aDoc);
}