/** * Pretty format the input stream. For instance, the following input: * * <pre> * <div><b>content</b></div> * </pre> * * becomes * * <pre> * <div> * <b>content</b> * </div> * </pre> * * @param is not null * @param os not null * @throws IOException if any or invalid xml content * @see #prettyFormat(InputStream, OutputStream, int, String) */ public static void prettyFormat( InputStream is, OutputStream os ) throws IOException { prettyFormat( is, os, DEFAULT_INDENTATION_SIZE, DEFAULT_LINE_SEPARATOR ); }
try if ( XmlUtil.isXml( f ) )
parser.setInput( reader ); prettyFormatInternal( parser, xmlWriter );
if ( XmlUtil.isXml( f ) )
prettyFormatInternal( parser, xmlWriter );
/** * Pretty format the input reader. For instance, the following input: * * <pre> * <div><b>content</b></div> * </pre> * * becomes * * <pre> * <div> * <b>content</b> * </div> * </pre> * * @param reader not null * @param writer not null * @throws IOException if any or invalid xml content * @see #prettyFormat(Reader, Writer, int, String) * @see ReaderFactory to read an xml content * @see WriterFactory to write an xml content */ public static void prettyFormat( Reader reader, Writer writer ) throws IOException { prettyFormat( reader, writer, DEFAULT_INDENTATION_SIZE, DEFAULT_LINE_SEPARATOR ); }
/** {@inheritDoc} */ public void close() { super.close(); String xdocContent = xdocWriter.toString(); if ( getLog().isDebugEnabled() ) { getLog().debug( "Xdoc content: " + xdocContent ); } StringWriter formattedContent = new StringWriter(); try { XmlUtil.prettyFormat( new StringReader( xdocContent ), formattedContent ); } catch ( IOException e ) { if ( getLog().isDebugEnabled() ) { getLog().error( "IOException: " + e.getMessage(), e ); } formattedContent = new StringWriter(); formattedContent.write( xdocContent ); } xmlWriter.writeMarkup( formattedContent.toString() ); } }
XmlUtil.prettyFormat( r, caw ); w = WriterFactory.newXmlWriter( outputFile ); w.write( caw.toString() );