List of usage examples for javax.xml.xpath XPathFunctionResolver XPathFunctionResolver
XPathFunctionResolver
From source file:org.apache.camel.builder.xml.XPathBuilder.java
protected XPathFunctionResolver createDefaultFunctionResolver(final XPathFunctionResolver parent) { return new XPathFunctionResolver() { public XPathFunction resolveFunction(QName qName, int argumentCount) { XPathFunction answer = null; if (parent != null) { answer = parent.resolveFunction(qName, argumentCount); }/*from w w w. j a v a 2s. c om*/ if (answer == null) { if (isMatchingNamespaceOrEmptyNamespace(qName.getNamespaceURI(), IN_NAMESPACE) || isMatchingNamespaceOrEmptyNamespace(qName.getNamespaceURI(), DEFAULT_NAMESPACE)) { String localPart = qName.getLocalPart(); if (localPart.equals("body") && argumentCount == 0) { return getBodyFunction(); } if (localPart.equals("header") && argumentCount == 1) { return getHeaderFunction(); } } if (isMatchingNamespaceOrEmptyNamespace(qName.getNamespaceURI(), OUT_NAMESPACE)) { String localPart = qName.getLocalPart(); if (localPart.equals("body") && argumentCount == 0) { return getOutBodyFunction(); } if (localPart.equals("header") && argumentCount == 1) { return getOutHeaderFunction(); } } if (isMatchingNamespaceOrEmptyNamespace(qName.getNamespaceURI(), FUNCTION_NAMESPACE)) { String localPart = qName.getLocalPart(); if (localPart.equals("properties") && argumentCount == 1) { return getPropertiesFunction(); } if (localPart.equals("simple") && argumentCount == 1) { return getSimpleFunction(); } } } return answer; } }; }
From source file:org.apache.hise.utils.TaskXmlUtils.java
/** * Creates {@link XPath} aware of request namespaces. *//*from w ww.j av a 2 s . c o m*/ synchronized XPath createXPathInstance() { XPath xpath = this.xPathFactory.newXPath(); xpath.setNamespaceContext(this.namespaceContext); xpath.setXPathFunctionResolver(new XPathFunctionResolver() { public XPathFunction resolveFunction(QName functionName, int arity) { if (functionName == null) { throw new NullPointerException("The function name cannot be null."); } if (functionName.equals(new QName("http://www.example.org/WS-HT", "getInput", "htd"))) { return new GetXPathFunction(input); } if (functionName.equals(new QName("http://www.example.org/WS-HT", "getOutput", "htd"))) { return new GetXPathFunction(output); } return null; } }); return xpath; }