Class XMLUtils

java.lang.Object
de.latlon.ets.core.util.XMLUtils

public final class XMLUtils extends Object
Provides various utility methods for accessing or manipulating XML representations.
  • Method Details

    • writeNodeToString

      public static String writeNodeToString(Node node)
      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

      public static void writeNode(Node node, OutputStream outputStream)
      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

      public static String transformToString(Source source)
    • evaluateXPath2

      public static net.sf.saxon.s9api.XdmValue evaluateXPath2(Source xmlSource, String expr, Map<String,String> nsBindings) throws net.sf.saxon.s9api.SaxonApiException
      Evaluates 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

      public static String resultToString(Result result)
      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.