public static String prettyPrint(SQLXML xml) throws SQLException {
try {
TransformerFactory transFactory = TransformerFactory.newInstance();
transFactory.setAttribute("indent-number", new Integer(2)); //$NON-NLS-1$
Transformer tf = transFactory.newTransformer();
tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$
tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");//$NON-NLS-1$
tf.setOutputProperty(OutputKeys.INDENT, "yes");//$NON-NLS-1$
tf.setOutputProperty(OutputKeys.METHOD, "xml");//$NON-NLS-1$
tf.setOutputProperty(OutputKeys.STANDALONE, "yes");//$NON-NLS-1$
tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamResult xmlOut = new StreamResult(new BufferedOutputStream(out));
tf.transform(xml.getSource(StreamSource.class), xmlOut);
return out.toString();
} catch (Exception e) {
return xml.getString();
}