本文整理汇总了Java中javax.xml.xpath.XPathVariableResolver类的典型用法代码示例。如果您正苦于以下问题:Java XPathVariableResolver类的具体用法?Java XPathVariableResolver怎么用?Java XPathVariableResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XPathVariableResolver类属于javax.xml.xpath包,在下文中一共展示了XPathVariableResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
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);
}
}
示例2: createNewXPath
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
/**
* 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;
}
示例3: PSBoundSchemaCacheKey
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
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;
}
示例4: init
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
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;
}
示例5: XPathImpl
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
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;
}
示例6: setXPathVariableResolver
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
/**
* <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;
}
示例7: XPathExpressionImpl
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
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());
}
示例8: XPathImpl
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
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;
}
示例9: XPathExpressionImpl
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
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));
}
示例10: XPathImpl
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
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;
}
示例11: XPathExpressionImpl
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
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());
}
示例12: XPathImpl
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
XPathImpl(NamespaceContext namespaceContext,
XPathVariableResolver variableResolver,
XPathFunctionResolver functionResolver)
{
parser = new XPathParser();
this.namespaceContext = namespaceContext;
this.variableResolver = variableResolver;
this.functionResolver = functionResolver;
reset();
}
示例13: newXPath
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
/**
* 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;
}
示例14: setXPathVariableResolver
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
/**
* <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;
}
示例15: XPathExpressionImpl
import javax.xml.xpath.XPathVariableResolver; //导入依赖的package包/类
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;
}