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...@daedelus.apache.org on 2000/12/31 11:07:18 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/transformer SerializerSwitcher.java

sboag       00/12/31 02:07:18

  Modified:    java/src/org/apache/xalan/transformer
                        SerializerSwitcher.java
  Log:
  Check the transformer output properties, NOT the stylesheet output
  properties (duh).
  
  Revision  Changes    Path
  1.7       +41 -38    xml-xalan/java/src/org/apache/xalan/transformer/SerializerSwitcher.java
  
  Index: SerializerSwitcher.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/SerializerSwitcher.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SerializerSwitcher.java	2000/12/13 17:23:02	1.6
  +++ SerializerSwitcher.java	2000/12/31 10:07:18	1.7
  @@ -86,7 +86,7 @@
      *
      * @param transformer Non-null transformer instance
      * @param ns Namespace URI of the element
  -   * @param localName Local part of name of element 
  +   * @param localName Local part of name of element
      *
      * @throws TransformerException
      */
  @@ -98,55 +98,58 @@
       if (null == transformer)
         return;
   
  -    StylesheetRoot stylesheet = transformer.getStylesheet();
  -
  -    if (null != stylesheet &&!stylesheet.isOutputMethodSet())
  +    if (((null == ns) || (ns.length() == 0))
  +            && localName.equalsIgnoreCase("html"))
       {
  -      if (((null == ns) || (ns.length() == 0))
  -              && localName.equalsIgnoreCase("html"))
  -      {
  -        OutputProperties oformat = stylesheet.getOutputComposed();
  -
  -        // Access at level of hashtable to see if the method has been set.
  -        if (null != oformat.getProperties().get(OutputKeys.METHOD))
  -          return;
  +      // System.out.println("transformer.getOutputPropertyNoDefault(OutputKeys.METHOD): "+
  +      //              transformer.getOutputPropertyNoDefault(OutputKeys.METHOD));     
  +      // Access at level of hashtable to see if the method has been set.
  +      if (null != transformer.getOutputPropertyNoDefault(OutputKeys.METHOD))
  +        return;
  +
  +      // Getting the output properties this way won't cause a clone of 
  +      // the properties.
  +      Properties prevProperties = transformer.getOutputFormat().getProperties();
  +      
  +      // We have to make sure we get an output properties with the proper 
  +      // defaults for the HTML method.  The easiest way to do this is to 
  +      // have the OutputProperties class do it.
  +      OutputProperties htmlOutputProperties = new OutputProperties(Method.HTML);
   
  -        OutputProperties htmlFormat;
  +      htmlOutputProperties.copyFrom(prevProperties, true);
  +      Properties htmlProperties = htmlOutputProperties.getProperties();
   
  -        htmlFormat = (OutputProperties)oformat.clone();
  -        htmlFormat.setProperty(OutputKeys.METHOD, Method.HTML);
  +      try
  +      {
  +        Serializer oldSerializer = transformer.getSerializer();
   
  -        try
  +        if (null != oldSerializer)
           {
  -          Serializer oldSerializer = transformer.getSerializer();
  +          Serializer serializer =
  +            SerializerFactory.getSerializer(htmlProperties);
   
  -          if (null != oldSerializer)
  -          {
  -            Serializer serializer =
  -              SerializerFactory.getSerializer(htmlFormat.getProperties());
  -            Writer writer = oldSerializer.getWriter();
  +          Writer writer = oldSerializer.getWriter();
   
  -            if (null != writer)
  -              serializer.setWriter(writer);
  -            else
  -            {
  -              OutputStream os = serializer.getOutputStream();
  +          if (null != writer)
  +            serializer.setWriter(writer);
  +          else
  +          {
  +            OutputStream os = serializer.getOutputStream();
   
  -              if (null != os)
  -                serializer.setOutputStream(os);
  -            }
  +            if (null != os)
  +              serializer.setOutputStream(os);
  +          }
   
  -            transformer.setSerializer(serializer);
  +          transformer.setSerializer(serializer);
   
  -            ContentHandler ch = serializer.asContentHandler();
  +          ContentHandler ch = serializer.asContentHandler();
   
  -            transformer.setContentHandler(ch);
  -          }
  +          transformer.setContentHandler(ch);
           }
  -        catch (java.io.IOException e)
  -        {
  -          throw new TransformerException(e);
  -        }
  +      }
  +      catch (java.io.IOException e)
  +      {
  +        throw new TransformerException(e);
         }
       }
     }