Package de.latlon.ets.core.util
Class XMLUtils
java.lang.Object
de.latlon.ets.core.util.XMLUtils
Provides various utility methods for accessing or manipulating XML representations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.sf.saxon.s9api.XdmValueEvaluates an XPath 2.0 expression using the Saxon s9api API.static StringresultToString(Result result) Writes the result of a transformation to a String.static StringtransformToString(Source source) static voidwriteNode(Node node, OutputStream outputStream) Writes the content of a DOM node to a byte stream.static StringwriteNodeToString(Node node) Writes the content of a DOM node to a String.
-
Method Details
-
writeNodeToString
Writes the content of a DOM node to a String. An XML declaration is omitted.- Parameters:
node- The node to be serialized.- Returns:
- A String representing the content of the given node.
-
writeNode
Writes the content of a DOM node to a byte stream. An XML declaration is omitted.- Parameters:
node- The node to be serialized.outputStream- The destination OutputStream reference.
-
transformToString
-
evaluateXPath2
public static net.sf.saxon.s9api.XdmValue evaluateXPath2(Source xmlSource, String expr, Map<String, String> nsBindings) throws net.sf.saxon.s9api.SaxonApiExceptionEvaluates an XPath 2.0 expression using the Saxon s9api API.- Parameters:
xmlSource- The XML Source.expr- The XPath expression to be evaluated.nsBindings- A collection of namespace bindings required to evaluate the XPath expression, where each entry maps a namespace URI (key) to a prefix (value); if the prefix is an empty string, it declares the default namespace.- Returns:
- An XdmValue object representing a value in the XDM data model; this is a sequence of zero or more items, where each item is either an atomic value or a node.
- Throws:
net.sf.saxon.s9api.SaxonApiException- If an error occurs while evaluating the expression; this always wraps some other underlying exception.
-
resultToString
Writes the result of a transformation to a String. An XML declaration is always omitted.- Parameters:
result- An object (DOMResult or StreamResult) that holds the result of a transformation, which may be XML or plain text.- Returns:
- A String representing the content of the result; it may be empty if the content could not be read.
-