Class DOMWriter


  • public class DOMWriter
    extends java.lang.Object
    Traverse a DOM tree in order to print a document that is parsed.
    • Field Detail

      • out

        private java.io.PrintWriter out
      • canonical

        private boolean canonical
      • prettyprint

        private boolean prettyprint
      • writeXMLDeclaration

        private boolean writeXMLDeclaration
      • ignoreWhitespace

        private boolean ignoreWhitespace
      • charsetName

        private java.lang.String charsetName
      • prettyIndent

        private int prettyIndent
      • wroteXMLDeclaration

        private boolean wroteXMLDeclaration
      • rootNode

        private org.w3c.dom.Node rootNode
      • completeNamespaces

        private boolean completeNamespaces
      • currentDefaultNamespace

        private java.lang.String currentDefaultNamespace
    • Constructor Detail

      • DOMWriter

        public DOMWriter​(java.io.Writer w)
      • DOMWriter

        public DOMWriter​(java.io.Writer w,
                         java.lang.String charsetName)
      • DOMWriter

        public DOMWriter​(java.io.OutputStream stream)
      • DOMWriter

        public DOMWriter​(java.io.OutputStream stream,
                         java.lang.String charsetName)
    • Method Detail

      • printNode

        public static java.lang.String printNode​(org.w3c.dom.Node node,
                                                 boolean prettyprint)
        Print a node with explicit prettyprinting. The defaults for all other DOMWriter properties apply.
      • isCanonical

        public boolean isCanonical()
      • setCanonical

        public DOMWriter setCanonical​(boolean canonical)
        Set wheter entities should appear in their canonical form. The default is false.
      • isIgnoreWhitespace

        public boolean isIgnoreWhitespace()
      • setIgnoreWhitespace

        public DOMWriter setIgnoreWhitespace​(boolean ignoreWhitespace)
        Set whether whitespace should be ignored. The default is false.
      • setCompleteNamespaces

        public DOMWriter setCompleteNamespaces​(boolean complete)
        Set wheter subelements should have their namespaces completed. Setting this to false may lead to invalid XML fragments. The default is true.
      • isPrettyprint

        public boolean isPrettyprint()
      • setPrettyprint

        public DOMWriter setPrettyprint​(boolean prettyprint)
        Set wheter element should be indented. The default is false.
      • isWriteXMLDeclaration

        public boolean isWriteXMLDeclaration()
      • setWriteXMLDeclaration

        public DOMWriter setWriteXMLDeclaration​(boolean flag)
        Set wheter the XML declaration should be written. The default is false.
      • print

        public void print​(org.w3c.dom.Node node)
      • printInternal

        private void printInternal​(org.w3c.dom.Node node,
                                   boolean indentEndMarker)
      • getNamespaceURI

        private java.lang.String getNamespaceURI​(java.lang.String prefix,
                                                 org.w3c.dom.Element element,
                                                 org.w3c.dom.Node stopNode)
      • isEndMarkerIndented

        private boolean isEndMarkerIndented​(org.w3c.dom.Node node)
      • sortAttributes

        private org.w3c.dom.Attr[] sortAttributes​(org.w3c.dom.NamedNodeMap attrs)
        Returns a sorted list of attributes.
      • normalize

        public static java.lang.String normalize​(java.lang.String s,
                                                 boolean canonical)
        Normalizes the given string.