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 2005/08/05 01:57:06 UTC

cvs commit: xml-xalan/java/src/org/apache/xml/serializer ToStream.java EncodingInfo.java

minchau     2005/08/04 16:57:06

  Modified:    java/src/org/apache/xml/serializer ToStream.java
                        EncodingInfo.java
  Log:
  Committing XALANJ-2181, not yet reviewed, but a safe fix.
  
  When the requested encoding is not supported by the JDK no
  warning is given,... this fix adds an error message.
  
  Revision  Changes    Path
  1.45      +27 -1     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.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- ToStream.java	3 Aug 2005 19:20:31 -0000	1.44
  +++ ToStream.java	4 Aug 2005 23:57:06 -0000	1.45
  @@ -26,8 +26,10 @@
   import java.util.StringTokenizer;
   import java.util.Vector;
   
  +import javax.xml.transform.ErrorListener;
   import javax.xml.transform.OutputKeys;
   import javax.xml.transform.Transformer;
  +import javax.xml.transform.TransformerException;
   
   import org.apache.xml.serializer.utils.MsgKey;
   import org.apache.xml.serializer.utils.Utils;
  @@ -3020,6 +3022,30 @@
            if (old == null || !old.equals(encoding)) {        
               // If we have changed the setting of the 
               m_encodingInfo = Encodings.getEncodingInfo(encoding);
  +            
  +            if (encoding != null && m_encodingInfo.name == null) {
  +            	// We tried to get an EncodingInfo for Object for the given
  +            	// encoding, but it came back with an internall null name
  +            	// so the encoding is not supported by the JDK, issue a message.
  +            	String msg = Utils.messages.createMessage(
  +            			MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
  +            	try 
  +            	{
  +            		// Prepare to issue the warning message
  +            		Transformer tran = super.getTransformer();
  +            		if (tran != null) {
  +            			ErrorListener errHandler = tran.getErrorListener();
  +            			// Issue the warning message
  +            			if (null != errHandler && m_sourceLocator != null)
  +            				errHandler.warning(new TransformerException(msg, m_sourceLocator));
  +            			else
  +            				System.out.println(msg);
  +            	    }
  +            		else
  +            			System.out.println(msg);
  +            	}
  +            	catch (Exception e){}
  +            }
            }
            return;
        }
  
  
  
  1.6       +7 -1      xml-xalan/java/src/org/apache/xml/serializer/EncodingInfo.java
  
  Index: EncodingInfo.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/EncodingInfo.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EncodingInfo.java	3 Aug 2005 19:20:31 -0000	1.5
  +++ EncodingInfo.java	4 Aug 2005 23:57:06 -0000	1.6
  @@ -411,6 +411,12 @@
   
           } catch (Exception e) {
               isInEncoding = false;
  +            
  +            // If for some reason the encoding is null, e.g.
  +            // for a temporary result tree, we should just
  +            // say that every character is in the encoding.
  +            if (encoding == null)
  +            	isInEncoding = true;
           }
           return isInEncoding;
       }
  
  
  

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