# HG changeset patch # User lana # Date 1332738582 25200 # Node ID 02400887d8c82eab88933df7167d1f8ab826113f # Parent ce6c381830d1be427788ac9b7e8e2acb3aba3947# Parent b3b62f285a2c6b117ec107b9a8b7cb4c0e56bb60 Merge diff -r ce6c381830d1 -r 02400887d8c8 src/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java --- a/src/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java Thu Mar 22 14:11:10 2012 -0700 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java Sun Mar 25 22:09:42 2012 -0700 @@ -67,6 +67,8 @@ public String _encoding = "UTF-8"; public boolean _omitHeader = false; public String _standalone = null; + //see OutputPropertiesFactory.ORACLE_IS_STANDALONE + public boolean _isStandalone = false; public String _doctypePublic = null; public String _doctypeSystem = null; public boolean _indent = false; @@ -671,6 +673,7 @@ if (_doctypeSystem != null) { handler.setDoctype(_doctypeSystem, _doctypePublic); } + handler.setIsStandalone(_isStandalone); } else if (_method.equals("html")) { handler.setIndent(_indent); @@ -693,6 +696,7 @@ } handler.setIndent(_indent); handler.setDoctype(_doctypeSystem, _doctypePublic); + handler.setIsStandalone(_isStandalone); } } diff -r ce6c381830d1 -r 02400887d8c8 src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java --- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Thu Mar 22 14:11:10 2012 -0700 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Sun Mar 25 22:09:42 2012 -0700 @@ -990,6 +990,11 @@ } } } + else if (name.equals(OutputPropertiesFactory.ORACLE_IS_STANDALONE)) { + if (value != null && value.equals("yes")) { + translet._isStandalone = true; + } + } } } @@ -1049,6 +1054,11 @@ handler.setIndentAmount(Integer.parseInt(value)); } } + else if (name.equals(OutputPropertiesFactory.ORACLE_IS_STANDALONE)) { + if (value != null && value.equals("yes")) { + handler.setIsStandalone(true); + } + } else if (name.equals(OutputKeys.CDATA_SECTION_ELEMENTS)) { if (value != null) { StringTokenizer e = new StringTokenizer(value); @@ -1162,6 +1172,7 @@ name.equals(OutputKeys.OMIT_XML_DECLARATION) || name.equals(OutputKeys.STANDALONE) || name.equals(OutputKeys.VERSION) || + name.equals(OutputPropertiesFactory.ORACLE_IS_STANDALONE) || name.charAt(0) == '{'); } diff -r ce6c381830d1 -r 02400887d8c8 src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java --- a/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java Thu Mar 22 14:11:10 2012 -0700 +++ b/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java Sun Mar 25 22:09:42 2012 -0700 @@ -179,6 +179,13 @@ aMethodIsCalled(); } /** + * @see SerializationHandler#setIsStandalone(boolean) + */ + public void setIsStandalone(boolean isStandalone) + { + aMethodIsCalled(); + } + /** * @see SerializationHandler#setOutputFormat(java.util.Properties) */ public void setOutputFormat(Properties format) diff -r ce6c381830d1 -r 02400887d8c8 src/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java --- a/src/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java Thu Mar 22 14:11:10 2012 -0700 +++ b/src/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java Sun Mar 25 22:09:42 2012 -0700 @@ -175,6 +175,26 @@ public static final int S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN = S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL.length(); + /** + * This non-standard, Oracle-impl only property key is used as if OutputKeys.STANDALONE is specified but + * without writing it out in the declaration; It can be used to reverse the change by Xalan patch 1495. + * Since Xalan patch 1495 can cause incompatible behavior, this property is add for application to neutralize + * the effect of Xalan patch 1495 + */ + /** + *

Is Standalone

+ * + * + */ + public static final String ORACLE_IS_STANDALONE = "http://www.oracle.com/xml/is-standalone"; + //************************************************************ //* PRIVATE CONSTANTS //************************************************************ diff -r ce6c381830d1 -r 02400887d8c8 src/com/sun/org/apache/xml/internal/serializer/SerializationHandler.java --- a/src/com/sun/org/apache/xml/internal/serializer/SerializationHandler.java Thu Mar 22 14:11:10 2012 -0700 +++ b/src/com/sun/org/apache/xml/internal/serializer/SerializationHandler.java Sun Mar 25 22:09:42 2012 -0700 @@ -124,5 +124,11 @@ */ public void setDTDEntityExpansion(boolean expand); + /** + * Specify if the output will be treated as a standalone property + * @param isStandalone true if the http://www.oracle.com/xml/is-standalone is set to yes + * @see OutputPropertiesFactory ORACLE_IS_STANDALONE + */ + public void setIsStandalone(boolean b); } diff -r ce6c381830d1 -r 02400887d8c8 src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java --- a/src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java Thu Mar 22 14:11:10 2012 -0700 +++ b/src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java Sun Mar 25 22:09:42 2012 -0700 @@ -143,6 +143,11 @@ protected boolean m_standaloneWasSpecified = false; /** + * Determine if the output is a standalone. + */ + protected boolean m_isStandalone = false; + + /** * Flag to tell if indenting (pretty-printing) is on. */ protected boolean m_doIndent = false; @@ -740,6 +745,16 @@ } /** + * Sets the isStandalone property + * @param isStandalone true if the ORACLE_IS_STANDALONE is set to yes + * @see OutputPropertiesFactory ORACLE_IS_STANDALONE + */ + public void setIsStandalone(boolean isStandalone) + { + m_isStandalone = isStandalone; + } + + /** * This method is used when a prefix/uri namespace mapping * is indicated after the element was started with a * startElement() and before and endElement(). diff -r ce6c381830d1 -r 02400887d8c8 src/com/sun/org/apache/xml/internal/serializer/ToStream.java --- a/src/com/sun/org/apache/xml/internal/serializer/ToStream.java Thu Mar 22 14:11:10 2012 -0700 +++ b/src/com/sun/org/apache/xml/internal/serializer/ToStream.java Sun Mar 25 22:09:42 2012 -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); } /** diff -r ce6c381830d1 -r 02400887d8c8 src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java --- a/src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java Thu Mar 22 14:11:10 2012 -0700 +++ b/src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java Sun Mar 25 22:09:42 2012 -0700 @@ -163,7 +163,8 @@ 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 @@ -326,6 +327,13 @@ 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.