Package org.apache.empire.xml
Class XMLWriter
java.lang.Object
org.apache.empire.xml.XMLWriter
This class prints out a XML-DOM-Tree to an output stream.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanCanonical output.protected static final org.slf4j.Loggerprotected PrintWriterPrint writer. -
Constructor Summary
ConstructorsConstructorDescriptionXMLWriter(OutputStream outStream) ConstructorXMLWriter(OutputStream outStream, String charsetEncoding) Creates a XML Writer object.Creates a XML Writer object. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidPrints out the DOM-Tree on System.out for debugging purposes.static voiddebugToFile(Document doc, String filename) Prints out the DOM-Tree to a file for debugging purposes.protected StringConverts a string to valid XML-Syntax replacing XML entities.static StringvoidPrints the specified document.voidPrints the specified document.intPrints the specified node recursivelystatic voidsaveAsFile(Document doc, String filename) Saves an XML-Document as file.static voidsetXmlWriterDebugPath(String path) protected Attr[]sortAttributes(NamedNodeMap attrs) Sorts attributes by name.
-
Field Details
-
log
protected static final org.slf4j.Logger log -
out
Print writer. -
canonical
protected boolean canonicalCanonical output.
-
-
Constructor Details
-
XMLWriter
Creates a XML Writer object.- Parameters:
writer- a writer to the output streamcharsetEncoding- encoding type (i.e. utf-8)
-
XMLWriter
public XMLWriter(OutputStream outStream, String charsetEncoding) throws UnsupportedEncodingException Creates a XML Writer object.- Parameters:
outStream- the output streamcharsetEncoding- The name of a supportedcharset- Throws:
UnsupportedEncodingException- If the named encoding is not supported
-
XMLWriter
Constructor- Parameters:
outStream- the output stream
-
-
Method Details
-
debug
Prints out the DOM-Tree on System.out for debugging purposes.- Parameters:
doc- The XML-Document to print
-
debugToFile
Prints out the DOM-Tree to a file for debugging purposes. The file will be truncated if it exists or created if if does not exist.- Parameters:
doc- The XML-Document to printfilename- The name of the file to write the XML-Document to
-
saveAsFile
Saves an XML-Document as file. The file will be truncated if it exists or created if if does not exist.- Parameters:
doc- The XML-Document to printfilename- The name of the file to write the XML-Document to- Throws:
FileWriteException
-
setXmlWriterDebugPath
-
print
Prints the specified node recursively- Parameters:
node- the current node to printlevel- the nesting level used for indenting the output- Returns:
- the node type of this node
-
print
Prints the specified document.- Parameters:
doc- the XML-DOM-Document to print
-
print
Prints the specified document.- Parameters:
doc- the XML-DOM-Document to printstyleSheet- the XML-DOM-Document to print
-
sortAttributes
Sorts attributes by name.- Parameters:
attrs- the unsorted list of attributes- Returns:
- the sorted list of attributes
-
normalize
Converts a string to valid XML-Syntax replacing XML entities.- Parameters:
s- the string to normalize
-
normalize
-