xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mk...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xalan/templates ElemApplyTemplates.java ElemAttribute.java ElemCopy.java ElemCopyOf.java ElemElement.java ElemExtensionCall.java ElemForEach.java ElemLiteralResult.java ElemTemplateElement.java ElemTextLiteral.java ElemValueOf.java OutputProperties.java StylesheetRoot.java output_html.properties output_text.properties output_xml.properties
Date Tue, 01 Apr 2003 20:16:28 GMT
mkwan       2003/04/01 12:16:28

  Modified:    java/src/org/apache/xalan/templates ElemApplyTemplates.java
                        ElemAttribute.java ElemCopy.java ElemCopyOf.java
                        ElemElement.java ElemExtensionCall.java
                        ElemForEach.java ElemLiteralResult.java
                        ElemTemplateElement.java ElemTextLiteral.java
                        ElemValueOf.java OutputProperties.java
                        StylesheetRoot.java
  Removed:     java/src/org/apache/xalan/templates output_html.properties
                        output_text.properties output_xml.properties
  Log:
  Merging XSLTC_DTM and common serializer to the head
  
  Changes in org.apache.xalan.templates.
  Replace ResultTreeHandler with SerializationHandler.
  
  Revision  Changes    Path
  1.29      +4 -4      xml-xalan/java/src/org/apache/xalan/templates/ElemApplyTemplates.java
  
  Index: ElemApplyTemplates.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemApplyTemplates.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ElemApplyTemplates.java	30 Jan 2003 18:45:50 -0000	1.28
  +++ ElemApplyTemplates.java	1 Apr 2003 20:16:26 -0000	1.29
  @@ -60,18 +60,17 @@
   
   import javax.xml.transform.TransformerException;
   
  -import org.apache.xalan.transformer.ResultTreeHandler;
   import org.apache.xalan.transformer.StackGuard;
   import org.apache.xalan.transformer.TransformerImpl;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
  +import org.apache.xml.serializer.SerializationHandler;
   import org.apache.xml.utils.IntStack;
   import org.apache.xml.utils.QName;
   import org.apache.xpath.VariableStack;
   import org.apache.xpath.XPath;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.objects.XObject;
  -import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
   
   /**
  @@ -268,8 +267,8 @@
                   new org.apache.xpath.objects.XNodeSet(sourceNodes));
         }
   
  -      final ResultTreeHandler rth = transformer.getResultTreeHandler();
  -      ContentHandler chandler = rth.getContentHandler();
  +      final SerializationHandler rth = transformer.getSerializationHandler();
  +//      ContentHandler chandler = rth.getContentHandler();
         final StylesheetRoot sroot = transformer.getStylesheet();
         final TemplateList tl = sroot.getTemplateListComposed();
         final boolean quiet = transformer.getQuietConflictWarnings();
  @@ -319,6 +318,7 @@
           }
           
           final int exNodeType = dtm.getExpandedTypeID(child);
  +
           final int nodeType = dtm.getNodeType(child);
   
           final QName mode = transformer.getMode();
  
  
  
  1.23      +14 -6     xml-xalan/java/src/org/apache/xalan/templates/ElemAttribute.java
  
  Index: ElemAttribute.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemAttribute.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- ElemAttribute.java	30 Jan 2003 18:45:50 -0000	1.22
  +++ ElemAttribute.java	1 Apr 2003 20:16:27 -0000	1.23
  @@ -59,8 +59,9 @@
   import javax.xml.transform.TransformerException;
   
   import org.apache.xalan.res.XSLTErrorResources;
  -import org.apache.xalan.transformer.ResultTreeHandler;
   import org.apache.xalan.transformer.TransformerImpl;
  +import org.apache.xml.serializer.NamespaceMappings;
  +import org.apache.xml.serializer.SerializationHandler;
   import org.apache.xml.utils.QName;
   
   import org.xml.sax.SAXException;
  @@ -114,7 +115,7 @@
             TransformerImpl transformer)
               throws TransformerException
     {
  -    ResultTreeHandler rhandler = transformer.getResultTreeHandler();
  +    SerializationHandler rhandler = transformer.getSerializationHandler();
   
       // If they are trying to add an attribute when there isn't an 
       // element pending, it is an error.
  @@ -154,7 +155,7 @@
      *
      * @return The prefix to be used.
      */
  -  protected String resolvePrefix(ResultTreeHandler rhandler,
  +  protected String resolvePrefix(SerializationHandler rhandler,
                                    String prefix, String nodeNamespace)
       throws TransformerException
     {
  @@ -170,7 +171,8 @@
         {
           if(nodeNamespace.length() > 0)
           {
  -          prefix = rhandler.getNewUniqueNSPrefix();
  +            NamespaceMappings prefixMapping = rhandler.getNamespaceMappings();
  +            prefix = prefixMapping.generateNextPrefix();
           }
           else
             prefix = "";
  @@ -215,7 +217,7 @@
   
       if(null != nodeName && nodeName.length() > 0)
       {
  -      ResultTreeHandler rhandler = transformer.getResultTreeHandler();
  +      SerializationHandler rhandler = transformer.getSerializationHandler();
         if(prefix != null && prefix.length() > 0)
         {
           try
  @@ -229,7 +231,13 @@
         }
         String val = transformer.transformToString(this);
         String localName = QName.getLocalPart(nodeName);
  -      rhandler.addAttribute(nodeNamespace, localName, nodeName, "CDATA", val);
  +      try 
  +      {
  +        rhandler.addAttribute(nodeNamespace, localName, nodeName, "CDATA", val);
  +      }
  +      catch (SAXException e)
  +      {
  +      }
       }
     }
   
  
  
  
  1.18      +4 -3      xml-xalan/java/src/org/apache/xalan/templates/ElemCopy.java
  
  Index: ElemCopy.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemCopy.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ElemCopy.java	30 Jan 2003 18:45:50 -0000	1.17
  +++ ElemCopy.java	1 Apr 2003 20:16:27 -0000	1.18
  @@ -59,9 +59,10 @@
   import javax.xml.transform.TransformerException;
   
   import org.apache.xalan.transformer.ClonerToResultTree;
  -import org.apache.xalan.transformer.ResultTreeHandler;
   import org.apache.xalan.transformer.TransformerImpl;
   import org.apache.xml.dtm.DTM;
  +import org.apache.xalan.serialize.SerializerUtils;
  +import org.apache.xml.serializer.SerializationHandler;
   import org.apache.xpath.XPathContext;
   
   /**
  @@ -136,7 +137,7 @@
   
         if ((DTM.DOCUMENT_NODE != nodeType) && (DTM.DOCUMENT_FRAGMENT_NODE != nodeType))
         {
  -        ResultTreeHandler rthandler = transformer.getResultTreeHandler();
  +        SerializationHandler rthandler = transformer.getSerializationHandler();
   
           if (TransformerImpl.S_DEBUG)
             transformer.getTraceManager().fireTraceEvent(this);
  @@ -148,7 +149,7 @@
           if (DTM.ELEMENT_NODE == nodeType)
           {
             super.execute(transformer);
  -          rthandler.processNSDecls(sourceNode, nodeType, dtm);
  +          SerializerUtils.processNSDecls(rthandler, sourceNode, nodeType, dtm);
             transformer.executeChildTemplates(this, true);
             
             String ns = dtm.getNamespaceURI(sourceNode);
  
  
  
  1.17      +6 -5      xml-xalan/java/src/org/apache/xalan/templates/ElemCopyOf.java
  
  Index: ElemCopyOf.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemCopyOf.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ElemCopyOf.java	30 Jan 2003 18:45:50 -0000	1.16
  +++ ElemCopyOf.java	1 Apr 2003 20:16:27 -0000	1.17
  @@ -59,12 +59,13 @@
   import javax.xml.transform.TransformerException;
   
   import org.apache.xalan.res.XSLTErrorResources;
  -import org.apache.xalan.transformer.ResultTreeHandler;
   import org.apache.xalan.transformer.TransformerImpl;
   import org.apache.xalan.transformer.TreeWalker2Result;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
   import org.apache.xml.dtm.ref.DTMTreeWalker;
  +import org.apache.xalan.serialize.SerializerUtils;
  +import org.apache.xml.serializer.SerializationHandler;
   import org.apache.xpath.XPath;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.objects.XObject;
  @@ -173,7 +174,7 @@
           transformer.getTraceManager().fireSelectedEvent(sourceNode, this,
                                                           "select", m_selectExpression, value);
   
  -      ResultTreeHandler handler = transformer.getResultTreeHandler();
  +      SerializationHandler handler = transformer.getSerializationHandler();
   
         if (null != value)
                           {
  @@ -215,7 +216,7 @@
               }
               else if (t == DTM.ATTRIBUTE_NODE)
               {
  -              handler.addAttribute(pos);
  +              SerializerUtils.addAttribute(handler, pos);
               }
               else
               {
  @@ -225,8 +226,8 @@
             // nl.detach();
             break;
           case XObject.CLASS_RTREEFRAG :
  -          handler.outputResultTreeFragment(value,
  -                                           transformer.getXPathContext());
  +          SerializerUtils.outputResultTreeFragment(
  +            handler, value, transformer.getXPathContext());
             break;
           default :
             
  
  
  
  1.30      +5 -5      xml-xalan/java/src/org/apache/xalan/templates/ElemElement.java
  
  Index: ElemElement.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemElement.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- ElemElement.java	30 Jan 2003 18:45:50 -0000	1.29
  +++ ElemElement.java	1 Apr 2003 20:16:27 -0000	1.30
  @@ -59,8 +59,8 @@
   import javax.xml.transform.TransformerException;
   
   import org.apache.xalan.res.XSLTErrorResources;
  -import org.apache.xalan.transformer.ResultTreeHandler;
   import org.apache.xalan.transformer.TransformerImpl;
  +import org.apache.xml.serializer.SerializationHandler;
   import org.apache.xml.utils.QName;
   import org.apache.xpath.XPathContext;
   import org.xml.sax.SAXException;
  @@ -242,7 +242,7 @@
      *
      * @return The prefix to be used.
      */
  -  protected String resolvePrefix(ResultTreeHandler rhandler,
  +  protected String resolvePrefix(SerializationHandler rhandler,
                                    String prefix, String nodeNamespace)
       throws TransformerException
     {
  @@ -278,7 +278,7 @@
       if (TransformerImpl.S_DEBUG)
         transformer.getTraceManager().fireTraceEvent(this);
         
  - 	ResultTreeHandler rhandler = transformer.getResultTreeHandler();
  + 	SerializationHandler rhandler = transformer.getSerializationHandler();
       XPathContext xctxt = transformer.getXPathContext();
       int sourceNode = xctxt.getCurrentNode();
       
  @@ -390,7 +390,7 @@
   
       try
       {
  -      ResultTreeHandler rhandler = transformer.getResultTreeHandler();
  +      SerializationHandler rhandler = transformer.getResultTreeHandler();
   
         if (null == nodeName)
         {
  @@ -409,7 +409,7 @@
           }
   
           rhandler.startElement(nodeNamespace, QName.getLocalPart(nodeName),
  -                              nodeName, null);
  +                              nodeName);
   
           super.execute(transformer);
   
  
  
  
  1.33      +2 -2      xml-xalan/java/src/org/apache/xalan/templates/ElemExtensionCall.java
  
  Index: ElemExtensionCall.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemExtensionCall.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- ElemExtensionCall.java	30 Jan 2003 18:45:50 -0000	1.32
  +++ ElemExtensionCall.java	1 Apr 2003 20:16:27 -0000	1.33
  @@ -291,9 +291,9 @@
           }
         }
       }
  -    catch(org.xml.sax.SAXException se)
  +    catch(TransformerException e)
       {
  -      transformer.getErrorListener().fatalError(new TransformerException(se));
  +      transformer.getErrorListener().fatalError(e);
       }
     }
   
  
  
  
  1.34      +0 -4      xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java
  
  Index: ElemForEach.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- ElemForEach.java	30 Jan 2003 18:45:50 -0000	1.33
  +++ ElemForEach.java	1 Apr 2003 20:16:27 -0000	1.34
  @@ -61,7 +61,6 @@
   import javax.xml.transform.TransformerException;
   
   import org.apache.xalan.transformer.NodeSorter;
  -import org.apache.xalan.transformer.ResultTreeHandler;
   import org.apache.xalan.transformer.TransformerImpl;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
  @@ -71,7 +70,6 @@
   import org.apache.xpath.ExpressionOwner;
   import org.apache.xpath.XPath;
   import org.apache.xpath.XPathContext;
  -import org.xml.sax.ContentHandler;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -375,8 +373,6 @@
                   new org.apache.xpath.objects.XNodeSet(sourceNodes));
         }
   
  -      final ResultTreeHandler rth = transformer.getResultTreeHandler();
  -      ContentHandler chandler = rth.getContentHandler();
   
         xctxt.pushCurrentNode(DTM.NULL);
   
  
  
  
  1.35      +3 -3      xml-xalan/java/src/org/apache/xalan/templates/ElemLiteralResult.java
  
  Index: ElemLiteralResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemLiteralResult.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- ElemLiteralResult.java	30 Jan 2003 18:45:50 -0000	1.34
  +++ ElemLiteralResult.java	1 Apr 2003 20:16:27 -0000	1.35
  @@ -61,8 +61,8 @@
   
   import javax.xml.transform.TransformerException;
   
  -import org.apache.xalan.transformer.ResultTreeHandler;
   import org.apache.xalan.transformer.TransformerImpl;
  +import org.apache.xml.serializer.SerializationHandler;
   import org.apache.xml.utils.StringVector;
   import org.apache.xpath.XPathContext;
   
  @@ -647,7 +647,7 @@
   
       try
       {
  -      ResultTreeHandler rhandler = transformer.getResultTreeHandler();
  +      SerializationHandler rhandler = transformer.getSerializationHandler();
   			
   			// JJK Bugzilla 3464, test namespace85 -- make sure LRE's
   			// namespace is asserted even if default, since xsl:element
  @@ -656,7 +656,7 @@
   
         // Add namespace declarations.
         executeNSDecls(transformer);
  -      rhandler.startElement(getNamespace(), getLocalName(), getRawName(), null);
  +      rhandler.startElement(getNamespace(), getLocalName(), getRawName());
   
         try
         {
  
  
  
  1.59      +3 -3      xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java
  
  Index: ElemTemplateElement.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- ElemTemplateElement.java	30 Jan 2003 18:45:51 -0000	1.58
  +++ ElemTemplateElement.java	1 Apr 2003 20:16:27 -0000	1.59
  @@ -65,8 +65,8 @@
   
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xalan.res.XSLTErrorResources;
  -import org.apache.xalan.transformer.ResultTreeHandler;
   import org.apache.xalan.transformer.TransformerImpl;
  +import org.apache.xml.serializer.SerializationHandler;
   import org.apache.xml.utils.PrefixResolver;
   import org.apache.xml.utils.UnImplNode;
   import org.apache.xpath.ExpressionNode;
  @@ -1208,7 +1208,7 @@
       {
         if (null != m_prefixTable)
         {
  -        ResultTreeHandler rhandler = transformer.getResultTreeHandler();
  +        SerializationHandler rhandler = transformer.getResultTreeHandler();
           int n = m_prefixTable.size();
   
           for (int i = n - 1; i >= 0; i--)
  @@ -1257,7 +1257,7 @@
       {
         if (null != m_prefixTable)
         {
  -        ResultTreeHandler rhandler = transformer.getResultTreeHandler();
  +        SerializationHandler rhandler = transformer.getResultTreeHandler();
           int n = m_prefixTable.size();
   
           for (int i = 0; i < n; i++)
  
  
  
  1.13      +2 -2      xml-xalan/java/src/org/apache/xalan/templates/ElemTextLiteral.java
  
  Index: ElemTextLiteral.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemTextLiteral.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ElemTextLiteral.java	30 Jan 2003 18:45:51 -0000	1.12
  +++ ElemTextLiteral.java	1 Apr 2003 20:16:27 -0000	1.13
  @@ -58,8 +58,8 @@
   
   import javax.xml.transform.TransformerException;
   
  -import org.apache.xalan.transformer.ResultTreeHandler;
   import org.apache.xalan.transformer.TransformerImpl;
  +import org.apache.xml.serializer.SerializationHandler;
   import org.xml.sax.SAXException;
   
   /**
  @@ -242,7 +242,7 @@
         transformer.getTraceManager().fireTraceEvent(this);
       try
       {
  -      ResultTreeHandler rth = transformer.getResultTreeHandler();
  +      SerializationHandler rth = transformer.getResultTreeHandler();
         if (m_disableOutputEscaping)
         {
           rth.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING,
"");
  
  
  
  1.22      +2 -2      xml-xalan/java/src/org/apache/xalan/templates/ElemValueOf.java
  
  Index: ElemValueOf.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemValueOf.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- ElemValueOf.java	30 Jan 2003 18:45:51 -0000	1.21
  +++ ElemValueOf.java	1 Apr 2003 20:16:27 -0000	1.22
  @@ -59,9 +59,9 @@
   import javax.xml.transform.TransformerException;
   
   import org.apache.xalan.res.XSLTErrorResources;
  -import org.apache.xalan.transformer.ResultTreeHandler;
   import org.apache.xalan.transformer.TransformerImpl;
   import org.apache.xml.dtm.DTM;
  +import org.apache.xml.serializer.SerializationHandler;
   import org.apache.xpath.Expression;
   import org.apache.xpath.XPath;
   import org.apache.xpath.XPathContext;
  @@ -250,7 +250,7 @@
     {
   
       XPathContext xctxt = transformer.getXPathContext();
  -    ResultTreeHandler rth = transformer.getResultTreeHandler();
  +    SerializationHandler rth = transformer.getResultTreeHandler();
   
       if (TransformerImpl.S_DEBUG)
         transformer.getTraceManager().fireTraceEvent(this);
  
  
  
  1.28      +34 -415   xml-xalan/java/src/org/apache/xalan/templates/OutputProperties.java
  
  Index: OutputProperties.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/OutputProperties.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- OutputProperties.java	30 Jan 2003 18:45:51 -0000	1.27
  +++ OutputProperties.java	1 Apr 2003 20:16:27 -0000	1.28
  @@ -56,9 +56,6 @@
    */
   package org.apache.xalan.templates;
   
  -import java.io.BufferedInputStream;
  -import java.io.IOException;
  -import java.io.InputStream;
   import java.util.Enumeration;
   import java.util.Properties;
   import java.util.Vector;
  @@ -68,10 +65,10 @@
   
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xalan.res.XSLTErrorResources;
  -import org.apache.xalan.serialize.Method;
  +import org.apache.xml.serializer.OutputPropertiesFactory;
  +import org.apache.xml.serializer.OutputPropertyUtils;
   import org.apache.xml.utils.FastStringBuffer;
   import org.apache.xml.utils.QName;
  -import org.apache.xml.utils.WrappedRuntimeException;
   
   /**
    * This class provides information from xsl:output elements. It is mainly
  @@ -94,7 +91,7 @@
      */
     public OutputProperties()
     {
  -    this(Method.XML);
  +    this(org.apache.xml.serializer.Method.XML);
     }
   
     /**
  @@ -119,308 +116,8 @@
      */
     public OutputProperties(String method)
     {
  -    m_properties = new Properties(getDefaultMethodProperties(method));
  -  }
  -  
  -  static final String S_XSLT_PREFIX = "xslt.output.";
  -  static final int S_XSLT_PREFIX_LEN = S_XSLT_PREFIX.length();
  -  static final String S_XALAN_PREFIX = "org.apache.xslt.";
  -  static final int S_XALAN_PREFIX_LEN = S_XALAN_PREFIX.length();
  -  
  -  /** Built-in extensions namespace, reexpressed in {namespaceURI} syntax
  -   * suitable for prepending to a localname to produce a "universal
  -   * name".
  -   */
  -  static final String S_BUILTIN_EXTENSIONS_UNIVERSAL=
  -        "{"+Constants.S_BUILTIN_EXTENSIONS_URL+"}";
  -  
  -  /**
  -   * The old built-in extension namespace
  -   */
  -  static final String S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL=
  -        "{"+Constants.S_BUILTIN_OLD_EXTENSIONS_URL+"}";
  -  
  -  static final int S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN = S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL.length();
  -  
  -  /**
  -   * Fix up a string in an output properties file according to 
  -   * the rules of {@link #loadPropertiesFile}.
  -   * 
  -   * @param s non-null reference to string that may need to be fixed up.
  -   * @return A new string if fixup occured, otherwise the s argument.
  -   */
  -  static private String fixupPropertyString(String s, boolean doClipping)
  -  {
  -    int index;
  -    if (doClipping && s.startsWith(S_XSLT_PREFIX))
  -    {
  -      s = s.substring(S_XSLT_PREFIX_LEN);
  -    }
  -    if (s.startsWith(S_XALAN_PREFIX))
  -    {
  -      s = S_BUILTIN_EXTENSIONS_UNIVERSAL + s.substring(S_XALAN_PREFIX_LEN);
  -    }
  -    if ((index = s.indexOf("\\u003a")) > 0)
  -    {
  -      String temp = s.substring(index+6);
  -      s = s.substring(0, index) + ":" + temp;
  -
  -    }
  -    return s;
  -  }
  -  
  -  /**
  -   * Load the properties file from a resource stream.  If a 
  -   * key name such as "org.apache.xslt.xxx", fix up the start of 
  -   * string to be a curly namespace.  If a key name starts with 
  -   * "xslt.output.xxx", clip off "xslt.output.".  If a key name *or* a 
  -   * key value is discovered, check for \u003a in the text, and 
  -   * fix it up to be ":", since earlier versions of the JDK do not 
  -   * handle the escape sequence (at least in key names).
  -   * 
  -   * @param resourceName non-null reference to resource name.
  -   * @param defaults Default properties, which may be null.
  -   */
  -  static private Properties loadPropertiesFile(final String resourceName, Properties defaults)
  -    throws IOException
  -  {
  -
  -    // This static method should eventually be moved to a thread-specific class
  -    // so that we can cache the ContextClassLoader and bottleneck all properties file
  -    // loading throughout Xalan.
  -
  -    Properties props = new Properties(defaults);
  -
  -    InputStream is = null;
  -    BufferedInputStream bis = null;
  -    Class accessControllerClass = null;
  -
  -    try {
  -      try {
  -	try {	
  -
  -	  // This Class was introduced in JDK 1.2. With the re-architecture of
  -	  // security mechanism ( starting in JDK 1.2 ), we have option of
  -	  // giving privileges to certain part of code using doPrivileged block.
  -	  // In JDK1.1.X applications won't be having security manager and if 
  -	  // there is security manager ( in applets ), code need to be signed
  -	  // and trusted for having access to resources. 
  -
  -	  accessControllerClass=Class.forName("java.security.AccessController"); 
  -
  -	  // If we are here means user is using JDK >= 1.2. 
  -	  // Using doPrivileged to be able to read property file without opening
  -          // up secured container permissions like J2EE container
  -
  -	  is =(InputStream)java.security.AccessController.doPrivileged (
  -            new java.security.PrivilegedAction() {
  -
  -            public Object run() {
  -              try {
  -                java.lang.reflect.Method getCCL = Thread.class.getMethod(
  -                    "getContextClassLoader", NO_CLASSES);
  -                if (getCCL != null) {
  -                  ClassLoader contextClassLoader = (ClassLoader)
  -                      getCCL.invoke(Thread.currentThread(), NO_OBJS);
  -                  return ( contextClassLoader.getResourceAsStream (
  -                      "org/apache/xalan/templates/" + resourceName) );
  -                }
  -              } catch ( Exception e ) { }
  -
  -              return null;
  -
  -            }
  -          });
  -	} catch ( ClassNotFoundException e ) {
  -	  //User may be using older JDK ( JDK <1.2 ). Allow him/her to use it.  
  -	  // But don't try to use doPrivileged
  -	  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/templates/" + resourceName );
  -                }
  -	  } catch ( Exception exception ) { }
  -	}	  
  -      }
  -      catch (Exception e) {}
  -
  -      if ( is == null ) {
  -	if ( accessControllerClass != null ) {
  -          is=(InputStream)java.security.AccessController.doPrivileged( 
  -	      new java.security.PrivilegedAction(){
  -	    public Object run() {
  -              return OutputProperties.class.getResourceAsStream(resourceName);
  -            }
  -          });
  -	} else {
  -	  // User may be using older JDK ( JDK < 1.2 )
  -	  is = OutputProperties.class.getResourceAsStream(resourceName);
  -	}
  -      }
  -      
  -      bis = new BufferedInputStream(is);
  -      props.load(bis);
  -    } 
  -    catch (IOException ioe) {
  -      if ( defaults == null ) {
  -        throw ioe;
  -      }
  -      else {
  -        throw new WrappedRuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_COULD_NOT_LOAD_RESOURCE,
new Object[]{resourceName}), ioe); //"Could not load '"+resourceName+"' (check CLASSPATH),
now using just the defaults ", ioe);
  -      }
  -    }
  -    catch (SecurityException se) {
  -      // Repeat IOException handling for sandbox/applet case -sc
  -      if ( defaults == null ) {
  -        throw se;
  -      }
  -      else {
  -        throw new WrappedRuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_COULD_NOT_LOAD_RESOURCE,
new Object[]{resourceName}), se); //"Could not load '"+resourceName+"' (check CLASSPATH, applet
security), now using just the defaults ", se);
  -      }
  -    } 
  -    finally {
  -      if ( bis != null ) {
  -        bis.close();
  -      }
  -      if (is != null ) {
  -        is.close();
  -      }
  -    }
  -    
  -    // Note that we're working at the HashTable level here, 
  -    // and not at the Properties level!  This is important 
  -    // because we don't want to modify the default properties.
  -    // NB: If fixupPropertyString ends up changing the property
  -    // name or value, we need to remove the old key and re-add
  -    // with the new key and value.  However, then our Enumeration
  -    // could lose its place in the HashTable.  So, we first
  -    // clone the HashTable and enumerate over that since the
  -    // clone will not change.  When we migrate to Collections,
  -    // this code should be revisited and cleaned up to use
  -    // an Iterator which may (or may not) alleviate the need for
  -    // the clone.  Many thanks to Padraig O'hIceadha
  -    // <padraig@gradient.ie> for finding this problem.  Bugzilla 2000.
  -
  -    Enumeration keys = ((Properties) props.clone()).keys();
  -    while(keys.hasMoreElements())
  -    {
  -      String key = (String)keys.nextElement();
  -      // Now check if the given key was specified as a 
  -      // System property. If so, the system property 
  -      // overides the default value in the propery file.
  -      String value = null;
  -      try {
  -        value = System.getProperty(key);
  -      }
  -      catch (SecurityException se) {
  -        // No-op for sandbox/applet case, leave null -sc
  -      }
  -      if (value == null)      
  -        value = (String)props.get(key);                       
  -      
  -      String newKey = fixupPropertyString(key, true);
  -      String newValue = null;
  -      try {
  -        newValue = System.getProperty(newKey);
  -      }
  -      catch (SecurityException se) {
  -        // No-op for sandbox/applet case, leave null -sc
  -      }
  -      if (newValue == null)
  -        newValue = fixupPropertyString(value, false);
  -      else
  -        newValue = fixupPropertyString(newValue, false);
  -       
  -      if(key != newKey || value != newValue)
  -      {
  -        props.remove(key);
  -        props.put(newKey, newValue);
  -      }
  -      
  -    }
  -    
  -    return props;
  -  }
  -
  -  /**
  -   * Creates an empty OutputProperties with the defaults specified by
  -   * a property file.  The method argument is used to construct a string of
  -   * the form output_[method].properties (for instance, output_html.properties).
  -   * The output_xml.properties file is always used as the base.
  -   * <p>At the moment, anything other than 'text', 'xml', and 'html', will
  -   * use the output_xml.properties file.</p>
  -   *
  -   * @param   method non-null reference to method name.
  -   *
  -   * @return Properties object that holds the defaults for the given method.
  -   */
  -  static public Properties getDefaultMethodProperties(String method)
  -  {
  -    String fileName = null;
  -    Properties defaultProperties = null;
  -    // According to this article : Double-check locking does not work
  -    // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html
  -    try
  -    {
  -      synchronized (m_synch_object)
  -      {
  -        if (null == m_xml_properties)  // double check
  -        {
  -          fileName = "output_xml.properties";
  -          m_xml_properties = loadPropertiesFile(fileName, null);
  -        }
  -      }
  -
  -      if (method.equals(Method.XML))
  -      {
  -        defaultProperties = m_xml_properties;
  -      }
  -      else if (method.equals(Method.HTML))
  -      {
  -            if (null == m_html_properties)  // double check
  -            {
  -              fileName = "output_html.properties";
  -              m_html_properties = loadPropertiesFile(fileName,
  -                                                     m_xml_properties);
  -            }
  -
  -        defaultProperties = m_html_properties;
  -      }
  -      else if (method.equals(Method.Text))
  -      {
  -            if (null == m_text_properties)  // double check
  -            {
  -              fileName = "output_text.properties";
  -              m_text_properties = loadPropertiesFile(fileName,
  -                                                     m_xml_properties);
  -              if(null == m_text_properties.getProperty(OutputKeys.ENCODING))
  -              {
  -                String mimeEncoding = org.apache.xalan.serialize.Encodings.getMimeEncoding(null);
  -                m_text_properties.put(OutputKeys.ENCODING, mimeEncoding);
  -              }
  -            }
  -
  -        defaultProperties = m_text_properties;
  -      }
  -      else
  -      {
  -
  -        // TODO: Calculate res file from name.
  -        defaultProperties = m_xml_properties;
  -      }
  -    }
  -    catch (IOException ioe)
  -    {
  -      throw new WrappedRuntimeException(
  -            "Output method is "+method+" could not load "+fileName+" (check CLASSPATH)",
  -             ioe);
  -    }
  -
  -    return defaultProperties;
  +    m_properties = new Properties(
  +        OutputPropertiesFactory.getDefaultMethodProperties(method));
     }
   
     /**
  @@ -473,8 +170,9 @@
         setMethodDefaults(value);
       }
       
  -    if (key.startsWith(S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL))
  -      key = S_BUILTIN_EXTENSIONS_UNIVERSAL + key.substring(S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN);
  +    if (key.startsWith(OutputPropertiesFactory.S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL))
  +      key = OutputPropertiesFactory.S_BUILTIN_EXTENSIONS_UNIVERSAL
  +         + key.substring(OutputPropertiesFactory.S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN);
       
       m_properties.put(key, value);
     }
  @@ -502,10 +200,11 @@
      * @param   key   the property key.
      * @return  the value in this property list with the specified key value.
      */
  -  public String getProperty(String key)
  +  public String getProperty(String key) 
     {
  -    if (key.startsWith(S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL))
  -      key = S_BUILTIN_EXTENSIONS_UNIVERSAL + key.substring(S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN);
  +    if (key.startsWith(OutputPropertiesFactory.S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL))
  +      key = OutputPropertiesFactory.S_BUILTIN_EXTENSIONS_UNIVERSAL 
  +        + key.substring(OutputPropertiesFactory.S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN);
       return m_properties.getProperty(key);
     }
   
  @@ -562,33 +261,10 @@
      */
     public boolean getBooleanProperty(String key)
     {
  -    return getBooleanProperty(key, m_properties);
  +    return OutputPropertyUtils.getBooleanProperty(key, m_properties);
     }
   
     /**
  -   * Searches for the boolean property with the specified key in the property list.
  -   * If the key is not found in this property list, the default property list,
  -   * and its defaults, recursively, are then checked. The method returns
  -   * <code>false</code> if the property is not found, or if the value is other
  -   * than "yes".
  -   *
  -   * @param   key   the property key.
  -   * @param   props   the list of properties that will be searched.
  -   * @return  the value in this property list as a boolean value, or false
  -   * if null or not "yes".
  -   */
  -  public static boolean getBooleanProperty(String key, Properties props)
  -  {
  -
  -    String s = props.getProperty(key);
  -
  -    if (null == s ||!s.equals("yes"))
  -      return false;
  -    else
  -      return true;
  -  }
  -  
  -  /**
      * Set an output property.
      *
      * @param key the key to be placed into the property list.
  @@ -641,31 +317,9 @@
      */
     public int getIntProperty(String key)
     {
  -    return getIntProperty(key, m_properties);
  +    return OutputPropertyUtils.getIntProperty(key, m_properties);
     }
   
  -  /**
  -   * Searches for the int property with the specified key in the property list.
  -   * If the key is not found in this property list, the default property list,
  -   * and its defaults, recursively, are then checked. The method returns
  -   * <code>false</code> if the property is not found, or if the value is other
  -   * than "yes".
  -   *
  -   * @param   key   the property key.
  -   * @param   props   the list of properties that will be searched.
  -   * @return  the value in this property list as a int value, or 0
  -   * if null or not a number.
  -   */
  -  public static int getIntProperty(String key, Properties props)
  -  {
  -
  -    String s = props.getProperty(key);
  -
  -    if (null == s)
  -      return 0;
  -    else
  -      return Integer.parseInt(s);
  -  }
   
     /**
      * Set an output property with a QName value.  The QName will be turned
  @@ -688,14 +342,25 @@
      */
     public void setMethodDefaults(String method)
     {
  -    String defaultMethod = m_properties.getProperty(OutputKeys.METHOD);
  -    if((null == defaultMethod) || !defaultMethod.equals(method))
  -    {
  -      Properties savedProps = m_properties;
  -      Properties newDefaults = getDefaultMethodProperties(method);
  -      m_properties = new Properties(newDefaults);
  -      copyFrom(savedProps, false);
  -    }
  +        String defaultMethod = m_properties.getProperty(OutputKeys.METHOD);
  + 
  +        if((null == defaultMethod) || !defaultMethod.equals(method)
  +         // bjm - add the next condition as a hack
  +         // but it is because both output_xml.properties and
  +         // output_unknown.properties have the same method=xml
  +         // for their default. Otherwise we end up with
  +         // a ToUnknownStream wraping a ToXMLStream even
  +         // when the users says method="xml"
  +         //
  +         || defaultMethod.equals("xml")
  +         )
  +        {
  +            Properties savedProps = m_properties;
  +            Properties newDefaults = 
  +                OutputPropertiesFactory.getDefaultMethodProperties(method);
  +            m_properties = new Properties(newDefaults);
  +            copyFrom(savedProps, false);
  +        }
     }
     
   
  @@ -1014,7 +679,7 @@
      *
      * @return true if key is legal.
      */
  -  public boolean isLegalPropertyKey(String key)
  +  public static boolean isLegalPropertyKey(String key)
     {
   
       return (key.equals(OutputKeys.CDATA_SECTION_ELEMENTS)
  @@ -1034,51 +699,5 @@
      *  @serial */
     private Properties m_properties = null;
   
  -  // Some special Xalan keys.
  -
  -  /** The number of whitespaces to indent by, if indent="yes". */
  -  public static String S_KEY_INDENT_AMOUNT =
  -    S_BUILTIN_EXTENSIONS_UNIVERSAL+"indent-amount";
  -
  -  /**
  -   * Fully qualified name of class with a default constructor that
  -   *  implements the ContentHandler interface, where the result tree events
  -   *  will be sent to.      
  -   */
  -  public static String S_KEY_CONTENT_HANDLER =
  -    S_BUILTIN_EXTENSIONS_UNIVERSAL+"content-handler";
  -
  -  /** File name of file that specifies character to entity reference mappings. */
  -  public static String S_KEY_ENTITIES =
  -    S_BUILTIN_EXTENSIONS_UNIVERSAL+"entities";
  -
  -  /** Use a value of "yes" if the href values for HTML serialization should 
  -   *  use %xx escaping. */
  -  public static String S_USE_URL_ESCAPING =
  -    S_BUILTIN_EXTENSIONS_UNIVERSAL+"use-url-escaping";
  -
  -  /** Use a value of "yes" if the META tag should be omitted where it would
  -   *  otherwise be supplied.
  -   */
  -  public static String S_OMIT_META_TAG =
  -    S_BUILTIN_EXTENSIONS_UNIVERSAL+"omit-meta-tag";
  -
  -  /** The default properties of all output files. */
  -  private static Properties m_xml_properties = null;
  -
  -  /** The default properties when method="html". */
  -  private static Properties m_html_properties = null;
  -
  -  /** The default properties when method="text". */
  -  private static Properties m_text_properties = null;
  -
  -  /** Synchronization object for lazy initialization of the above tables. */
  -  private static Integer m_synch_object = new Integer(1);
  -
  -  /** a zero length Class array used in loadPropertiesFile() */
  -  private static final Class[] NO_CLASSES = new Class[0];
  -
  -  /** a zero length Object array used in loadPropertiesFile() */
  -  private static final Object[] NO_OBJS = new Object[0];
   
   }
  
  
  
  1.50      +4 -2      xml-xalan/java/src/org/apache/xalan/templates/StylesheetRoot.java
  
  Index: StylesheetRoot.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/StylesheetRoot.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- StylesheetRoot.java	30 Jan 2003 18:45:51 -0000	1.49
  +++ StylesheetRoot.java	1 Apr 2003 20:16:27 -0000	1.50
  @@ -71,7 +71,7 @@
   import org.apache.xalan.processor.XSLTSchema;
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xalan.res.XSLTErrorResources;
  -import org.apache.xalan.serialize.Method;
  +
   import org.apache.xalan.transformer.TransformerImpl;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.ref.ExpandedNameTable;
  @@ -281,7 +281,9 @@
   
       // We set up the global variables that will hold the recomposed information.
   
  -    m_outputProperties = new OutputProperties(Method.XML);
  +
  +    m_outputProperties = new OutputProperties(org.apache.xml.serializer.Method.UNKNOWN);
  +//  m_outputProperties = new OutputProperties(Method.XML);
       
       m_attrSets = new Hashtable();
       m_decimalFormatSymbols = new Hashtable();
  
  
  

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


Mime
View raw message