Class DOM2Writer


  • public class DOM2Writer
    extends java.lang.Object
    This class is a utility to serialize a DOM node as XML. This class uses the DOM Level 2 APIs. The main difference between this class and DOMWriter is that this class generates and prints out namespace declarations.
    Author:
    Matthew J. Duftler (duftler@us.ibm.com), Joseph Kesselman
    • Constructor Summary

      Constructors 
      Constructor Description
      DOM2Writer()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String java2XMLEncoding​(java.lang.String javaEnc)  
      static java.lang.String nodeToString​(org.w3c.dom.Node node)
      Return a string containing this node serialized as XML.
      static java.lang.String nodeToString​(org.w3c.dom.Node node, java.util.Map namespaces)
      Return a string containing this node serialized as XML.
      static void serializeAsXML​(org.w3c.dom.Node node, java.io.Writer writer)
      Serialize this node into the writer as XML.
      static void serializeAsXML​(org.w3c.dom.Node node, java.util.Map namespaces, java.io.Writer writer)
      Serialize this node into the writer as XML.
      static void serializeElementAsDocument​(org.w3c.dom.Element el, java.io.Writer writer)
      Print an XML declaration before serializing the element.
      static void serializeElementAsDocument​(org.w3c.dom.Element el, java.util.Map namespaces, java.io.Writer writer)
      Print an XML declaration before serializing the element.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DOM2Writer

        public DOM2Writer()
    • Method Detail

      • nodeToString

        public static java.lang.String nodeToString​(org.w3c.dom.Node node)
        Return a string containing this node serialized as XML.
      • nodeToString

        public static java.lang.String nodeToString​(org.w3c.dom.Node node,
                                                    java.util.Map namespaces)
        Return a string containing this node serialized as XML. The specified Map associates prefixes with namespace URLs.
      • serializeElementAsDocument

        public static void serializeElementAsDocument​(org.w3c.dom.Element el,
                                                      java.io.Writer writer)
        Print an XML declaration before serializing the element.
      • serializeElementAsDocument

        public static void serializeElementAsDocument​(org.w3c.dom.Element el,
                                                      java.util.Map namespaces,
                                                      java.io.Writer writer)
        Print an XML declaration before serializing the element. The specified Map associates prefixes with namespace URLs.
      • serializeAsXML

        public static void serializeAsXML​(org.w3c.dom.Node node,
                                          java.io.Writer writer)
        Serialize this node into the writer as XML.
      • serializeAsXML

        public static void serializeAsXML​(org.w3c.dom.Node node,
                                          java.util.Map namespaces,
                                          java.io.Writer writer)
        Serialize this node into the writer as XML. The specified Map associates prefixes with namespace URLs.
      • java2XMLEncoding

        public static java.lang.String java2XMLEncoding​(java.lang.String javaEnc)