com.ebmwebsourcing.easycommons.xml
Class XMLPrettyPrinter

java.lang.Object
  extended by com.ebmwebsourcing.easycommons.xml.XMLPrettyPrinter

public class XMLPrettyPrinter
extends java.lang.Object

An util class to prettify XML document

Author:
ofabre - EBM WebSourcing

Constructor Summary
XMLPrettyPrinter()
           
 
Method Summary
static java.lang.String getEncoding(org.w3c.dom.Document xmlDocument)
           
static javax.xml.transform.Transformer getTransformer(javax.xml.transform.Source stylesheetSource)
          Get a transformer from a stylesheet source
static void prettify(java.io.InputStream in, java.io.OutputStream out)
          Prettify the xml input stream into the output stream.
static void prettify(org.w3c.dom.Node node, java.io.OutputStream out)
          Prettify the node into the output stream.
static void prettify(org.w3c.dom.Node node, java.io.OutputStream out, java.lang.String encoding)
          Prettify the node into the output stream.
static java.lang.String prettyPrint(org.w3c.dom.Document xmlDocument)
          parse the xml Document and return it pretty-printed (with correct indentations, etc..).
static java.lang.String prettyPrint(org.w3c.dom.Element node)
          parse the xml Document and return it pretty-printed (with correct indentations, etc..).
static java.lang.String prettyPrint(org.w3c.dom.Node node)
          parse the xml Document and return it pretty-printed (with correct indentations, etc..).
static java.lang.String prettyPrint(org.w3c.dom.Node xmlDocument, java.lang.String encoding)
          parse the xml String and return it pretty-printed (with correct indentations, etc..)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLPrettyPrinter

public XMLPrettyPrinter()
Method Detail

prettyPrint

public static java.lang.String prettyPrint(org.w3c.dom.Node xmlDocument,
                                           java.lang.String encoding)
parse the xml String and return it pretty-printed (with correct indentations, etc..)

Parameters:
xmlDocument - the xml document to pretty print. Must be non null
encoding - the encoding to use
Returns:
printed string if no error occurs. If an error occurs, return an empty String

prettyPrint

public static java.lang.String prettyPrint(org.w3c.dom.Document xmlDocument)
parse the xml Document and return it pretty-printed (with correct indentations, etc..). Use the encoding defined at the parsing or in the document (utf8 is used if no encoding is defined)

Parameters:
xmlDocument - the xml document to pretty print. Must be non null
Returns:
printed string if no error occurs. If an error occurs, return an empty String

prettyPrint

public static java.lang.String prettyPrint(org.w3c.dom.Element node)
parse the xml Document and return it pretty-printed (with correct indentations, etc..). Use the encoding defined at the parsing or in the document (utf8 is used if no encoding is defined)

Parameters:
xmlDocument - the xml document to pretty print. Must be non null
Returns:
printed string if no error occurs. If an error occurs, return an empty String

prettyPrint

public static java.lang.String prettyPrint(org.w3c.dom.Node node)
parse the xml Document and return it pretty-printed (with correct indentations, etc..). Use the encoding defined at the parsing or in the document (utf8 is used if no encoding is defined)

Parameters:
xmlDocument - the xml document to pretty print. Must be non null
Returns:
printed string if no error occurs. If an error occurs, return an empty String

prettify

public static void prettify(org.w3c.dom.Node node,
                            java.io.OutputStream out,
                            java.lang.String encoding)
                     throws java.lang.Exception
Prettify the node into the output stream.

Throws:
java.lang.Exception

prettify

public static void prettify(org.w3c.dom.Node node,
                            java.io.OutputStream out)
                     throws java.lang.Exception
Prettify the node into the output stream.

Throws:
java.lang.Exception

prettify

public static void prettify(java.io.InputStream in,
                            java.io.OutputStream out)
                     throws java.lang.Exception
Prettify the xml input stream into the output stream.

Throws:
java.lang.Exception

getTransformer

public static javax.xml.transform.Transformer getTransformer(javax.xml.transform.Source stylesheetSource)
                                                      throws javax.xml.transform.TransformerConfigurationException
Get a transformer from a stylesheet source

Parameters:
stylesheetSource - a stylesheet source
Throws:
javax.xml.transform.TransformerConfigurationException - if there is transformer configuration error

getEncoding

public static java.lang.String getEncoding(org.w3c.dom.Document xmlDocument)


Copyright © 2012 Petals Link. All Rights Reserved.