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");
}
}
java类javax.xml.xpath.XPathFunctionResolver的实例源码
XPathTest.java 文件源码
项目:Camel
阅读 23
收藏 0
点赞 0
评论 0
XPathHelper.java 文件源码
项目:ph-commons
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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;
}
PSBoundSchemaCacheKey.java 文件源码
项目:ph-schematron
阅读 24
收藏 0
点赞 0
评论 0
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;
}
ExternalFn.java 文件源码
项目:mulgara
阅读 19
收藏 0
点赞 0
评论 0
/**
* 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;
}
XPathEvaluator.java 文件源码
项目:lolxml-common
阅读 26
收藏 0
点赞 0
评论 0
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;
}
JAXPExtensionsProvider.java 文件源码
项目:OpenJSharp
阅读 29
收藏 0
点赞 0
评论 0
public JAXPExtensionsProvider(XPathFunctionResolver resolver,
boolean featureSecureProcessing, FeatureManager featureManager ) {
this.resolver = resolver;
if (featureSecureProcessing &&
!featureManager.isFeatureEnabled(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION)) {
this.extensionInvocationDisabled = true;
}
}
XPathImpl.java 文件源码
项目:OpenJSharp
阅读 22
收藏 0
点赞 0
评论 0
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;
}
XPathImpl.java 文件源码
项目:OpenJSharp
阅读 32
收藏 0
点赞 0
评论 0
/**
* <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;
}
XPathExpressionImpl.java 文件源码
项目:OpenJSharp
阅读 33
收藏 0
点赞 0
评论 0
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());
}
XPathExpressionImpl.java 文件源码
项目:OpenJSharp
阅读 44
收藏 0
点赞 0
评论 0
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;
}
JAXPExtensionsProvider.java 文件源码
项目:openjdk-jdk10
阅读 27
收藏 0
点赞 0
评论 0
public JAXPExtensionsProvider(XPathFunctionResolver resolver,
boolean featureSecureProcessing, JdkXmlFeatures featureManager ) {
this.resolver = resolver;
if (featureSecureProcessing &&
!featureManager.getFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION)) {
this.extensionInvocationDisabled = true;
}
}
XPathImpl.java 文件源码
项目:openjdk-jdk10
阅读 26
收藏 0
点赞 0
评论 0
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;
}
XPathExpressionImpl.java 文件源码
项目:openjdk-jdk10
阅读 22
收藏 0
点赞 0
评论 0
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));
}
XPathExpressionImpl.java 文件源码
项目:openjdk-jdk10
阅读 29
收藏 0
点赞 0
评论 0
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;
}
JAXPExtensionsProvider.java 文件源码
项目:openjdk9
阅读 28
收藏 0
点赞 0
评论 0
public JAXPExtensionsProvider(XPathFunctionResolver resolver,
boolean featureSecureProcessing, FeatureManager featureManager ) {
this.resolver = resolver;
if (featureSecureProcessing &&
!featureManager.isFeatureEnabled(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION)) {
this.extensionInvocationDisabled = true;
}
}
XPathImpl.java 文件源码
项目:openjdk9
阅读 30
收藏 0
点赞 0
评论 0
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;
}
XPathExpressionImpl.java 文件源码
项目:openjdk9
阅读 29
收藏 0
点赞 0
评论 0
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());
}
XPathExpressionImpl.java 文件源码
项目:openjdk9
阅读 29
收藏 0
点赞 0
评论 0
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;
}
JAXPExtensionsProvider.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 23
收藏 0
点赞 0
评论 0
public JAXPExtensionsProvider(XPathFunctionResolver resolver,
boolean featureSecureProcessing, FeatureManager featureManager ) {
this.resolver = resolver;
if (featureSecureProcessing &&
!featureManager.isFeatureEnabled(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION)) {
this.extensionInvocationDisabled = true;
}
}
XPathImpl.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 23
收藏 0
点赞 0
评论 0
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;
}
XPathImpl.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 25
收藏 0
点赞 0
评论 0
/**
* <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;
}
XPathExpressionImpl.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 25
收藏 0
点赞 0
评论 0
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());
}
XPathExpressionImpl.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 28
收藏 0
点赞 0
评论 0
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;
}
XPathImpl.java 文件源码
项目:javify
阅读 28
收藏 0
点赞 0
评论 0
XPathImpl(NamespaceContext namespaceContext,
XPathVariableResolver variableResolver,
XPathFunctionResolver functionResolver)
{
parser = new XPathParser();
this.namespaceContext = namespaceContext;
this.variableResolver = variableResolver;
this.functionResolver = functionResolver;
reset();
}
FunctionCall.java 文件源码
项目:javify
阅读 30
收藏 0
点赞 0
评论 0
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;
}
XPathBuilder.java 文件源码
项目:Camel
阅读 32
收藏 0
点赞 0
评论 0
/**
* 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);
}
XPathHelper.java 文件源码
项目:kc-rice
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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;
}
XPathImpl.java 文件源码
项目:jvm-stm
阅读 27
收藏 0
点赞 0
评论 0
XPathImpl(NamespaceContext namespaceContext,
XPathVariableResolver variableResolver,
XPathFunctionResolver functionResolver)
{
parser = new XPathParser();
this.namespaceContext = namespaceContext;
this.variableResolver = variableResolver;
this.functionResolver = functionResolver;
reset();
}
FunctionCall.java 文件源码
项目:jvm-stm
阅读 24
收藏 0
点赞 0
评论 0
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;
}
JAXPExtensionsProvider.java 文件源码
项目:infobip-open-jdk-8
阅读 19
收藏 0
点赞 0
评论 0
public JAXPExtensionsProvider(XPathFunctionResolver resolver,
boolean featureSecureProcessing, FeatureManager featureManager ) {
this.resolver = resolver;
if (featureSecureProcessing &&
!featureManager.isFeatureEnabled(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION)) {
this.extensionInvocationDisabled = true;
}
}