Package org.jboss.util.xml
Class DOMWriter
- java.lang.Object
-
- org.jboss.util.xml.DOMWriter
-
public class DOMWriter extends java.lang.ObjectTraverse a DOM tree in order to print a document that is parsed.
-
-
Field Summary
Fields Modifier and Type Field Description private booleancanonicalprivate java.lang.StringcharsetNameprivate booleancompleteNamespacesprivate java.lang.StringcurrentDefaultNamespaceprivate booleanignoreWhitespaceprivate java.io.PrintWriteroutprivate intprettyIndentprivate booleanprettyprintprivate org.w3c.dom.NoderootNodeprivate booleanwriteXMLDeclarationprivate booleanwroteXMLDeclaration
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.StringgetNamespaceURI(java.lang.String prefix, org.w3c.dom.Element element, org.w3c.dom.Node stopNode)booleanisCanonical()private booleanisEndMarkerIndented(org.w3c.dom.Node node)booleanisIgnoreWhitespace()booleanisPrettyprint()booleanisWriteXMLDeclaration()static java.lang.Stringnormalize(java.lang.String s, boolean canonical)Normalizes the given string.voidprint(org.w3c.dom.Node node)private voidprintInternal(org.w3c.dom.Node node, boolean indentEndMarker)static java.lang.StringprintNode(org.w3c.dom.Node node, boolean prettyprint)Print a node with explicit prettyprinting.DOMWritersetCanonical(boolean canonical)Set wheter entities should appear in their canonical form.DOMWritersetCompleteNamespaces(boolean complete)Set wheter subelements should have their namespaces completed.DOMWritersetIgnoreWhitespace(boolean ignoreWhitespace)Set whether whitespace should be ignored.DOMWritersetPrettyprint(boolean prettyprint)Set wheter element should be indented.DOMWritersetWriteXMLDeclaration(boolean flag)Set wheter the XML declaration should be written.private org.w3c.dom.Attr[]sortAttributes(org.w3c.dom.NamedNodeMap attrs)Returns a sorted list of attributes.
-
-
-
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
-
-
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.
-
-