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/10/23 22:32:23 UTC

cvs commit: xml-xalan/java/src/org/apache/xml/serializer ToStream.java ToXMLStream.java CharInfo.java ToHTMLStream.java

minchau     2003/10/23 13:32:23

  Modified:    java/src/org/apache/xml/serializer Tag: xslt20-compiled
                        ToStream.java ToXMLStream.java CharInfo.java
                        ToHTMLStream.java
  Log:
  Patch for HTML attribute performance bug 24025 is now applied.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.21.2.6  +5 -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.21.2.5
  retrieving revision 1.21.2.6
  diff -u -r1.21.2.5 -r1.21.2.6
  --- ToStream.java	22 Oct 2003 19:32:04 -0000	1.21.2.5
  +++ ToStream.java	23 Oct 2003 20:32:22 -0000	1.21.2.6
  @@ -563,7 +563,11 @@
   
           if (null != entitiesFileName)
           {
  -            m_charInfo = CharInfo.getCharInfo(entitiesFileName);
  +
  +            String method = 
  +                (String) format.get(OutputKeys.METHOD);
  +            
  +            m_charInfo = CharInfo.getCharInfo(entitiesFileName, method);
           }
   
       }
  
  
  
  1.8.2.3   +1 -1      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.2
  retrieving revision 1.8.2.3
  diff -u -r1.8.2.2 -r1.8.2.3
  --- ToXMLStream.java	22 Oct 2003 19:32:04 -0000	1.8.2.2
  +++ ToXMLStream.java	23 Oct 2003 20:32:22 -0000	1.8.2.3
  @@ -86,7 +86,7 @@
        */
       protected static CharInfo m_xmlcharInfo =
   //      new CharInfo(CharInfo.XML_ENTITIES_RESOURCE);
  -        CharInfo.getCharInfo(CharInfo.XML_ENTITIES_RESOURCE);
  +        CharInfo.getCharInfo(CharInfo.XML_ENTITIES_RESOURCE, Method.XML);
   
       /**
        * Default constructor.
  
  
  
  1.6.2.3   +31 -17    xml-xalan/java/src/org/apache/xml/serializer/CharInfo.java
  
  Index: CharInfo.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/CharInfo.java,v
  retrieving revision 1.6.2.2
  retrieving revision 1.6.2.3
  diff -u -r1.6.2.2 -r1.6.2.3
  --- CharInfo.java	15 Oct 2003 14:48:28 -0000	1.6.2.2
  +++ CharInfo.java	23 Oct 2003 20:32:22 -0000	1.6.2.3
  @@ -82,8 +82,10 @@
    * lookup.
    *
    * DEVELOPERS: See Known Issue in the constructor.
  + * 
  + * @xsl.usage internal
    */
  -public class CharInfo
  +class CharInfo
   {
       /** Lookup table for characters to entity references. */
       private Hashtable m_charToEntityRef = new Hashtable();
  @@ -112,9 +114,9 @@
       /** This flag is an optimization for HTML entities. It false if entities 
        * other than quot (34), amp (38), lt (60) and gt (62) are defined
        * in the range 0 to 127.
  -     */
  -    
  -    public final boolean onlyQuotAmpLtGt;
  +     * @xsl.usage internal
  +     */    
  +    final boolean onlyQuotAmpLtGt;
       
       /** Copy the first 0,1 ... ASCII_MAX values into an array */
       private static final int ASCII_MAX = 128;
  @@ -187,12 +189,12 @@
        * be loaded, which describes that mapping of characters to entity
        * references.
        */
  -    private CharInfo(String entitiesResource)
  +    private CharInfo(String entitiesResource, String method)
       {
  -        this(entitiesResource, false);
  +        this(entitiesResource, method, false);
       }
   
  -    private CharInfo(String entitiesResource, boolean internal)
  +    private CharInfo(String entitiesResource, String method, boolean internal)
       {
           ResourceBundle entities = null;
           boolean noExtraEntities = true;
  @@ -356,12 +358,17 @@
           
           /* Now that we've used get(ch) just above to initialize the
            * two arrays we will change by adding a tab to the set of 
  -         * special chars.  We do this because a tab is always a
  -         * special character in an attribute, but only a special character
  -         * in text if it has an entity defined for it.
  +         * special chars for XML (but not HTML!).
  +         * We do this because a tab is always a
  +         * special character in an XML attribute, 
  +         * but only a special character in XML text 
  +         * if it has an entity defined for it.
            * This is the reason for this delay.
  -         */ 
  -        set(S_HORIZONAL_TAB);
  +         */
  +        if (Method.XML.equals(method)) 
  +        {
  +            set(S_HORIZONAL_TAB);
  +        }
           
   
           onlyQuotAmpLtGt = noExtraEntities;
  @@ -383,7 +390,7 @@
        * @param name The entity's name
        * @param value The entity's value
        */
  -    protected void defineEntity(String name, char value)
  +    private void defineEntity(String name, char value)
       {
           CharKey character = new CharKey(value);
   
  @@ -407,6 +414,7 @@
        * @param value character value that should be resolved to a name.
        *
        * @return name of character entity, or null if not found.
  +     * @xsl.usage internal
        */
       synchronized public String getEntityNameForChar(char value)
       {
  @@ -423,6 +431,7 @@
        * @return true if the character should have any special treatment, 
        * such as when writing out attribute values, 
        * or entity references.
  +     * @xsl.usage internal
        */
       public final boolean isSpecialAttrChar(int value)
       {
  @@ -445,6 +454,7 @@
        * @return true if the character should have any special treatment, 
        * such as when writing out attribute values, 
        * or entity references.
  +     * @xsl.usage internal
        */
       public final boolean isSpecialTextChar(int value)
       {
  @@ -464,6 +474,7 @@
        * a text node (not an attribute value) is "clean".
        * @param value the character to check (0 to 127).
        * @return true if the character can go to the writer as-is
  +     * @xsl.usage internal
        */
       public final boolean isTextASCIIClean(int value)
       {
  @@ -494,8 +505,11 @@
        *
        * @param entitiesResource Name of entities resource file that should
        * be loaded, which describes that mapping of characters to entity references.
  +     * @param method the output method type, which should be one of "xml", "html", "text"...
  +     * 
  +     * @xsl.usage internal
        */
  -    public static CharInfo getCharInfo(String entitiesFileName)
  +    public static CharInfo getCharInfo(String entitiesFileName, String method)
       {
           CharInfo charInfo = (CharInfo) m_getCharInfoCache.get(entitiesFileName);
           if (charInfo != null) {
  @@ -504,14 +518,14 @@
   
           // try to load it internally - cache
           try {
  -            charInfo = new CharInfo(entitiesFileName, true);
  +            charInfo = new CharInfo(entitiesFileName, method, true);
               m_getCharInfoCache.put(entitiesFileName, charInfo);
               return charInfo;
           } catch (Exception e) {}
   
           // try to load it externally - do not cache
           try {
  -            return new CharInfo(entitiesFileName);
  +            return new CharInfo(entitiesFileName, method);
           } catch (Exception e) {}
   
           String absoluteEntitiesFileName;
  @@ -528,7 +542,7 @@
               }
           }
   
  -        return new CharInfo(absoluteEntitiesFileName, false);
  +        return new CharInfo(absoluteEntitiesFileName, method, false);
       }
   
       /** Table of user-specified char infos. */
  
  
  
  1.23.2.4  +1 -1      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.3
  retrieving revision 1.23.2.4
  diff -u -r1.23.2.3 -r1.23.2.4
  --- ToHTMLStream.java	22 Oct 2003 19:32:04 -0000	1.23.2.3
  +++ ToHTMLStream.java	23 Oct 2003 20:32:22 -0000	1.23.2.4
  @@ -90,7 +90,7 @@
        */
       protected static final CharInfo m_htmlcharInfo =
   //        new CharInfo(CharInfo.HTML_ENTITIES_RESOURCE);
  -        CharInfo.getCharInfo(CharInfo.HTML_ENTITIES_RESOURCE);
  +        CharInfo.getCharInfo(CharInfo.HTML_ENTITIES_RESOURCE, Method.HTML);
   
       /** A digital search trie for fast, case insensitive lookup of ElemDesc objects. */
       static final Trie m_elementFlags = new Trie();
  
  
  

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