--- old/src/com/sun/org/apache/xml/internal/serializer/ToStream.java 2012-03-20 20:30:51.602214600 -0700 +++ new/src/com/sun/org/apache/xml/internal/serializer/ToStream.java 2012-03-20 20:30:50.858449600 -0700 @@ -2393,12 +2393,15 @@ try { + if (shouldIndent() && m_isStandalone) + indent(); + final int limit = start + length; boolean wasDash = false; if (m_cdataTagOpen) closeCDATA(); - if (shouldIndent()) + if (shouldIndent() && !m_isStandalone) indent(); final java.io.Writer writer = m_writer; @@ -2690,7 +2693,7 @@ */ protected boolean shouldIndent() { - return m_doIndent && (!m_ispreserve && !m_isprevtext) && m_elemContext.m_currentElemDepth > 0; + return m_doIndent && (!m_ispreserve && !m_isprevtext) && (m_elemContext.m_currentElemDepth > 0 || m_isStandalone); } /**