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 2003/11/25 20:00:36 UTC

cvs commit: xml-xalan/java/src/org/apache/xml/serializer SerializerBase.java ToXMLSAXHandler.java ToHTMLSAXHandler.java ToSAXHandler.java ToXHTMLStream.java ToXMLStream.java ToStream.java ToHTMLStream.java NamespaceMappings.java ToTextStream.java

minchau     2003/11/25 11:00:36

  Modified:    java/src/org/apache/xml/serializer Tag: xslt20-compiled
                        SerializerBase.java ToXMLSAXHandler.java
                        ToHTMLSAXHandler.java ToSAXHandler.java
                        ToXHTMLStream.java ToXMLStream.java ToStream.java
                        ToHTMLStream.java NamespaceMappings.java
                        ToTextStream.java
  Log:
  Multiple changes made to serializer while committing 
  patches to Xalan-J 2.5.2 release are now rolled into thie 2.0 branch.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.8.2.1   +1 -1      xml-xalan/java/src/org/apache/xml/serializer/SerializerBase.java
  
  Index: SerializerBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/SerializerBase.java,v
  retrieving revision 1.8
  retrieving revision 1.8.2.1
  diff -u -r1.8 -r1.8.2.1
  --- SerializerBase.java	25 Jun 2003 17:05:03 -0000	1.8
  +++ SerializerBase.java	25 Nov 2003 19:00:36 -0000	1.8.2.1
  @@ -233,7 +233,7 @@
        * serializers, but exists here just so that the fireStartDoc() and
        * other fire... methods can flush this writer when tracing.
        */
  -    protected java.io.Writer m_writer = null;    
  +    protected java.io.Writer m_writer = null;
       
       /**
        * A reference to "stack frame" corresponding to
  
  
  
  1.8.2.2   +120 -81   xml-xalan/java/src/org/apache/xml/serializer/ToXMLSAXHandler.java
  
  Index: ToXMLSAXHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToXMLSAXHandler.java,v
  retrieving revision 1.8.2.1
  retrieving revision 1.8.2.2
  diff -u -r1.8.2.1 -r1.8.2.2
  --- ToXMLSAXHandler.java	22 Oct 2003 19:32:04 -0000	1.8.2.1
  +++ ToXMLSAXHandler.java	25 Nov 2003 19:00:36 -0000	1.8.2.2
  @@ -252,14 +252,26 @@
       }
   
       /**
  -     * Closes the open cdata tag
  +     * Closes ane open cdata tag, and
  +     * unlike the this.endCDATA() method (from the LexicalHandler) interface,
  +     * this "internal" method will send the endCDATA() call to the wrapped
  +     * handler.
  +     * 
        */
       public void closeCDATA() throws SAXException
       {
   
           // Output closing bracket - "]]>"
  -        m_saxHandler.characters(ENDCDATA, 0, ENDCDATA.length);
  -        m_cdataTagOpen = false;
  +        if (m_lexHandler != null && m_cdataTagOpen) {
  +            m_lexHandler.endCDATA();
  +        }
  +        
  +
  +        // There are no longer any calls made to 
  +        // m_lexHandler.startCDATA() without a balancing call to
  +        // m_lexHandler.endCDATA()
  +        // so we set m_cdataTagOpen to false to remember this.
  +        m_cdataTagOpen = false;        
       }
   
       /**
  @@ -290,7 +302,7 @@
           m_saxHandler.endElement(namespaceURI, localName, qName);
   
           if (m_tracer != null)
  -		    super.fireEndElem(qName);       
  +            super.fireEndElem(qName);       
   
           /* Pop all namespaces at the current element depth.
            * We are not waiting for official endPrefixMapping() calls.
  @@ -389,28 +401,33 @@
           {
               m_saxHandler.startPrefixMapping(prefix,uri);
               
  -            /* bjm: don't know if we really needto do this. The
  -             * callers of this object should have injected both
  -             * startPrefixMapping and the attributes.  We are
  -             * just covering our butt here.
  -             */
  -            String name;
  -            if (EMPTYSTRING.equals(prefix))
  +            if (getShouldOutputNSAttr()) 
               {
  -                name = "xmlns";
  -                addAttributeAlways(XMLNS_URI, prefix, name,"CDATA",uri);
  -            }
  -            else {
  -                if (!EMPTYSTRING.equals(uri)) // hack for XSLTC attribset16 test
  -                {                             // that maps ns1 prefix to "" URI 
  -                    name = "xmlns:" + prefix;
  -
  -                    /* for something like xmlns:abc="w3.pretend.org"
  -             	 	 *  the      uri is the value, that is why we pass it in the
  -             	 	 * value, or 5th slot of addAttributeAlways()
  -                 	 */
  -                    addAttributeAlways(XMLNS_URI, prefix, name,"CDATA",uri);
  -                }
  +
  +	              /* bjm: don't know if we really needto do this. The
  +	               * callers of this object should have injected both
  +	               * startPrefixMapping and the attributes.  We are
  +	               * just covering our butt here.
  +	               */
  +	              String name;
  +  	            if (EMPTYSTRING.equals(prefix))
  +  	            {
  +  	                name = "xmlns";
  +  	                addAttributeAlways(XMLNS_URI, prefix, name,"CDATA",uri);
  +  	            }
  +  	            else 
  +                {
  +  	                if (!EMPTYSTRING.equals(uri)) // hack for XSLTC attribset16 test
  +  	                {                             // that maps ns1 prefix to "" URI 
  +  	                    name = "xmlns:" + prefix;
  +  	
  +  	                    /* for something like xmlns:abc="w3.pretend.org"
  +  	             	 	     *  the uri is the value, that is why we pass it in the
  +  	             	 	     * value, or 5th slot of addAttributeAlways()
  +  	                 	   */
  +  	                    addAttributeAlways(XMLNS_URI, prefix, name,"CDATA",uri);
  +  	                }
  +  	            }
               }
           }
           return pushed;
  @@ -435,8 +452,27 @@
        */
       public void endCDATA() throws SAXException
       {
  -        if (m_lexHandler != null)
  -            m_lexHandler.endCDATA();
  +        /* Normally we would do somthing with this but we ignore it.
  +         * The neccessary call to m_lexHandler.endCDATA() will be made
  +         * in flushPending().
  +         * 
  +         * This is so that if we get calls like these:
  +         *   this.startCDATA();
  +         *   this.characters(chars1, off1, len1);
  +         *   this.endCDATA();
  +         *   this.startCDATA();
  +         *   this.characters(chars2, off2, len2);
  +         *   this.endCDATA();
  +         * 
  +         * that we will only make these calls to the wrapped handlers:
  +         * 
  +         *   m_lexHandler.startCDATA();
  +         *   m_saxHandler.characters(chars1, off1, len1);
  +         *   m_saxHandler.characters(chars1, off2, len2);
  +         *   m_lexHandler.endCDATA();
  +         * 
  +         * We will merge adjacent CDATA blocks.
  +         */ 
       }
   
       /**
  @@ -515,22 +551,39 @@
   
       public void characters(char[] ch, int off, int len) throws SAXException
       {
  -        // System.out.println("SAXXMLOutput.characters ch = " + new String(ch, off, len));
  -
  -        flushPending();
  +        // We do the first two things in flushPending() but we don't
  +        // close any open CDATA calls.        
  +        if (m_needToCallStartDocument)
  +        {
  +            startDocumentInternal();
  +            m_needToCallStartDocument = false;
  +        }
   
  -        if (m_elemContext.m_isCdataSection)
  +        if (m_elemContext.m_startTagOpen)
           {
  -            startCDATA(ch, off, len);
  +            closeStartTag();
  +            m_elemContext.m_startTagOpen = false;
           }
  -        else
  +
  +        if (m_elemContext.m_isCdataSection && !m_cdataTagOpen
  +        && m_lexHandler != null) 
           {
  -            m_saxHandler.characters(ch, off, len);
  +            m_lexHandler.startCDATA();
  +            // We have made a call to m_lexHandler.startCDATA() with
  +            // no balancing call to m_lexHandler.endCDATA()
  +            // so we set m_cdataTagOpen true to remember this.
  +            m_cdataTagOpen = true;
           }
  +        
  +        /* If there are any occurances of "]]>" in the character data
  +         * let m_saxHandler worry about it, we've already warned them with
  +         * the previous call of m_lexHandler.startCDATA();
  +         */ 
  +        m_saxHandler.characters(ch, off, len);
   
  -		// time to generate characters event
  -		if (m_tracer != null)
  -		    fireCharEvent(ch, off, len);
  +        // time to generate characters event
  +        if (m_tracer != null)
  +            fireCharEvent(ch, off, len);
       }
       
   
  @@ -598,47 +651,31 @@
   
       public void startCDATA() throws SAXException
       {
  -
  -        // Output start bracket - "<![CDATA["
  -        m_saxHandler.characters(BEGCDATA, 0, BEGCDATA.length);
  -        m_cdataTagOpen = true;
  -
  -    }
  -
  -    /**
  -     * Utility method - pass a whole charactes as CDATA to SAX handler
  -     */
  -    private void startCDATA(char[] ch, int off, int len) throws SAXException
  -    {
  -        final int limit = off + len;
  -        int offset = off;
  -
  -        // Output start bracket - "<![CDATA["
  -        m_saxHandler.characters(BEGCDATA, 0, BEGCDATA.length);
  -
  -        // Detect any occurence of "]]>" in the character array
  -        for (int i = offset; i < limit - 2; i++)
  +        /* m_cdataTagOpen can only be true here if we have ignored the
  +         * previous call to this.endCDATA() and the previous call 
  +         * this.startCDATA() before that is still "open". In this way
  +         * we merge adjacent CDATA. If anything else happened after the 
  +         * ignored call to this.endCDATA() and this call then a call to 
  +         * flushPending() would have been made which would have
  +         * closed the CDATA and set m_cdataTagOpen to false.
  +         */
  +        if (!m_cdataTagOpen ) 
           {
  -            if (ch[i] == ']' && ch[i + 1] == ']' && ch[i + 2] == '>')
  -            {
  -                m_saxHandler.characters(ch, offset, i - offset);
  -                m_saxHandler.characters(CNTCDATA, 0, CNTCDATA.length);
  -                offset = i + 3;
  -                i += 2; // Skip next chars ']' and '>'
  -            }
  -        }
  +            flushPending();
  +            if (m_lexHandler != null) {
  +                m_lexHandler.startCDATA();
   
  -        // Output the remaining characters
  -        if (offset < limit)
  -        {
  -            m_saxHandler.characters(ch, offset, limit - offset);
  -        }
  -        m_cdataTagOpen = true;
  +                // We have made a call to m_lexHandler.startCDATA() with
  +                // no balancing call to m_lexHandler.endCDATA()
  +                // so we set m_cdataTagOpen true to remember this.                
  +                m_cdataTagOpen = true;     
  +            }              
  +        }        
       }
   
       /**
  -    * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
  -    */
  +     * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
  +     */
       public void startElement(
       String namespaceURI,
       String localName,
  @@ -701,14 +738,16 @@
                   {
                       this.startPrefixMapping(prefix, ns, false);
   
  -                    // Bugzilla1133: Generate attribute as well as namespace event.
  -                    // SAX does expect both.
  -                    this.addAttributeAlways(
  -                        "http://www.w3.org/2000/xmlns/",
  -                        prefix,
  -                        "xmlns" + (prefix.length() == 0 ? "" : ":") + prefix,
  -                        "CDATA",
  -                        ns);
  +                    if (getShouldOutputNSAttr()) {
  +                        // Bugzilla1133: Generate attribute as well as namespace event.
  +                        // SAX does expect both.
  +                        this.addAttributeAlways(
  +                            "http://www.w3.org/2000/xmlns/",
  +                            prefix,
  +                            "xmlns" + (prefix.length() == 0 ? "" : ":") + prefix,
  +                            "CDATA",
  +                            ns);
  +                    }
                   }
   
               }
  
  
  
  1.5.2.3   +2 -10     xml-xalan/java/src/org/apache/xml/serializer/ToHTMLSAXHandler.java
  
  Index: ToHTMLSAXHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToHTMLSAXHandler.java,v
  retrieving revision 1.5.2.2
  retrieving revision 1.5.2.3
  diff -u -r1.5.2.2 -r1.5.2.3
  --- ToHTMLSAXHandler.java	22 Oct 2003 19:32:04 -0000	1.5.2.2
  +++ ToHTMLSAXHandler.java	25 Nov 2003 19:00:36 -0000	1.5.2.3
  @@ -650,21 +650,13 @@
       {
   		if (m_needToCallStartDocument)
   		{
  -			try {startDocumentInternal();
  +			startDocumentInternal();
   			m_needToCallStartDocument = false;
  -			} catch (SAXException e) {}
   		}       	
           // Close any open element
           if (m_elemContext.m_startTagOpen)
           {
  -            try
  -            {
  -                closeStartTag();
  -            }
  -            catch(SAXException se)
  -            {
  -                // do something ??
  -            }
  +            closeStartTag();
               m_elemContext.m_startTagOpen = false;
           }
       }
  
  
  
  1.6.2.2   +41 -4     xml-xalan/java/src/org/apache/xml/serializer/ToSAXHandler.java
  
  Index: ToSAXHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToSAXHandler.java,v
  retrieving revision 1.6.2.1
  retrieving revision 1.6.2.2
  diff -u -r1.6.2.1 -r1.6.2.2
  --- ToSAXHandler.java	6 Oct 2003 14:35:48 -0000	1.6.2.1
  +++ ToSAXHandler.java	25 Nov 2003 19:00:36 -0000	1.6.2.2
  @@ -100,6 +100,16 @@
        */
       protected LexicalHandler m_lexHandler;
   
  +    /**
  +     * A startPrefixMapping() call on a ToSAXHandler will pass that call
  +     * on to the wrapped ContentHandler, but should we also mirror these calls
  +     * with matching attributes, if so this field is true.
  +     * For example if this field is true then a call such as
  +     * startPrefixMapping("prefix1","uri1") will also cause the additional
  +     * internally generated attribute xmlns:prefix1="uri1" to be effectively added
  +     * to the attributes passed to the wrapped ContentHandler.
  +     */ 
  +    private boolean m_shouldGenerateNSAttribute = true;
       
       /** If this is true, then the content handler wrapped by this
        * serializer implements the TransformState interface which
  @@ -278,6 +288,28 @@
       {
           // do nothing
       }
  +    
  +    /** Set whether or not namespace declarations (e.g. 
  +     * xmlns:foo) should appear as attributes of 
  +     * elements
  +     * @param doOutputNSAttr whether or not namespace declarations
  +     * should appear as attributes
  +     */
  +    public void setShouldOutputNSAttr(boolean doOutputNSAttr)
  +    {
  +        m_shouldGenerateNSAttribute = doOutputNSAttr;
  +    }
  + 
  +    /** 
  +     * Returns true if namespace declarations from calls such as
  +     * startPrefixMapping("prefix1","uri1") should
  +     * also be mirrored with self generated additional attributes of elements 
  +     * that declare the namespace, for example the attribute xmlns:prefix1="uri1"
  +     */
  +    boolean getShouldOutputNSAttr()
  +    {
  +        return m_shouldGenerateNSAttribute;
  +    }
   
       /**
        * This method flushes any pending events, which can be startDocument()
  @@ -357,7 +389,7 @@
       }
       
       /**
  -     * This method gets the nodes value as a String and uses that String as if
  +     * This method gets the node's value as a String and uses that String as if
        * it were an input character notification.
        * @param node the Node to serialize
        * @throws org.xml.sax.SAXException
  @@ -371,9 +403,13 @@
               m_state.setCurrentNode(node);
           }
           
  -        // do what the stream serializers do
  -        super.characters(node);
  -       }    
  +        // Get the node's value as a String and use that String as if
  +        // it were an input character notification.
  +        String data = node.getNodeValue();
  +        if (data != null) {
  +            this.characters(data);
  +        }
  +    }    
   
       /**
        * @see org.xml.sax.ErrorHandler#fatalError(SAXParseException)
  @@ -438,6 +474,7 @@
           this.m_lexHandler = null;
           this.m_saxHandler = null;
           this.m_state = null;
  +        this.m_shouldGenerateNSAttribute = false;
       }  
   
       /**
  
  
  
  1.1.2.3   +0 -6      xml-xalan/java/src/org/apache/xml/serializer/Attic/ToXHTMLStream.java
  
  Index: ToXHTMLStream.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/Attic/ToXHTMLStream.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ToXHTMLStream.java	31 Oct 2003 21:12:15 -0000	1.1.2.2
  +++ ToXHTMLStream.java	25 Nov 2003 19:00:36 -0000	1.1.2.3
  @@ -39,12 +39,6 @@
           final int elemFlags = elemDesc.getFlags();
           final boolean isHeadElement = (elemFlags & ElemDesc.HEADELEM) != 0;
           
  -//        if ( ((elemFlags & ElemDesc.HTMLELEM) != 0)
  -//            && (namespaceURI == null || namespaceURI.equals(EMPTYSTRING))) 
  -//        {
  -//            this.startPrefixMapping(EMPTYSTRING,"http://www.w3.org/1999/xhtml");
  -//        }
  -
           if (m_needToCallStartDocument)
           {
               startDocumentInternal();
  
  
  
  1.8.2.4   +2 -2      xml-xalan/java/src/org/apache/xml/serializer/ToXMLStream.java
  
  Index: ToXMLStream.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToXMLStream.java,v
  retrieving revision 1.8.2.3
  retrieving revision 1.8.2.4
  diff -u -r1.8.2.3 -r1.8.2.4
  --- ToXMLStream.java	23 Oct 2003 20:32:22 -0000	1.8.2.3
  +++ ToXMLStream.java	25 Nov 2003 19:00:36 -0000	1.8.2.4
  @@ -77,7 +77,7 @@
       /**
        * remembers if we need to write out "]]>" to close the CDATA
        */
  -    protected boolean m_cdataTagOpen = false;
  +    boolean m_cdataTagOpen = false;
   
   
       /**
  @@ -580,7 +580,7 @@
       private void resetToXMLStream()
       {
           this.m_cdataTagOpen = false;
  -        this.m_charInfo = m_xmlcharInfo;
  +
       }  
   
   }
  
  
  
  1.21.2.7  +16 -26    xml-xalan/java/src/org/apache/xml/serializer/ToStream.java
  
  Index: ToStream.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToStream.java,v
  retrieving revision 1.21.2.6
  retrieving revision 1.21.2.7
  diff -u -r1.21.2.6 -r1.21.2.7
  --- ToStream.java	23 Oct 2003 20:32:22 -0000	1.21.2.6
  +++ ToStream.java	25 Nov 2003 19:00:36 -0000	1.21.2.7
  @@ -1801,8 +1801,8 @@
           m_elemContext = m_elemContext.push(namespaceURI,localName,name);
           m_isprevtext = false;
   
  -		if (m_tracer != null)
  -			firePseudoAttributes();
  +        if (m_tracer != null)
  +            firePseudoAttributes();
       }
   
       /**
  @@ -2665,7 +2665,7 @@
           return null;
       }
   
  -    protected void ensurePrefixIsDeclared(String ns, String rawName)
  +    void ensurePrefixIsDeclared(String ns, String rawName)
           throws org.xml.sax.SAXException
       {
   
  @@ -2706,9 +2706,6 @@
        */
       public void flushPending() throws SAXException
       {
  -        try
  -        {
  -
               if (m_needToCallStartDocument)
               {
                   startDocumentInternal();
  @@ -2725,12 +2722,6 @@
                   closeCDATA();
                   m_cdataTagOpen = false;
               }
  -        }
  -        catch (SAXException e)
  -        { // can we do anything useful here,
  -            // or should this method throw a SAXException?
  -        }
  -
       }
   
       public void setContentHandler(ContentHandler ch)
  @@ -2808,13 +2799,12 @@
               {
                   // flush out the "<elemName" if not already flushed
                   m_writer.flush();
  -
  +                
  +                // make a StringBuffer to write the name="value" pairs to.
  +                StringBuffer sb = new StringBuffer();
                   int nAttrs = m_attributes.getLength();
                   if (nAttrs > 0)
                   {
  -                    // make a StringBuffer to write the name="value" pairs to.
  -                    StringBuffer sb = new StringBuffer();
  -
                       // make a writer that internally appends to the same
                       // StringBuffer
                       java.io.Writer writer =
  @@ -2824,17 +2814,17 @@
                       // Don't clear the attributes! 
                       // We only want to see what would be written out
                       // at this point, we don't want to loose them.
  -
  -                    // convert the StringBuffer to a char array and
  -                    // emit the trace event that these characters "might"
  -                    // be written
  -                    char ch[] = sb.toString().toCharArray();
  -                    m_tracer.fireGenerateEvent(
  -                        SerializerTrace.EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS,
  -                        ch,
  -                        0,
  -                        ch.length);
                   }
  +                sb.append('>');  // the potential > after the attributes.
  +                // convert the StringBuffer to a char array and
  +                // emit the trace event that these characters "might"
  +                // be written                
  +                char ch[] = sb.toString().toCharArray();
  +                m_tracer.fireGenerateEvent(
  +                    SerializerTrace.EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS,
  +                    ch,
  +                    0,
  +                    ch.length);                
               }
               catch (IOException ioe)
               {
  
  
  
  1.23.2.5  +1 -2      xml-xalan/java/src/org/apache/xml/serializer/ToHTMLStream.java
  
  Index: ToHTMLStream.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToHTMLStream.java,v
  retrieving revision 1.23.2.4
  retrieving revision 1.23.2.5
  diff -u -r1.23.2.4 -r1.23.2.5
  --- ToHTMLStream.java	23 Oct 2003 20:32:22 -0000	1.23.2.4
  +++ ToHTMLStream.java	25 Nov 2003 19:00:36 -0000	1.23.2.5
  @@ -1933,7 +1933,6 @@
           m_inDTD = false;
   //        m_isRawStack.clear();
           m_omitMetaTag = false;
  -        m_specialEscapeURLs = true;   
  -        m_charInfo = m_htmlcharInfo;  
  +        m_specialEscapeURLs = true;     
       }
   }
  
  
  
  1.3.2.2   +6 -6      xml-xalan/java/src/org/apache/xml/serializer/NamespaceMappings.java
  
  Index: NamespaceMappings.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/NamespaceMappings.java,v
  retrieving revision 1.3.2.1
  retrieving revision 1.3.2.2
  diff -u -r1.3.2.1 -r1.3.2.2
  --- NamespaceMappings.java	22 Oct 2003 19:32:04 -0000	1.3.2.1
  +++ NamespaceMappings.java	25 Nov 2003 19:00:36 -0000	1.3.2.2
  @@ -319,12 +319,12 @@
       
       public final void reset()
       {
  -    	this.count = 0;
  -    	this.m_namespaces.clear();
  -    	this.m_nodeStack.clear();
  -    	this.m_prefixStack.clear();
  -    	
  -    	initNamespaces();
  +        this.count = 0;
  +        this.m_namespaces.clear();
  +        this.m_nodeStack.clear();
  +        this.m_prefixStack.clear();
  +        
  +        initNamespaces();
       }
   
   }
  
  
  
  1.11.2.4  +42 -15    xml-xalan/java/src/org/apache/xml/serializer/ToTextStream.java
  
  Index: ToTextStream.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToTextStream.java,v
  retrieving revision 1.11.2.3
  retrieving revision 1.11.2.4
  diff -u -r1.11.2.3 -r1.11.2.4
  --- ToTextStream.java	23 Oct 2003 18:20:10 -0000	1.11.2.3
  +++ ToTextStream.java	25 Nov 2003 19:00:36 -0000	1.11.2.4
  @@ -357,11 +357,28 @@
                   }
                   else
                   {
  +                    /* The character is greater than the allowed 
  +                     * maximum value and it is not part of a UTF-16
  +                     * pair that would be put out as a character reference.
  +                     */
                       String encoding = getEncoding();
  -                    String integralValue = Integer.toString(c);
  -                    throw new SAXException(XMLMessages.createXMLMessage(
  -                        XMLErrorResources.ER_ILLEGAL_CHARACTER,
  -                        new Object[]{ integralValue, encoding}));
  +                    if (encoding != null)
  +                    {
  +                        /* The output encoding is known, 
  +                         * so somthing is wrong.
  +                         */ 
  +                        String integralValue = Integer.toString(c);
  +                        throw new SAXException(XMLMessages.createXMLMessage(
  +                            XMLErrorResources.ER_ILLEGAL_CHARACTER,
  +                            new Object[]{ integralValue, encoding}));
  +                    }
  +                    else 
  +                    {
  +                        /* The output encoding is not known,
  +                         * so just write it out as-is.
  +                         */                        
  +                        writer.write(c);
  +                    }
                   }
               }
           }
  @@ -388,11 +405,28 @@
               }
               else
               {
  +                /* The character is greater than the allowed 
  +                 * maximum value and it is not part of a UTF-16
  +                 * pair that would be put out as a character reference.
  +                 */
                   String encoding = getEncoding();
  -                String integralValue = Integer.toString(c);
  -                throw new SAXException(XMLMessages.createXMLMessage(
  -                    XMLErrorResources.ER_ILLEGAL_CHARACTER,
  -                    new Object[]{ integralValue, encoding}));                 
  +                if (encoding != null) 
  +                {
  +                    /* The output encoding is known, 
  +                     * so somthing is wrong.
  +                     */ 
  +                    String integralValue = Integer.toString(c);
  +                    throw new SAXException(XMLMessages.createXMLMessage(
  +                        XMLErrorResources.ER_ILLEGAL_CHARACTER,
  +                        new Object[]{ integralValue, encoding}));
  +                }
  +                else 
  +                {
  +                    /* The output encoding is not known,
  +                     * so just write it out as-is.
  +                     */                        
  +                    writer.write(c);
  +                }                
               }
           }
       }
  @@ -673,17 +707,10 @@
   
       public void flushPending() throws org.xml.sax.SAXException
       {
  -        try
  -        {
               if (m_needToCallStartDocument)
               {
                   startDocumentInternal();
                   m_needToCallStartDocument = false;
               }
  -        }
  -        catch (SAXException e)
  -        { // can we do anything useful here,
  -            // or should this method throw a SAXException?
  -        }
       }
   }
  
  
  

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