List of utility methods to do XPath Expression
Boolean | asBoolean(String expression, Node node) Evaluates the specified XPath expression and returns the result as a Boolean. return asBoolean(expression, node, xpath());
|
Long | asLong(String expression, Node node) Evaluates the specified XPath expression and returns the result as a Long. String longString = evaluateAsString(expression, node);
return (isEmptyString(longString)) ? null : Long.valueOf(longString);
|
XPathExpression | compile(String expression) compile return xPath.compile(expression);
|
XPathExpression | compile(String expression) Returns a compiled XPath expression. return compile(expression, (NamespaceContext) null);
|
XPathExpression | compile(String path) compile XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); try { return xpath.compile(path); } catch (Exception e) { throw new RuntimeException(e); |
XPathExpression | compileXPathExpression(String xPathExpression) compile X Path Expression final XPathFactory factory = XPathFactory.newInstance(); final XPath xpath = factory.newXPath(); try { return xpath.compile(xPathExpression); } catch (XPathExpressionException e) { throw new RuntimeException("Internal error, invalid XPATH expression " + xPathExpression, e); |
String | constructXPathForElement(Element inElem, String xPathRest) construct X Path For Element String xpathPart = "/" + inElem.getNodeName(); if (inElem.hasAttribute("id")) { xpathPart = "/" + xpathPart + "[@id = '" + inElem.getAttribute("id") + "']"; } else { xpathPart += "[" + countPrecedingSiblingsOfType(inElem) + "]"; if (inElem.getParentNode() != null) { if (inElem.getParentNode().getNodeType() == Node.ELEMENT_NODE) { return constructXPathForElement((Element) (inElem.getParentNode()), xpathPart + xPathRest); ... |
XPathFactory | createFactory() create Factory return XPathFactory.newInstance();
|
XPath | createNewXPath(@Nullable final NamespaceContext aNamespaceContext) Create a new XPath with the passed namespace context using the default XPathFactory . return createNewXPath(s_aXPathFactory, (XPathVariableResolver) null, (XPathFunctionResolver) null,
aNamespaceContext);
|
Element | createQueryResourcePropertiesCallBody(String aXqueryExpression) Creates the frame for SOAP message body for calling 'QueryResourceProperties' method of a service (getting metadata) DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.newDocument(); String methodName = "QueryResourceProperties"; String parameterName = "QueryExpression"; String nameSpace = "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd"; Element methodElement = doc.createElementNS(nameSpace, methodName); Element parameterElement = doc.createElementNS(nameSpace, parameterName); parameterElement.setAttribute("Dialect", "http://www.w3.org/TR/1999/REC-xpath-19991116"); ... |