public static void pretty ( final Source input , final StreamResult output ) { try { // Configure transformer Transformer transformer = TransformerFactory . newInstance ( ) . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . ENCODING , "utf-8" ) ; transformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "no" ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; transformer . setOutputProperty ( "{http://xml.apache.org/xslt}indent-amount" , Integer . toString ( DEFAULT_INDENT ) ) ; transformer . transform ( input , output ) ; } catch ( Throwable t ) { throw new RuntimeException ( "Error during pretty-print operation" , t ) ; } }
Serialise the provided source to the provided destination pretty - printing with the default indent settings