src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java
Print this page
@@ -161,11 +161,12 @@
writer.write(standalone);
writer.write("?>");
if (m_doIndent) {
if (m_standaloneWasSpecified
|| getDoctypePublic() != null
- || getDoctypeSystem() != null) {
+ || getDoctypeSystem() != null
+ || m_isStandalone) {
// We almost never put a newline after the XML
// header because this XML could be used as
// an extenal general parsed entity
// and we don't know the context into which it
// will be used in the future. Only when
@@ -324,10 +325,17 @@
}
writer.write('?');
writer.write('>');
+ /**
+ * Before Xalan 1497, a newline char was printed out if not inside of an
+ * element. The whitespace is not significant if the output is standalone
+ */
+ if (m_elemContext.m_currentElemDepth <= 0 && m_isStandalone)
+ writer.write(m_lineSep, 0, m_lineSepLen);
+
/*
* Don't write out any indentation whitespace now,
* because there may be non-whitespace text after this.
*
* Simply mark that at this point if we do decide