You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mi...@apache.org on 2006/01/18 23:35:34 UTC

svn commit: r370286 - in /xalan/java/trunk/src/org/apache/xml/serializer: SerializerBase.java ToStream.java

Author: minchau
Date: Wed Jan 18 14:35:32 2006
New Revision: 370286

URL: http://svn.apache.org/viewcvs?rev=370286&view=rev
Log:
Applying cleanup.txt patch in XALANJ-2258

Modified:
    xalan/java/trunk/src/org/apache/xml/serializer/SerializerBase.java
    xalan/java/trunk/src/org/apache/xml/serializer/ToStream.java

Modified: xalan/java/trunk/src/org/apache/xml/serializer/SerializerBase.java
URL: http://svn.apache.org/viewcvs/xalan/java/trunk/src/org/apache/xml/serializer/SerializerBase.java?rev=370286&r1=370285&r2=370286&view=diff
==============================================================================
--- xalan/java/trunk/src/org/apache/xml/serializer/SerializerBase.java (original)
+++ xalan/java/trunk/src/org/apache/xml/serializer/SerializerBase.java Wed Jan 18 14:35:32 2006
@@ -252,6 +252,8 @@
      */
     public void comment(String data) throws SAXException
     {
+        m_docIsEmpty = false;
+        
         final int length = data.length();
         if (length > m_charsBuff.length)
         {
@@ -1434,11 +1436,31 @@
         
     }
     
+    
     /**
-     * Push a boolean state based on if the name of the current element
-     * is found in the list of qnames.  A state is only pushed if
-     * there were some cdata-section-names were specified.
+     * Return true if nothing has been sent to this result tree yet.
+     * <p>
+     * This is not a public API.
+     * 
+     * @xsl.usage internal
+     */
+    public boolean documentIsEmpty() {
+        // If we haven't called startDocument() yet, then this document is empty
+        return m_docIsEmpty && (m_elemContext.m_currentElemDepth == 0);
+    }    
+    
+    /**
+     * Return true if the current element in m_elemContext
+     * is a CDATA section.
+     * CDATA sections are specified in the <xsl:output> attribute
+     * cdata-section-names or in the JAXP equivalent property.
+     * In any case the format of the value of such a property is:
+     * <pre>
+     * "{uri1}localName1 {uri2}localName2 . . . "
+     * </pre>
+     * 
      * <p>
+     * This method is not a public API, but is only used internally by the serializer.
      */
     protected boolean isCdataSection()
     {

Modified: xalan/java/trunk/src/org/apache/xml/serializer/ToStream.java
URL: http://svn.apache.org/viewcvs/xalan/java/trunk/src/org/apache/xml/serializer/ToStream.java?rev=370286&r1=370285&r2=370286&view=diff
==============================================================================
--- xalan/java/trunk/src/org/apache/xml/serializer/ToStream.java (original)
+++ xalan/java/trunk/src/org/apache/xml/serializer/ToStream.java Wed Jan 18 14:35:32 2006
@@ -276,8 +276,7 @@
             return ((WriterToUTF8Buffered) m_writer).getOutputStream();
         if (m_writer instanceof WriterToASCI)
             return ((WriterToASCI) m_writer).getOutputStream();
-        else
-            return null;
+        return null;
     }
 
     // Implement DeclHandler
@@ -447,9 +446,13 @@
             OutputPropertyUtils.getIntProperty(
                 OutputPropertiesFactory.S_KEY_INDENT_AMOUNT,
                 format));
-        setIndent(
-            OutputPropertyUtils.getBooleanProperty(OutputKeys.INDENT, format));
-            
+
+        String vall = format.getProperty(OutputKeys.INDENT);
+        if (vall != null) {
+            setIndent(
+                OutputPropertyUtils.getBooleanProperty(OutputKeys.INDENT, format));
+        }
+
         {
             String sep = 
                     format.getProperty(OutputPropertiesFactory.S_KEY_LINE_SEPARATOR);
@@ -521,6 +524,21 @@
             m_charInfo = CharInfo.getCharInfo(entitiesFileName, method);
         }
 
+        // if we are tracing events we need to trace what
+        // characters are written to the output writer.
+        if (m_tracer != null) {
+            boolean noTracerYet = true;
+            Writer w2 = m_writer;
+            while (w2 instanceof WriterChain) {
+                if (w2 instanceof SerializerTraceWriter) {
+                    noTracerYet = false;
+                    break;
+                }
+                w2 = ((WriterChain)w2).getWriter();
+            }
+            if (noTracerYet)
+                m_writer = new SerializerTraceWriter(m_writer, m_tracer);
+        }
     }
 
     /**
@@ -566,20 +584,6 @@
         if (encoding.equalsIgnoreCase("UTF-8"))
         {
             m_isUTF8 = true;
-            //            if (output instanceof java.io.BufferedOutputStream)
-            //            {
-            //                init(new WriterToUTF8(output), format, defaultProperties, true);
-            //            }
-            //            else if (output instanceof java.io.FileOutputStream)
-            //            {
-            //                init(new WriterToUTF8Buffered(output), format, defaultProperties, true);
-            //            }
-            //            else
-            //            {
-            //                // Not sure what to do in this case.  I'm going to be conservative 
-            //                // and not buffer.
-            //                init(new WriterToUTF8(output), format, defaultProperties, true);
-            //            }
          
 
                 init(
@@ -1341,6 +1345,9 @@
         // is created if string is empty.	
         if (length == 0 || (m_inEntityRef && !m_expandDTDEntities))
             return;
+            
+        m_docIsEmpty = false;
+        
         if (m_elemContext.m_startTagOpen)
         {
             closeStartTag();
@@ -1726,6 +1733,7 @@
         {
             startDocumentInternal();
             m_needToCallStartDocument = false;
+            m_docIsEmpty = false;
         }
         else if (m_cdataTagOpen)
             closeCDATA();



---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org