# HG changeset patch # User Deepak Bhole # Date 1335978760 14400 # Node ID a98d6a2f14a13957841d9836711d5b35ca3146af # Parent 10808c0ac008e29e4084b84ebfa0e8d124333e27# Parent 9de44cdaafe7d5fcc0e8f0bc7c7b4df782e8293e Merge diff -r 10808c0ac008 -r a98d6a2f14a1 .hgtags --- a/.hgtags Wed May 02 15:07:10 2012 +0100 +++ b/.hgtags Wed May 02 13:12:40 2012 -0400 @@ -163,3 +163,13 @@ 3fbd87d50fbf4de3987e36ec5f3e8ce1c383ce3d jdk7u4-b11 b4e5df5b18bb75db15ed97da02e5df086d2c7930 jdk7u4-b12 c51876b27811ba0f6ea3409ba19d357b7400908a icedtea-2.2-branchpoint +7d18bccaec3781f3d4f2d71879f91e257db2f0f7 jdk7u4-b13 +82c5b3166b3194e7348b2a9d146b6760c9a77128 jdk7u4-b14 +36490d49683f7be9d8fbbe1f8eefa1fe9fe550fa jdk7u4-b15 +5c881231f1161fbc4fe86383ce59dd6a1bbe4f8e jdk7u4-b16 +77a453ae863fee408035c8986f7e3bb22b7252cb jdk7u4-b17 +02400887d8c82eab88933df7167d1f8ab826113f jdk7u4-b18 +eb1f8bea2e93a498a9b9f42d33efad564d960407 jdk7u4-b19 +b08fa5f665726f578674c2d93b21b37a4330b16f jdk7u4-b20 +501dd924118687733a875bdbebfba3f98ca38a6c jdk7u4-b30 +a90108a5e1612782c4ab49a3e7de422cce7280d8 jdk7u4-b21 \ No newline at end of file diff -r 10808c0ac008 -r a98d6a2f14a1 src/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java --- a/src/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java Wed May 02 15:07:10 2012 +0100 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java Wed May 02 13:12:40 2012 -0400 @@ -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 10808c0ac008 -r a98d6a2f14a1 src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java --- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Wed May 02 15:07:10 2012 +0100 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Wed May 02 13:12:40 2012 -0400 @@ -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 10808c0ac008 -r a98d6a2f14a1 src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java --- a/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java Wed May 02 15:07:10 2012 +0100 +++ b/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java Wed May 02 13:12:40 2012 -0400 @@ -45,7 +45,7 @@ * @exception DVFactoryException cannot create an instance of the specified * class name or the default class name */ - public static synchronized final DTDDVFactory getInstance() throws DVFactoryException { + public static final DTDDVFactory getInstance() throws DVFactoryException { return getInstance(DEFAULT_FACTORY_CLASS); } @@ -57,19 +57,19 @@ * @exception DVFactoryException cannot create an instance of the specified * class name or the default class name */ - public static synchronized final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException { - + public static final DTDDVFactory getInstance(String factoryClass) throws DVFactoryException { try { // if the class name is not specified, use the default one return (DTDDVFactory) (ObjectFactory.newInstance(factoryClass, true)); - } catch (ClassCastException e) { + } + catch (ClassCastException e) { throw new DVFactoryException("DTD factory class " + factoryClass + " does not extend from DTDDVFactory."); } } // can't create a new object of this class - protected DTDDVFactory(){} + protected DTDDVFactory() {} /** * return a dtd type of the given name diff -r 10808c0ac008 -r a98d6a2f14a1 src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java --- a/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java Wed May 02 15:07:10 2012 +0100 +++ b/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java Wed May 02 13:12:40 2012 -0400 @@ -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 10808c0ac008 -r a98d6a2f14a1 src/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java --- a/src/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java Wed May 02 15:07:10 2012 +0100 +++ b/src/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java Wed May 02 13:12:40 2012 -0400 @@ -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 10808c0ac008 -r a98d6a2f14a1 src/com/sun/org/apache/xml/internal/serializer/SerializationHandler.java --- a/src/com/sun/org/apache/xml/internal/serializer/SerializationHandler.java Wed May 02 15:07:10 2012 +0100 +++ b/src/com/sun/org/apache/xml/internal/serializer/SerializationHandler.java Wed May 02 13:12:40 2012 -0400 @@ -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 10808c0ac008 -r a98d6a2f14a1 src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java --- a/src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java Wed May 02 15:07:10 2012 +0100 +++ b/src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java Wed May 02 13:12:40 2012 -0400 @@ -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 10808c0ac008 -r a98d6a2f14a1 src/com/sun/org/apache/xml/internal/serializer/ToStream.java --- a/src/com/sun/org/apache/xml/internal/serializer/ToStream.java Wed May 02 15:07:10 2012 +0100 +++ b/src/com/sun/org/apache/xml/internal/serializer/ToStream.java Wed May 02 13:12:40 2012 -0400 @@ -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 10808c0ac008 -r a98d6a2f14a1 src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java --- a/src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java Wed May 02 15:07:10 2012 +0100 +++ b/src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java Wed May 02 13:12:40 2012 -0400 @@ -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.