com.ibm.commerce.bi.events.xml

Class XMLUpdateUtil

  • java.lang.Object
    • com.ibm.commerce.bi.events.xml.XMLUpdateUtil


  • public class XMLUpdateUtil
    extends java.lang.Object
    This class contains static utility functions that manipulates a DOM, based on XPath. It also provides general XML utility functions to obtain the defined encoding of an XML file and escape entity references so that they do not get resolved by the XML parser. In addition, it contains helper functions for reading and writing XML files. Users can extend this class and provide addition DOM manipulation fuctions.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String ATTR_NAME_ENC
      The encoding attribute name of an XML declaration.
      static java.lang.String CLASSNAME
      The full class name for this file.
      static java.lang.String COPYRIGHT
      Copyright statement.
    • Constructor Summary

      Constructors 
      Constructor and Description
      XMLUpdateUtil() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static void appendChild(org.w3c.dom.Document doc, org.w3c.dom.NodeList matchedNodeList, org.w3c.dom.Node newNode)
      Appends a child node to the node(s) in a node list.
      static void appendChild(org.w3c.dom.Document doc, java.lang.String path, org.w3c.dom.Node newNode)
      Appends a child node to the node(s) pointed to by the XPath.
      static void appendChild(org.w3c.dom.Document doc, java.lang.String path, org.w3c.dom.NodeList newNodes)
      Appends a set of nodes to the node(s) pointed to by the XPath.
      static void appendString(org.w3c.dom.Document doc, java.lang.String path, java.lang.String value)
      Appends a string to the node(s) pointed to by the XPath.
      static void appendString(org.w3c.dom.NodeList matchedNodeList, java.lang.String value)
      Appends a string to the node(s) in a node list.
      static int countMatches(org.w3c.dom.Document doc, java.lang.String path)
      Returns the number of XPath matches in the DOM tree.
      static void delete(org.w3c.dom.Document doc, java.lang.String path)
      Removes the node(s) pointed to by the XPath.
      static void delete(org.w3c.dom.NodeList matchedNodeList)
      Removes the nodes present in list of nodes indicated by matchedNodeList
      static boolean escapeEntityReferences(java.io.File xmlFile)
      Escapes entity references in an XML file.
      static boolean escapeEntityReferences(java.io.File inputFile, java.io.File outputFile)
      Reads content of an input XML file, escapes entity references, and writes the modified content to another XML file.
      static java.lang.String getEncoding(java.io.File xmlFile)
      Returns the encoding of an XML file.
      static java.lang.String getEscapedAmp()
      Returns the escaped '&' string.
      static java.lang.String getXMLDeclaration(java.io.File xmlFile)
      Returns the XML declaration string in an XML file.
      static void insertAfter(org.w3c.dom.Document doc, org.w3c.dom.NodeList matchedNodeList, org.w3c.dom.Node newNode)
      Inserts a node after a list of node(s).
      static void insertAfter(org.w3c.dom.Document doc, org.w3c.dom.NodeList matchedNodeList, org.w3c.dom.NodeList newNodes)
      Inserts a set of node after a list of node(s).
      static void insertAfter(org.w3c.dom.Document doc, java.lang.String path, org.w3c.dom.Node newNode)
      Inserts a node after the node(s) pointed to by the XPath.
      static void insertAfter(org.w3c.dom.Document doc, java.lang.String path, org.w3c.dom.NodeList newNodes)
      Inserts a set of node after the node(s) pointed to by the XPath.
      static void insertBefore(org.w3c.dom.Document doc, org.w3c.dom.NodeList matchedNodeList, org.w3c.dom.Node newNode)
      Inserts a node before a list of node(s) that match XPath as siblings.
      static void insertBefore(org.w3c.dom.Document doc, org.w3c.dom.NodeList matchedNodeList, org.w3c.dom.NodeList newNodes)
      Inserts a set of node before a list of node(s).
      static void insertBefore(org.w3c.dom.Document doc, java.lang.String path, org.w3c.dom.Node newNode)
      Inserts a node before the node(s) pointed to by the XPath.
      static void insertBefore(org.w3c.dom.Document doc, java.lang.String path, org.w3c.dom.NodeList newNodes)
      Inserts a set of node before the node(s) pointed to by the XPath.
      static void insertCommentAfter(org.w3c.dom.Document doc, org.w3c.dom.NodeList matchedNodeList, java.lang.String comment)
      Inserts a comment after the node(s) pointed to by the XPath.
      static void insertCommentBefore(org.w3c.dom.Document doc, org.w3c.dom.NodeList matchedNodeList, java.lang.String comment)
      Inserts a comment before the node(s) pointed to by the XPath.
      static boolean matches(org.w3c.dom.Document doc, java.lang.String path)
      Checks whether a given XPath matches any node in the DOM tree.
      static org.w3c.dom.Document readXMLFile(java.io.File inputFile)
      Reads an XML file and returns its DOM representation.
      static org.w3c.dom.Document readXMLFile(java.io.File inputFile, java.lang.String encoding)
      Reads an XML file and returns its DOM representation.
      static void replace(org.w3c.dom.Document doc, org.w3c.dom.NodeList matchedNodeList, org.w3c.dom.Node newNode)
      Replace the node(s) in a node list with the new node that match XPath with Nodes.
      static void replace(org.w3c.dom.Document doc, org.w3c.dom.NodeList matchedNodeList, org.w3c.dom.NodeList newNodes)
      Replaces the node(s) in a list with the new list of nodes.
      static void replace(org.w3c.dom.Document doc, java.lang.String path, org.w3c.dom.Node newNode)
      Replaces the node(s) pointed to by the XPath with the new node.
      static void replace(org.w3c.dom.Document doc, java.lang.String path, org.w3c.dom.NodeList newNodes)
      Replaces the node(s) pointed to by the XPath with the new list of nodes.
      static org.w3c.dom.NodeList selectNodeList(org.w3c.dom.Document doc, java.lang.String path)
      Returns a list of matched node(s) pointed to by the XPath.
      static java.lang.String serializeToString(org.w3c.dom.Document doc, org.apache.xml.serialize.OutputFormat of)
      Serializes a DOM to a string.
      static java.lang.String serializeToString(org.w3c.dom.Document doc, java.lang.String encoding, boolean indenting)
      Serializes a DOM to a string.
      static void setAttribute(org.w3c.dom.Document doc, java.lang.String path, java.lang.String name, java.lang.String value)
      Sets an attribute in the node(s) pointed to by the XPath.
      static void setAttribute(org.w3c.dom.NodeList matchedNodeList, java.lang.String name, java.lang.String value)
      Sets an attribute in the node(s) in a node list.
      static boolean unescapeEntityReferences(java.io.File inputFile)
      Unescapes entity references in an XML file.
      static boolean unescapeEntityReferences(java.io.File inputFile, java.io.File outputFile)
      Reads content of an input XML file, unescapes entity references, and writes the modified content to another XML file.
      static void writeXMLFile(org.w3c.dom.Document doc, java.io.File outputFile, org.apache.xml.serialize.OutputFormat of)
      Writes a DOM to a file.
      static void writeXMLFile(org.w3c.dom.Document doc, java.io.File outputFile, java.lang.String encoding, boolean indenting)
      Writes a DOM to a file.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        Copyright statement.
        See Also:
        Constant Field Values
      • CLASSNAME

        public static final java.lang.String CLASSNAME
        The full class name for this file.
      • ATTR_NAME_ENC

        public static final java.lang.String ATTR_NAME_ENC
        The encoding attribute name of an XML declaration.
        See Also:
        Constant Field Values
    • Constructor Detail

      • XMLUpdateUtil

        public XMLUpdateUtil()
    • Method Detail

      • appendChild

        public static void appendChild(org.w3c.dom.Document doc,
                                       org.w3c.dom.NodeList matchedNodeList,
                                       org.w3c.dom.Node newNode)
        Appends a child node to the node(s) in a node list.
        Parameters:
        doc - The DOM tree to be modified.
        matchedNodeList - The list of node(s) to which child node is added.
        newNode - The new node to be added.
      • appendChild

        public static void appendChild(org.w3c.dom.Document doc,
                                       java.lang.String path,
                                       org.w3c.dom.Node newNode)
                                throws javax.xml.transform.TransformerException,
                                       NoXPathMatchException
        Appends a child node to the node(s) pointed to by the XPath.
        Parameters:
        doc - The DOM tree to be modified.
        path - The XPath to the node(s) to which the child node is added.
        newNode - The new node to be added.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • appendChild

        public static void appendChild(org.w3c.dom.Document doc,
                                       java.lang.String path,
                                       org.w3c.dom.NodeList newNodes)
                                throws javax.xml.transform.TransformerException,
                                       NoXPathMatchException
        Appends a set of nodes to the node(s) pointed to by the XPath.
        Parameters:
        doc - The DOM tree to be modified.
        path - The XPath to the node(s) to which the child node is added.
        newNodes - The list of new nodes.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • delete

        public static void delete(org.w3c.dom.NodeList matchedNodeList)
        Removes the nodes present in list of nodes indicated by matchedNodeList
        Parameters:
        matchedNodeList - The list of node(s) to be deleted.
      • delete

        public static void delete(org.w3c.dom.Document doc,
                                  java.lang.String path)
                           throws javax.xml.transform.TransformerException,
                                  NoXPathMatchException
        Removes the node(s) pointed to by the XPath.
        Parameters:
        doc - The DOM tree to be modified.
        path - The XPath to the node(s) to be deleted.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • insertBefore

        public static void insertBefore(org.w3c.dom.Document doc,
                                        org.w3c.dom.NodeList matchedNodeList,
                                        org.w3c.dom.Node newNode)
        Inserts a node before a list of node(s) that match XPath as siblings.
        Parameters:
        doc - The DOM tree to be modified.
        matchedNodeList - The list of node(s) before which the new node is inserted.
        newNode - The new node to be inserted.
      • insertBefore

        public static void insertBefore(org.w3c.dom.Document doc,
                                        java.lang.String path,
                                        org.w3c.dom.Node newNode)
                                 throws javax.xml.transform.TransformerException,
                                        NoXPathMatchException
        Inserts a node before the node(s) pointed to by the XPath.
        Parameters:
        doc - The DOM tree to be modified.
        path - The XPath to the node(s) before which the new node is inserted.
        newNode - The new node to be inserted.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • insertBefore

        public static void insertBefore(org.w3c.dom.Document doc,
                                        org.w3c.dom.NodeList matchedNodeList,
                                        org.w3c.dom.NodeList newNodes)
                                 throws javax.xml.transform.TransformerException,
                                        NoXPathMatchException
        Inserts a set of node before a list of node(s).
        Parameters:
        doc - The DOM tree to be modified.
        matchedNodeList - The list of node(s) before which the new nodes are inserted.
        newNodes - The list of new nodes.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • insertBefore

        public static void insertBefore(org.w3c.dom.Document doc,
                                        java.lang.String path,
                                        org.w3c.dom.NodeList newNodes)
                                 throws javax.xml.transform.TransformerException,
                                        NoXPathMatchException
        Inserts a set of node before the node(s) pointed to by the XPath.
        Parameters:
        doc - The DOM tree to be modified.
        path - The XPath to the node(s) before which the new nodes are inserted.
        newNodes - The list of new nodes.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • insertAfter

        public static void insertAfter(org.w3c.dom.Document doc,
                                       org.w3c.dom.NodeList matchedNodeList,
                                       org.w3c.dom.Node newNode)
                                throws javax.xml.transform.TransformerException
        Inserts a node after a list of node(s).
        Parameters:
        doc - The DOM tree to be modified.
        matchedNodeList - The list of node(s) after which the new node is inserted.
        newNode - The new node to be inserted.
        Throws:
        javax.xml.transform.TransformerException
      • insertAfter

        public static void insertAfter(org.w3c.dom.Document doc,
                                       java.lang.String path,
                                       org.w3c.dom.Node newNode)
                                throws javax.xml.transform.TransformerException,
                                       NoXPathMatchException
        Inserts a node after the node(s) pointed to by the XPath.
        Parameters:
        doc - The DOM tree to be modified.
        path - The XPath to the node after before which the new node is inserted.
        newNode - The new node to be inserted.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • insertAfter

        public static void insertAfter(org.w3c.dom.Document doc,
                                       org.w3c.dom.NodeList matchedNodeList,
                                       org.w3c.dom.NodeList newNodes)
                                throws javax.xml.transform.TransformerException,
                                       NoXPathMatchException
        Inserts a set of node after a list of node(s).
        Parameters:
        doc - The DOM tree to be modified.
        matchedNodeList - The list of node(s) after which the new nodes are inserted.
        newNodes - The list of new nodes.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • insertAfter

        public static void insertAfter(org.w3c.dom.Document doc,
                                       java.lang.String path,
                                       org.w3c.dom.NodeList newNodes)
                                throws javax.xml.transform.TransformerException,
                                       NoXPathMatchException
        Inserts a set of node after the node(s) pointed to by the XPath.
        Parameters:
        doc - The DOM tree to be modified.
        path - The XPath to the node(s) after which the new nodes are inserted.
        newNodes - The list of new nodes.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • replace

        public static void replace(org.w3c.dom.Document doc,
                                   org.w3c.dom.NodeList matchedNodeList,
                                   org.w3c.dom.Node newNode)
                            throws javax.xml.transform.TransformerException
        Replace the node(s) in a node list with the new node that match XPath with Nodes.
        Parameters:
        doc - The DOM tree to be modified.
        matchedNodeList - The list of node(s) to be replaced.
        newNode - The replacement node.
        Throws:
        javax.xml.transform.TransformerException
      • replace

        public static void replace(org.w3c.dom.Document doc,
                                   java.lang.String path,
                                   org.w3c.dom.Node newNode)
                            throws javax.xml.transform.TransformerException,
                                   NoXPathMatchException
        Replaces the node(s) pointed to by the XPath with the new node.
        Parameters:
        doc - The DOM tree to be modified.
        path - The XPath to the node(s) to be replaced.
        newNode - The replacement node.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • replace

        public static void replace(org.w3c.dom.Document doc,
                                   org.w3c.dom.NodeList matchedNodeList,
                                   org.w3c.dom.NodeList newNodes)
                            throws javax.xml.transform.TransformerException,
                                   NoXPathMatchException
        Replaces the node(s) in a list with the new list of nodes.
        Parameters:
        doc - The DOM tree to be modified.
        matchedNodeList - The list of node(s) to be replaced.
        newNodes - The list of replacement nodes.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • replace

        public static void replace(org.w3c.dom.Document doc,
                                   java.lang.String path,
                                   org.w3c.dom.NodeList newNodes)
                            throws javax.xml.transform.TransformerException,
                                   NoXPathMatchException
        Replaces the node(s) pointed to by the XPath with the new list of nodes.
        Parameters:
        doc - The DOM tree to be modified.
        path - The XPath to the node(s) to be replaced.
        newNodes - The list of replacement nodes.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • appendString

        public static void appendString(org.w3c.dom.NodeList matchedNodeList,
                                        java.lang.String value)
                                 throws javax.xml.transform.TransformerException
        Appends a string to the node(s) in a node list. It only works with nodes of type Attribute, CDATA, Comment, and Text.
        Parameters:
        matchedNodeList - The list of node(s) to which value is appended.
        value - The value to be appended.
        Throws:
        javax.xml.transform.TransformerException
      • appendString

        public static void appendString(org.w3c.dom.Document doc,
                                        java.lang.String path,
                                        java.lang.String value)
                                 throws javax.xml.transform.TransformerException,
                                        NoXPathMatchException
        Appends a string to the node(s) pointed to by the XPath. It only works with nodes of type Attribute, CDATA, Comment, and Text.
        Parameters:
        doc - The DOM tree to be modified.
        path - The XPath to the node(s) to which value is appended.
        value - The value to be appended.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • setAttribute

        public static void setAttribute(org.w3c.dom.NodeList matchedNodeList,
                                        java.lang.String name,
                                        java.lang.String value)
                                 throws javax.xml.transform.TransformerException
        Sets an attribute in the node(s) in a node list. If the attribute does not exist, a new attribute is added; Otherwise it is set to the new value.
        Parameters:
        matchedNodeList - The list of element node(s) to which the new attribute is added.
        name - The new attribute name.
        value - The new attribute value.
        Throws:
        javax.xml.transform.TransformerException
      • setAttribute

        public static void setAttribute(org.w3c.dom.Document doc,
                                        java.lang.String path,
                                        java.lang.String name,
                                        java.lang.String value)
                                 throws javax.xml.transform.TransformerException,
                                        NoXPathMatchException
        Sets an attribute in the node(s) pointed to by the XPath. If the attribute does not exist, a new attribute is added; Otherwise it is set to the new value.
        Parameters:
        doc - The DOM tree to be modified.
        path - The XPath to the element node(s) to which the new attribute is added.
        name - The new attribute name.
        value - The new attribute value.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • insertCommentBefore

        public static void insertCommentBefore(org.w3c.dom.Document doc,
                                               org.w3c.dom.NodeList matchedNodeList,
                                               java.lang.String comment)
                                        throws javax.xml.transform.TransformerException,
                                               NoXPathMatchException
        Inserts a comment before the node(s) pointed to by the XPath. If a matched node is of type Attribute, CDATA, or Text, it will insert the comment before its parent node.
        Parameters:
        doc - The DOM tree to be modified.
        matchedNodeList - The list of node(s) before which the comment is added.
        comment - The comment text.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • insertCommentAfter

        public static void insertCommentAfter(org.w3c.dom.Document doc,
                                              org.w3c.dom.NodeList matchedNodeList,
                                              java.lang.String comment)
                                       throws javax.xml.transform.TransformerException,
                                              NoXPathMatchException
        Inserts a comment after the node(s) pointed to by the XPath. If a matched node is of type Attribute, CDATA, or Text, it will insert the comment after its parent node.
        Parameters:
        doc - The DOM tree to be modified.
        matchedNodeList - The list of node(s) after which the comment is added.
        comment - The comment text.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • matches

        public static boolean matches(org.w3c.dom.Document doc,
                                      java.lang.String path)
                               throws javax.xml.transform.TransformerException
        Checks whether a given XPath matches any node in the DOM tree.
        Parameters:
        doc - The DOM tree to be tested against.
        path - The XPath to be searched.
        Returns:
        true if XPath matches; false otherwise.
        Throws:
        javax.xml.transform.TransformerException
      • countMatches

        public static int countMatches(org.w3c.dom.Document doc,
                                       java.lang.String path)
                                throws javax.xml.transform.TransformerException
        Returns the number of XPath matches in the DOM tree.
        Parameters:
        doc - The DOM tree to be tested against.
        path - The XPath to be searched.
        Returns:
        The number of matches that satisfy path in doc.
        Throws:
        javax.xml.transform.TransformerException
      • selectNodeList

        public static org.w3c.dom.NodeList selectNodeList(org.w3c.dom.Document doc,
                                                          java.lang.String path)
                                                   throws javax.xml.transform.TransformerException,
                                                          NoXPathMatchException
        Returns a list of matched node(s) pointed to by the XPath.
        Parameters:
        doc - The document to select node(s) from.
        path - The XPath.
        Returns:
        A list of matched node(s) pointed to by the XPath.
        Throws:
        javax.xml.transform.TransformerException
        NoXPathMatchException
      • getEncoding

        public static java.lang.String getEncoding(java.io.File xmlFile)
                                            throws java.io.IOException
        Returns the encoding of an XML file.
        Parameters:
        xmlFile - The XML file to be parsed.
        Returns:
        The encoding if declared; null otherwise.
        Throws:
        java.io.IOException
      • getXMLDeclaration

        public static java.lang.String getXMLDeclaration(java.io.File xmlFile)
                                                  throws java.io.IOException
        Returns the XML declaration string in an XML file.
        Parameters:
        xmlFile - The XML file to be parsed.
        Returns:
        The XML declaration string if it exists; null otherwise.
        Throws:
        java.io.IOException
      • escapeEntityReferences

        public static boolean escapeEntityReferences(java.io.File xmlFile)
                                              throws java.io.IOException
        Escapes entity references in an XML file.
        Parameters:
        xmlFile - The XML file in which entity references are escaped.
        Returns:
        true if file is modified; false otherwise.
        Throws:
        java.io.IOException
      • escapeEntityReferences

        public static boolean escapeEntityReferences(java.io.File inputFile,
                                                     java.io.File outputFile)
                                              throws java.io.IOException
        Reads content of an input XML file, escapes entity references, and writes the modified content to another XML file.
        Parameters:
        inputFile - The input XML file to get content from.
        outputFile - The output XML file to write modified content to.
        Returns:
        true if file is modified; false otherwise.
        Throws:
        java.io.IOException
      • unescapeEntityReferences

        public static boolean unescapeEntityReferences(java.io.File inputFile)
                                                throws java.io.IOException
        Unescapes entity references in an XML file.
        Parameters:
        inputFile - The XML file in which entity references are unescaped.
        Returns:
        true if file is modified; false otherwise.
        Throws:
        java.io.IOException
      • unescapeEntityReferences

        public static boolean unescapeEntityReferences(java.io.File inputFile,
                                                       java.io.File outputFile)
                                                throws java.io.IOException
        Reads content of an input XML file, unescapes entity references, and writes the modified content to another XML file.
        Parameters:
        inputFile - The input XML file to get content from.
        outputFile - The output XML file to write modified content to.
        Returns:
        true if file is modified; false otherwise.
        Throws:
        java.io.IOException
      • getEscapedAmp

        public static java.lang.String getEscapedAmp()
        Returns the escaped '&' string.
        Returns:
        The escaped '&' string.
      • readXMLFile

        public static org.w3c.dom.Document readXMLFile(java.io.File inputFile)
                                                throws java.io.IOException,
                                                       org.xml.sax.SAXException
        Reads an XML file and returns its DOM representation. Encoding is automatically detected, and is set to UTF-8 if not defined in the XML file.
        Parameters:
        inputFile - The input XML file.
        Returns:
        The DOM representation of the XML file.
        Throws:
        java.io.IOException
        org.xml.sax.SAXException
      • readXMLFile

        public static org.w3c.dom.Document readXMLFile(java.io.File inputFile,
                                                       java.lang.String encoding)
                                                throws java.io.IOException,
                                                       org.xml.sax.SAXException
        Reads an XML file and returns its DOM representation.
        Parameters:
        inputFile - The input file.
        encoding - The encoding to be used for reading the XML file. If set to null, UTF-8 is assumed.
        Returns:
        The DOM representation of the XML file.
        Throws:
        java.io.IOException
        org.xml.sax.SAXException
      • writeXMLFile

        public static void writeXMLFile(org.w3c.dom.Document doc,
                                        java.io.File outputFile,
                                        java.lang.String encoding,
                                        boolean indenting)
                                 throws java.io.IOException
        Writes a DOM to a file.
        Parameters:
        doc - The DOM.
        outputFile - The output XML file.
        encoding - The encoding of the output XML file. If set to null, UTF-8 is assumed.
        indenting - Whether to indent the output XML file.
        Throws:
        java.io.IOException
      • writeXMLFile

        public static void writeXMLFile(org.w3c.dom.Document doc,
                                        java.io.File outputFile,
                                        org.apache.xml.serialize.OutputFormat of)
                                 throws java.io.IOException
        Writes a DOM to a file.
        Parameters:
        doc - The DOM.
        outputFile - The output XML file.
        of - The output format.
        Throws:
        java.io.IOException
      • serializeToString

        public static java.lang.String serializeToString(org.w3c.dom.Document doc,
                                                         java.lang.String encoding,
                                                         boolean indenting)
                                                  throws java.io.IOException
        Serializes a DOM to a string.
        Parameters:
        doc - The DOM.
        encoding - The encoding of the output XML file. If set to null, UTF-8 is assumed.
        indenting - Whether to indent the output XML file.
        Returns:
        The string serialization of the DOM.
        Throws:
        java.io.IOException
      • serializeToString

        public static java.lang.String serializeToString(org.w3c.dom.Document doc,
                                                         org.apache.xml.serialize.OutputFormat of)
                                                  throws java.io.IOException
        Serializes a DOM to a string.
        Parameters:
        doc - The DOM.
        of - The output format.
        Returns:
        The string serialization of the DOM.
        Throws:
        java.io.IOException