curcuru     01/10/16 11:16:15

  Modified:    java/src/org/apache/xalan/serialize CharInfo.java
                        HTMLEntities.res XMLEntities.res
  Log:
  Fix Bugzilla#4000, force reading of *Entites.res to be in UTF-8; added 
comments
  PR: Bugzilla#4000
  
  Revision  Changes    Path
  1.9       +18 -17    
xml-xalan/java/src/org/apache/xalan/serialize/CharInfo.java
  
  Index: CharInfo.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/CharInfo.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CharInfo.java     2001/10/10 18:42:24     1.8
  +++ CharInfo.java     2001/10/16 18:16:14     1.9
  @@ -115,6 +115,15 @@
      * Constructor that reads in a resource file that describes the mapping of
      * characters to entity references.
      *
  +   * Resource files must be encoded in UTF-8 and have a format like:
  +   * <pre>
  +   * # First char # is a comment
  +   * Entity numericValue
  +   * quot 34
  +   * amp 38
  +   * </pre>
  +   * (Note: Why don't we just switch to .properties files? Oct-01 -sc)
  +   *
      * @param entitiesResource Name of entities resource file that should
      * be loaded, which describes that mapping of characters to entity 
references.
      */
  @@ -133,6 +142,9 @@
       {
         try
         {
  +        // Maintenance note: we should evaluate replacing getting the 
  +        //  ClassLoader with 
javax.xml.transform.FactoryFinder.findClassLoader()
  +        //  or similar code
           ClassLoader cl = CharInfo.class.getClassLoader();
   
           if (cl == null) {
  @@ -141,15 +153,6 @@
             is = cl.getResourceAsStream(entitiesResource);
           }
         }
  -      /*  replaced with lines above (adapted from TransformerFactory) for 
getting a stream resource.
  -      try {
  -        java.lang.reflect.Method getCCL = 
Thread.class.getMethod("getContextClassLoader", NO_CLASSES);
  -        if (getCCL != null) {
  -          ClassLoader contextClassLoader = (ClassLoader) 
getCCL.invoke(Thread.currentThread(), NO_OBJS);
  -          is = 
contextClassLoader.getResourceAsStream("org/apache/xalan/serialize/" + 
entitiesResource);
  -        }
  -      }    */
  -    
         catch (Exception e) {}
   
         if (is == null)
  @@ -163,11 +166,12 @@
         }
   
         if (is == null)
  -        throw new 
RuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_RESOURCE_COULD_NOT_FIND,
 new Object[]{entitiesResource, entitiesResource })); //"The resource [" + 
entitiesResource
  -                                  // + "] could not be found.\n"
  -                                  // + entitiesResource);
  +        throw new 
RuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_RESOURCE_COULD_NOT_FIND,
 new Object[]{entitiesResource, entitiesResource }));
   
  -      reader = new BufferedReader(new InputStreamReader(is));
  +      // Fix Bugzilla#4000: force reading in UTF-8
  +      //  This creates the de facto standard that Xalan's resource 
  +      //  files must be encoded in UTF-8
  +      reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
         line = reader.readLine();
   
         while (line != null)
  @@ -210,10 +214,7 @@
       }
       catch (Exception except)
       {
  -      throw new 
RuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_RESOURCE_COULD_NOT_LOAD,
 new Object[]{entitiesResource,  except.toString(), entitiesResource, 
except.toString() })); //"The resource [" + entitiesResource
  -                                 //+ "] could not load: " + except.toString()
  -                                 //+ "\n" + entitiesResource + "\t"
  -                                 //+ except.toString());
  +      throw new 
RuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_RESOURCE_COULD_NOT_LOAD,
 new Object[]{entitiesResource,  except.toString(), entitiesResource, 
except.toString() }));
       }
       finally
       {
  
  
  
  1.3       +3 -2      
xml-xalan/java/src/org/apache/xalan/serialize/HTMLEntities.res
  
  Index: HTMLEntities.res
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/HTMLEntities.res,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HTMLEntities.res  2000/12/10 05:17:39     1.2
  +++ HTMLEntities.res  2001/10/16 18:16:14     1.3
  @@ -1,7 +1,8 @@
  -# $Id: HTMLEntities.res,v 1.2 2000/12/10 05:17:39 sboag Exp $
  +# $Id: HTMLEntities.res,v 1.3 2001/10/16 18:16:14 curcuru Exp $
   #
  -# @version $Revision: 1.2 $ $Date: 2000/12/10 05:17:39 $
  +# @version $Revision: 1.3 $ $Date: 2001/10/16 18:16:14 $
   # @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
  +# This file must be encoded in UTF-8; see org.apache.xalan.serialize.CharInfo
   #
   # Character entity references for markup-significant
   #
  
  
  
  1.2       +3 -2      
xml-xalan/java/src/org/apache/xalan/serialize/XMLEntities.res
  
  Index: XMLEntities.res
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/XMLEntities.res,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLEntities.res   2000/12/06 05:37:09     1.1
  +++ XMLEntities.res   2001/10/16 18:16:14     1.2
  @@ -1,7 +1,8 @@
  -# $Id: XMLEntities.res,v 1.1 2000/12/06 05:37:09 sboag Exp $
  +# $Id: XMLEntities.res,v 1.2 2001/10/16 18:16:14 curcuru Exp $
   #
  -# @version $Revision: 1.1 $ $Date: 2000/12/06 05:37:09 $
  +# @version $Revision: 1.2 $ $Date: 2001/10/16 18:16:14 $
   # @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
  +# This file must be encoded in UTF-8; see org.apache.xalan.serialize.CharInfo
   #
   # Character entity references for markup-significant
   #
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to