Package ddf.util
Class XPathHelper
java.lang.Object
ddf.util.XPathHelper
- Author:
- Ashraf Barakat, rodgersh
-
Constructor Summary
ConstructorsConstructorDescriptionXPathHelper(String xmlText) XPathHelper(Document document) XPathHelper(Document document, boolean cloneAndNormalize) -
Method Summary
Modifier and TypeMethodDescriptionConvenience method for evaluating xpath expressions that uses as default for itsNamespaceContext, theNamespaceResolverclassevaluate(String xpathExpressionKey, NamespaceContext nsContext) Convenience method for evaluating xpaths that uses as default for itsNamespaceContext, theNamespaceResolverclass.evaluate(String xpathExpressionKey, QName returnType, NamespaceContext nsContext) Retrieve the XML document being worked on by this XPathHelper utility class.static StringPrints a given node as a String.static StringPrints a given node as a Stringstatic StringxmlToString(Node node) Convert an XML Node to a string representation.
-
Constructor Details
-
XPathHelper
public XPathHelper() -
XPathHelper
public XPathHelper(Document document) throws ParserConfigurationException, IOException, SAXException - Parameters:
document- - To parse- Throws:
ParserConfigurationExceptionIOExceptionSAXException
-
XPathHelper
-
XPathHelper
- Parameters:
xmlText-- Throws:
ParserConfigurationExceptionIOExceptionSAXException
-
-
Method Details
-
print
Prints a given node as a String. This is a convenience method that uses the default character encoding.- Parameters:
n- - the node to print as a String- Returns:
- the Node as a String, null if an exception is thrown or null is passed in.
-
print
Prints a given node as a String- Parameters:
n- - the node to print as a Stringencoding- - the character encoding to use for the returned String- Returns:
- the Node as a String, null if an exception is thrown or null is passed in.
-
xmlToString
Convert an XML Node to a string representation.- Parameters:
node- the XML node to be converted- Returns:
- the string representation of the XML node
-
evaluate
Convenience method for evaluating xpath expressions that uses as default for itsNamespaceContext, theNamespaceResolverclass- Parameters:
xpathExpressionKey-- Returns:
- a String of the matched xpath evaluation
- Throws:
XPathExpressionException
-
evaluate
public String evaluate(String xpathExpressionKey, NamespaceContext nsContext) throws XPathExpressionException - Parameters:
xpathExpressionKey-nsContext-- Returns:
- Throws:
XPathExpressionException
-
evaluate
Convenience method for evaluating xpaths that uses as default for itsNamespaceContext, theNamespaceResolverclass. Allows you to also change the how the type is returned.- Parameters:
xpathExpressionKey-returnType-- Throws:
XPathExpressionException
-
evaluate
public Object evaluate(String xpathExpressionKey, QName returnType, NamespaceContext nsContext) throws XPathExpressionException - Parameters:
xpathExpressionKey-returnType-nsContext-- Returns:
- Throws:
XPathExpressionException
-
print
- Parameters:
xmlDeclaration-indent-- Returns:
-
getDocument
Retrieve the XML document being worked on by this XPathHelper utility class.- Returns:
- the XML document
-