You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@locus.apache.org on 2000/12/07 09:16:15 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/serialize CharInfo.java FormatterToHTML.java FormatterToXML.java

sboag       00/12/07 00:16:13

  Modified:    java/src/org/apache/xalan/serialize CharInfo.java
                        FormatterToHTML.java FormatterToXML.java
  Log:
  Allow xsl:output xalan:entities attribute to override entity ref map.
  
  Revision  Changes    Path
  1.2       +9 -0      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CharInfo.java	2000/12/06 05:37:08	1.1
  +++ CharInfo.java	2000/12/07 08:16:10	1.2
  @@ -62,6 +62,8 @@
   import java.io.InputStreamReader;
   import java.io.BufferedReader;
   
  +import java.net.*;
  +
   import java.util.Hashtable;
   
   /**
  @@ -115,6 +117,13 @@
       try
       {
         is = CharInfo.class.getResourceAsStream(entitiesResource);
  +
  +      if (is == null)
  +      {
  +        URL url = new URL(entitiesResource);
  +
  +        is = url.openStream();
  +      }
   
         if (is == null)
           throw new RuntimeException("The resource [" + entitiesResource
  
  
  
  1.9       +1 -1      xml-xalan/java/src/org/apache/xalan/serialize/FormatterToHTML.java
  
  Index: FormatterToHTML.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/FormatterToHTML.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FormatterToHTML.java	2000/12/07 06:25:04	1.8
  +++ FormatterToHTML.java	2000/12/07 08:16:11	1.9
  @@ -406,7 +406,7 @@
       m_specialEscapeURLs =
         OutputProperties.getBooleanProperty(OutputProperties.S_USE_URL_ESCAPING,
                                             format);
  -
  +                            
       super.setOutputFormat(format);
     }
   
  
  
  
  1.8       +56 -2     xml-xalan/java/src/org/apache/xalan/serialize/FormatterToXML.java
  
  Index: FormatterToXML.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/FormatterToXML.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FormatterToXML.java	2000/12/06 05:37:09	1.7
  +++ FormatterToXML.java	2000/12/07 08:16:11	1.8
  @@ -80,6 +80,7 @@
   import org.apache.xml.utils.BoolStack;
   import org.apache.xml.utils.TreeWalker;
   import org.apache.xml.utils.WrappedRuntimeException;
  +import org.apache.xml.utils.SystemIDResolver;
   import org.apache.xalan.res.XSLTErrorResources;
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xpath.res.XPATHErrorResources;
  @@ -286,8 +287,11 @@
      * Map that tells which characters should have special treatment, and it
      *  provides character to entity name lookup.
      */
  -  protected static CharInfo m_charInfo;
  +  protected CharInfo m_charInfo;
   
  +  /** Table of user-specified char infos. */
  +  private static Hashtable m_charInfos = null;
  +
     /**
      * Flag to quickly tell if the encoding is UTF8.
      */
  @@ -415,6 +419,56 @@
   
       m_isUTF8 = m_encoding.equals(Encodings.DEFAULT_MIME_ENCODING);
       m_maxCharacter = Encodings.getLastPrintable(m_encoding);
  +
  +    // Access this only from the Hashtable level... we don't want to 
  +    // get default properties.
  +    String entitiesFileName =
  +      (String) format.get(OutputProperties.S_KEY_ENTITIES);
  +
  +    if (null != entitiesFileName)
  +    {
  +      try
  +      {
  +        m_charInfo = null;
  +
  +        if (null == m_charInfos)
  +        {
  +          synchronized (m_xmlcharInfo)
  +          {
  +            if (null == m_charInfos)  // secondary check
  +              m_charInfos = new Hashtable();
  +          }
  +        }
  +        else
  +        {
  +          m_charInfo = (CharInfo) m_charInfos.get(entitiesFileName);
  +        }
  +
  +        if (null == m_charInfo)
  +        {
  +          String absoluteEntitiesFileName;
  +
  +          if (entitiesFileName.indexOf(':') < 0)
  +          {
  +            absoluteEntitiesFileName =
  +              SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName);
  +          }
  +          else
  +          {
  +            absoluteEntitiesFileName =
  +              SystemIDResolver.getAbsoluteURI(entitiesFileName, null);
  +          }
  +
  +          m_charInfo = new CharInfo(absoluteEntitiesFileName);
  +
  +          m_charInfos.put(entitiesFileName, m_charInfo);
  +        }
  +      }
  +      catch (javax.xml.transform.TransformerException te)
  +      {
  +        throw new org.apache.xml.utils.WrappedRuntimeException(te);
  +      }
  +    }
     }
   
     /**
  @@ -1120,7 +1174,7 @@
   
     /**
      * If a character event is greater than this number, don't bother with
  -   *  the local buffer. 
  +   *  the local buffer.
      */
     static final int NUMBERBYTESTOWRITEDIRECT = (1024);