cziegeler    2004/03/17 04:26:59

  Modified:    src/java/org/apache/cocoon/xml XMLUtils.java
               src/java/org/apache/cocoon/xml/dom DocumentWrapper.java
               src/java/org/apache/cocoon/transformation
                        CIncludeTransformer.java
                        SourceWritingTransformer.java
                        AbstractSAXTransformer.java
               src/java/org/apache/cocoon/components/source SourceUtil.java
  Log:
  Don't use hard-coded encoding for serializing dom to string (addresses bug 
26924)
  
  Revision  Changes    Path
  1.6       +24 -45    cocoon-2.2/src/java/org/apache/cocoon/xml/XMLUtils.java
  
  Index: XMLUtils.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/xml/XMLUtils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XMLUtils.java     8 Mar 2004 14:04:00 -0000       1.5
  +++ XMLUtils.java     17 Mar 2004 12:26:59 -0000      1.6
  @@ -122,10 +122,14 @@
        * @return an <code>XMLConsumer</code> for <code>ch</code> an 
<code>lh</code>
        */
       public static XMLConsumer getConsumer(ContentHandler ch, LexicalHandler 
lh) {
  -        if (ch instanceof XMLConsumer)
  +        if (ch instanceof XMLConsumer) {
               return (XMLConsumer)ch;
  -        else
  +        } else {
  +            if ( lh == null && ch instanceof LexicalHandler ) {
  +                lh = (LexicalHandler)ch;
  +            }
               return new ContentHandlerWrapper(ch, lh);
  +        }
       }
   
       /**
  @@ -141,45 +145,20 @@
       }
   
       /**
  -     * Serialize a DOM node to a String.
  -     * The defaultSerializeToXMLFormat() is used to format the serialized 
xml.
  -     */
  -    public static String serializeNodeToXML(Node node)
  -    throws ProcessingException {
  -        return serializeNode(node, XMLUtils.defaultSerializeToXMLFormat());
  -    }
  -
  -    /**
  -     * This is the default properties set used to serialize xml.
  -     * It is used by the serializeNodeToXML() method.
  -     * The format is as follows:
  -     * Method: xml
  -     * Encoding: ISO-8859-1
  -     * Omit xml declaration: no
  -     * Indent: yes
  -     */
  -    public static Properties defaultSerializeToXMLFormat() {
  -        return defaultSerializeToXMLFormat(false);
  -    }
  -
  -    /**
  -     * This is the default properties set used to serialize xml.
  -     * It is used by the serializeNodeToXML() method.
  +     * Create a new properties set for serializing xml
        * The omit xml declaration property can be controlled by the flag.
        * Method: xml
  -     * Encoding: ISO-8859-1
        * Omit xml declaration: according to the flag
        * Indent: yes
        */
  -    public static Properties defaultSerializeToXMLFormat(boolean 
omitXMLDeclaration) {
  -        Properties format = new Properties();
  +    public static Properties createPropertiesForXML(boolean 
omitXMLDeclaration) {
  +        final Properties format = new Properties();
           format.put(OutputKeys.METHOD, "xml");
  -        format.put(OutputKeys.ENCODING, "ISO-8859-1");
           format.put(OutputKeys.OMIT_XML_DECLARATION, (omitXMLDeclaration ? 
"yes" : "no"));
           format.put(OutputKeys.INDENT, "yes");
  -        return format;
  +        return format;        
       }
  -
  +    
       /**
        * Serialize a DOM node to a String.
        * The format of the output can be specified with the properties.
  @@ -347,7 +326,7 @@
        * @param localName The local name (without prefix)
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        */
       public static void createElement(ContentHandler contentHandler, String 
localName) 
       throws SAXException {
  @@ -363,7 +342,7 @@
        * @param stringValue The content of the Element
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        */
       public static void createElement(ContentHandler contentHandler, String 
localName, String stringValue)
           throws SAXException {
  @@ -381,7 +360,7 @@
        *        Attributes object.
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        * @see org.xml.sax.Attributes
        */
       public static void createElement(ContentHandler contentHandler, String 
localName, Attributes atts) 
  @@ -401,7 +380,7 @@
        * @param stringValue The content of the Element
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        * @see org.xml.sax.Attributes
        */
       public static void createElement(ContentHandler contentHandler, String 
localName, Attributes atts, String stringValue)
  @@ -417,7 +396,7 @@
        * @param localName The local name (without prefix)
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        */
       public static void createElementNS(ContentHandler contentHandler, String 
namespaceURI, String localName)
           throws SAXException {
  @@ -433,7 +412,7 @@
        * @param stringValue The content of the Element
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        */
       public static void createElementNS(
           ContentHandler contentHandler,
  @@ -455,7 +434,7 @@
        *        Attributes object.
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        * @see org.xml.sax.Attributes
        */
       public static void createElementNS(
  @@ -479,7 +458,7 @@
        * @param stringValue The content of the Element
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        * @see org.xml.sax.Attributes
        */
       public static void createElementNS(
  @@ -530,7 +509,7 @@
        * @param localName The local name (without prefix)
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        */
       public static void startElement(ContentHandler contentHandler, String 
localName) 
       throws SAXException {
  @@ -545,7 +524,7 @@
        * @param localName The local name (without prefix)
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        */
       public static void startElement(ContentHandler contentHandler, String 
namespaceURI, String localName)
       throws SAXException {
  @@ -561,7 +540,7 @@
        *        Attributes object.
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        * @see org.xml.sax.Attributes
        */
       public static void startElement(ContentHandler contentHandler, String 
localName, Attributes atts) 
  @@ -580,7 +559,7 @@
        *        Attributes object.
        * @exception org.xml.sax.SAXException Any SAX exception, possibly
        *            wrapping another exception.
  -     * @see #endElement
  +     * @see #endElement(ContentHandler, String)
        * @see org.xml.sax.Attributes
        */
       public static void startElement(ContentHandler contentHandler, String 
namespaceURI, String localName, Attributes atts)
  
  
  
  1.4       +2 -2      
cocoon-2.2/src/java/org/apache/cocoon/xml/dom/DocumentWrapper.java
  
  Index: DocumentWrapper.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/xml/dom/DocumentWrapper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DocumentWrapper.java      8 Mar 2004 14:04:01 -0000       1.3
  +++ DocumentWrapper.java      17 Mar 2004 12:26:59 -0000      1.4
  @@ -71,7 +71,7 @@
   
       public String toString() {
           try {
  -            return XMLUtils.serializeNodeToXML(this.document);
  +            return XMLUtils.serializeNode(this.document, 
XMLUtils.createPropertiesForXML(false));
           } catch (ProcessingException e) {
           }
           return "";
  
  
  
  1.14      +11 -11    
cocoon-2.2/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java
  
  Index: CIncludeTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- CIncludeTransformer.java  8 Mar 2004 14:03:31 -0000       1.13
  +++ CIncludeTransformer.java  17 Mar 2004 12:26:59 -0000      1.14
  @@ -76,14 +76,14 @@
    *         <!-- more can follow -->
    *     </cinclude:parameters>
    * </cinclude:includexml>
  - *
  + * 
    *
    * This transformer also supports caching of the included content.
    * Therefore it triggers for the element <code>cached-include</code> in the
    * namespace "http://apache.org/cocoon/include/1.0";.
    * The <code>src</code> attribute contains the url which points to
    * an xml resource which is include instead of the element.
  - * First, it works like the usual include command. But it can be
  + * First, it works like the usual include command. But it can be 
    * configured with various parameters:
    * The most important one is the <code>expires</code> parameter.
    * If (and only if) this is set to a value greater than zero,
  @@ -102,13 +102,13 @@
    * in a series.
    * With the optional parameter <code>preemptive</code> set to 
<code>true</code>
    * a pre-emptive caching is activated. When a resource is requested with
  - * pre-emptive caching, this transformer always attempts to get the
  + * pre-emptive caching, this transformer always attempts to get the 
    * content from the cache. If the content is not in the cache, it is
    * of course retrieved from the original source and cached.
    * If the cached resource has expired, it is still provided. The cache
    * is updated by a background task. This task has to be started
    * beforehand.
  - *
  + * 
    * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Andrew C. Oliver</a>
    * @version CVS $Id$
  @@ -118,7 +118,7 @@
    * @x-avalon.lifestyle type="pooled"
    * @x-avalon.info name="cinclude-transformer"
    */
  -public class CIncludeTransformer
  +public class CIncludeTransformer 
   extends AbstractSAXTransformer
   implements Disposable, CacheableProcessingComponent {
   
  @@ -147,13 +147,13 @@
   
       /** The configuration of includexml */
       protected Parameters configurationParameters;
  -
  +    
       /** The parameters for includexml */
       protected SourceParameters resourceParameters;
  -
  +    
       /** The current state: STATE_ */
       protected int state;
  -
  +    
       protected IncludeCacheManager cacheManager;
   
       protected IncludeCacheManagerSession cachingSession;
  @@ -240,7 +240,7 @@
           this.configurationParameters = null;
           this.resourceParameters = null;
           if (this.getLogger().isErrorEnabled()) {
  -            this.getLogger().debug("Finishing CIncludeTransformer, time: " + 
(System.currentTimeMillis() - this.startTime));
  +            this.getLogger().debug("Finishing CachingCIncludeTransformer, 
time: " + (System.currentTimeMillis() - this.startTime));
               this.startTime = 0;
           }
           this.filter = null;
  @@ -299,7 +299,7 @@
           // parameter value
           } else if (name.equals(CINCLUDE_VALUE_ELEMENT)
                      && this.state == STATE_INCLUDE) {
  -            
this.startSerializedXMLRecording(XMLUtils.defaultSerializeToXMLFormat(true));
  +            
this.startSerializedXMLRecording(XMLUtils.createPropertiesForXML(true));
   
          } else if (name.equals(CINCLUDE_CACHED_INCLUDE_ELEMENT)) {
   
  
  
  
  1.11      +2 -2      
cocoon-2.2/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java
  
  Index: SourceWritingTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SourceWritingTransformer.java     8 Mar 2004 14:03:31 -0000       1.10
  +++ SourceWritingTransformer.java     17 Mar 2004 12:26:59 -0000      1.11
  @@ -582,7 +582,7 @@
                                 ", create="+create+
                                 ", overwrite="+overwrite+
                                 ", reinsert="+reinsertPath+
  -                              ", fragment="+(fragment == null ? "null" : 
XMLUtils.serializeNodeToXML(fragment)));
  +                              ", fragment="+(fragment == null ? "null" : 
XMLUtils.serializeNode(fragment, XMLUtils.createPropertiesForXML(false))));
           }
           // test parameter
           if (systemID == null) {
  
  
  
  1.11      +111 -96   
cocoon-2.2/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java
  
  Index: AbstractSAXTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AbstractSAXTransformer.java       8 Mar 2004 14:03:31 -0000       1.10
  +++ AbstractSAXTransformer.java       17 Mar 2004 12:26:59 -0000      1.11
  @@ -166,20 +166,15 @@
       /** The current prefix for our namespace */
       private String ourPrefix;
       
  -    /**
  -     * Avalon Configurable Interface
  +    /* (non-Javadoc)
  +     * @see 
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
        */
       public void configure(Configuration configuration)
       throws ConfigurationException {
       }
   
  -    /**
  -     * Setup the next round.
  -     * The instance variables are initialised.
  -     * @param resolver The current SourceResolver
  -     * @param objectModel The objectModel of the environment.
  -     * @param src The value of the src attribute in the sitemap.
  -     * @param par The parameters from the sitemap.
  +    /* (non-Javadoc)
  +     * @see 
org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver,
 java.util.Map, java.lang.String, 
org.apache.avalon.framework.parameters.Parameters)
        */
       public void setup(SourceResolver resolver,
                         Map            objectModel,
  @@ -209,7 +204,8 @@
           this.isInitialized = false;
   
           // get the current namespace
  -        this.namespaceURI = this.parameters.getParameter("namespaceURI", 
this.defaultNamespaceURI);
  +        this.namespaceURI = this.parameters.getParameter("namespaceURI",
  +                    this.defaultNamespaceURI);
   
           this.ignoreHooksCount = 0;
           this.ignoreEventsCount = 0;
  @@ -221,8 +217,8 @@
           }
       }
   
  -    /**
  -     *  Recycle this component.
  +    /* (non-Javadoc)
  +     * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
        */
       public void recycle() {
           super.recycle();
  @@ -239,9 +235,8 @@
           this.ourPrefix = null;
       }
   
  -    /**
  -     * Avalon Serviceable Interface
  -     * @param manager The Avalon Service Manager
  +    /* (non-Javadoc)
  +     * @see 
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
        */
       public void service(ServiceManager manager) throws ServiceException {
           this.manager = manager;
  @@ -250,7 +245,7 @@
       /**
        *  Process the SAX event. A new document is processed. The hook (method)
        *  <code>setupTransforming()</code> is invoked.
  -     *  @see org.xml.sax.ContentHandler#startDocument
  +     *  @see org.xml.sax.ContentHandler#startDocument()
        */
       public void startDocument()
       throws SAXException {
  @@ -269,14 +264,13 @@
   
       /**
        *  Process the SAX event. The processing of the document is finished.
  -     *  @see org.xml.sax.ContentHandler#endDocument
  +     *  @see org.xml.sax.ContentHandler#endDocument()
        */
       public void endDocument()
       throws SAXException {
           if (this.ignoreEventsCount == 0) super.endDocument();
       }
   
  -
       /**
        * Process the SAX event.
        * The namespace of the event is checked. If it is the defined namespace
  @@ -400,73 +394,25 @@
       }
   
       /**
  -     * Start DocumentFragment recording.
  -     * All invoking events are recorded and not forwarded. The resulting
  -     * DocumentFragment can be obtained by the matching endRecording() call.
  +     * Start recording of SAX events
  +     * All incomming events are recorded and not forwarded. The result
  +     * can be obtained by the matching endSAXRecording() call.
  +     * @since 2.1.5
        */
  -    public void startRecording()
  +    public void startSAXRecording()
       throws SAXException {
  -        if (this.getLogger().isDebugEnabled()) {
  -            this.getLogger().debug("BEGIN startRecording");
  -        }
  -        DOMBuilder builder = new DOMBuilder();
  -        this.addRecorder(builder);
  -        builder.startDocument();
  -        builder.startElement("", "cocoon", "cocoon", new AttributesImpl());
  -
  -        this.sendStartPrefixMapping();
  -
  -        if (this.getLogger().isDebugEnabled()) {
  -            this.getLogger().debug("END startRecording");
  -        }
  +        this.addRecorder(new SaxBuffer());
       }
   
       /**
        * Stop DocumentFragment recording.
  -     * All invoking events are recorded and not forwarded. This method 
returns
  +     * All incomming events are recorded and not forwarded. This method 
returns
        * the resulting DocumentFragment.
  +     * @since 2.1.5
        */
  -    public DocumentFragment endRecording()
  +    public XMLizable endSAXRecording()
       throws SAXException {
  -        if (this.getLogger().isDebugEnabled()) {
  -            this.getLogger().debug("BEGIN endRecording");
  -        }
  -
  -        this.sendEndPrefixMapping();
  -
  -        DOMBuilder builder = (DOMBuilder)this.removeRecorder();
  -        builder.endElement("", "cocoon", "cocoon");
  -        builder.endDocument();
  -
  -        // Create Document Fragment
  -        final Document doc = builder.getDocument();
  -        final DocumentFragment recordedDocFrag = 
doc.createDocumentFragment();
  -        final Node root = doc.getDocumentElement();
  -        root.normalize();
  -        Node child;
  -        boolean appendedNode = false;
  -        while (root.hasChildNodes() == true) {
  -            child = root.getFirstChild();
  -            root.removeChild(child);
  -            // Leave out empty text nodes before any other node
  -            if (appendedNode == true
  -                || child.getNodeType() != Node.TEXT_NODE
  -                || child.getNodeValue().trim().length() > 0) {
  -                recordedDocFrag.appendChild(child);
  -                appendedNode = true;
  -            }
  -        }
  -
  -        if (this.getLogger().isDebugEnabled()) {
  -            Object serializedXML = null;
  -            try {
  -                serializedXML = (recordedDocFrag == null ? "null" : 
XMLUtils.serializeNodeToXML(recordedDocFrag));
  -            } catch (ProcessingException ignore) {
  -                serializedXML = recordedDocFrag;
  -            }
  -            this.getLogger().debug("END endRecording fragment=" + 
serializedXML);
  -        }
  -        return recordedDocFrag;
  +        return (XMLizable)this.removeRecorder();
       }
   
       /**
  @@ -522,7 +468,7 @@
           if (this.getLogger().isDebugEnabled()) {
               this.getLogger().debug("BEGIN startSerializedXMLRecording 
format="+format);
           }
  -        this.stack.push((format == null ? 
XMLUtils.defaultSerializeToXMLFormat() : format));
  +        this.stack.push((format == null ? 
XMLUtils.createPropertiesForXML(false) : format));
           this.startRecording();
           if (this.getLogger().isDebugEnabled()) {
               this.getLogger().debug("END startSerializedXMLRecording");
  @@ -613,6 +559,76 @@
           return pars;
       }
   
  +    /**
  +     * Start DocumentFragment recording.
  +     * All incomming events are recorded and not forwarded. The resulting
  +     * DocumentFragment can be obtained by the matching endRecording() call.
  +     */
  +    public void startRecording()
  +    throws SAXException {
  +        if (this.getLogger().isDebugEnabled()) {
  +            this.getLogger().debug("BEGIN startRecording");
  +        }
  +        DOMBuilder builder = new DOMBuilder();
  +        this.addRecorder(builder);
  +        builder.startDocument();
  +        builder.startElement("", "cocoon", "cocoon", new AttributesImpl());
  +
  +        this.sendStartPrefixMapping();
  +
  +        if (this.getLogger().isDebugEnabled()) {
  +            this.getLogger().debug("END startRecording");
  +        }
  +    }
  +
  +    /**
  +     * Stop DocumentFragment recording.
  +     * All incomming events are recorded and not forwarded. This method 
returns
  +     * the resulting DocumentFragment.
  +     */
  +    public DocumentFragment endRecording()
  +    throws SAXException {
  +        if (this.getLogger().isDebugEnabled()) {
  +            this.getLogger().debug("BEGIN endRecording");
  +        }
  +
  +        this.sendEndPrefixMapping();
  +
  +        DOMBuilder builder = (DOMBuilder)this.removeRecorder();
  +        builder.endElement("", "cocoon", "cocoon");
  +        builder.endDocument();
  +
  +        // Create Document Fragment
  +        final Document doc = builder.getDocument();
  +        final DocumentFragment recordedDocFrag = 
doc.createDocumentFragment();
  +        final Node root = doc.getDocumentElement();
  +        root.normalize();
  +        Node child;
  +        boolean appendedNode = false;
  +        while (root.hasChildNodes() == true) {
  +            child = root.getFirstChild();
  +            root.removeChild(child);
  +            // Leave out empty text nodes before any other node
  +            if (appendedNode == true
  +                || child.getNodeType() != Node.TEXT_NODE
  +                || child.getNodeValue().trim().length() > 0) {
  +                recordedDocFrag.appendChild(child);
  +                appendedNode = true;
  +            }
  +        }
  +
  +        if (this.getLogger().isDebugEnabled()) {
  +            Object serializedXML = null;
  +            try {
  +                serializedXML = (recordedDocFrag == null ? "null" : 
XMLUtils.serializeNode(recordedDocFrag, 
XMLUtils.createPropertiesForXML(false)));
  +            } catch (ProcessingException ignore) {
  +                serializedXML = recordedDocFrag;
  +            }
  +            this.getLogger().debug("END endRecording fragment=" + 
serializedXML);
  +        }
  +        return recordedDocFrag;
  +    }
  +
       // ************
       // Hooks
       // ************
  @@ -914,54 +930,53 @@
           if (this.ignoreEventsCount == 0) super.endPrefixMapping(prefix);
       }
   
  -    /**
  -     * SAX Event handling
  +    /* (non-Javadoc)
  +     * @see 
org.xml.sax.ContentHandler#processingInstruction(java.lang.String, 
java.lang.String)
        */
       public void processingInstruction(String target, String data)
  -            throws SAXException {
  +    throws SAXException {
           if (this.ignoreEventsCount == 0) super.processingInstruction(target, 
data);
       }
   
  -    /**
  -     * SAX Event handling
  +    /* (non-Javadoc)
  +     * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
        */
       public void skippedEntity(String name)
  -            throws SAXException {
  +    throws SAXException {
           if (this.ignoreEventsCount == 0) super.skippedEntity(name);
       }
   
  -    /**
  -     * SAX Event handling
  +    /* (non-Javadoc)
  +     * @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, 
java.lang.String, java.lang.String)
        */
       public void startDTD(String name, String public_id, String system_id)
  -            throws SAXException {
  +    throws SAXException {
           if (this.ignoreEventsCount == 0) super.startDTD(name, public_id, 
system_id);
       }
   
  -    /**
  -     * SAX Event handling
  +    /* (non-Javadoc)
  +     * @see org.xml.sax.ext.LexicalHandler#endDTD()
        */
       public void endDTD() throws SAXException {
           if (this.ignoreEventsCount == 0) super.endDTD();
       }
   
  -    /**
  -     * SAX Event handling
  +    /* (non-Javadoc)
  +     * @see org.xml.sax.ext.LexicalHandler#startCDATA()
        */
       public void startCDATA() throws SAXException {
           if (this.ignoreEventsCount == 0) super.startCDATA();
       }
   
  -    /**
  -     * SAX Event handling
  +    /* (non-Javadoc)
  +     * @see org.xml.sax.ext.LexicalHandler#endCDATA()
        */
       public void endCDATA() throws SAXException {
           if (this.ignoreEventsCount == 0) super.endCDATA();
       }
   
  -
  -    /**
  -     * SAX Event handling
  +    /* (non-Javadoc)
  +     * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
        */
       public void comment(char ary[], int start, int length)
       throws SAXException {
  
  
  
  1.14      +7 -5      
cocoon-2.2/src/java/org/apache/cocoon/components/source/SourceUtil.java
  
  Index: SourceUtil.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/source/SourceUtil.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SourceUtil.java   8 Mar 2004 14:01:57 -0000       1.13
  +++ SourceUtil.java   17 Mar 2004 12:26:59 -0000      1.14
  @@ -452,8 +452,9 @@
                                                }
                        }
                   } else {
  -                     final String content = XMLUtils.serializeNode(frag,
  -                                                
XMLUtils.defaultSerializeToXMLFormat(false));
  +                    Properties props = 
XMLUtils.createPropertiesForXML(false);
  +                    props.put(OutputKeys.ENCODING, "ISO-8859-1");
  +                     final String content = XMLUtils.serializeNode(frag, 
props);
                        OutputStream oStream = ws.getOutputStream();
        
                        oStream.write(content.getBytes());
  @@ -493,8 +494,9 @@
                       }
                                        content = oStream.toString();
                                } else {
  -                    content = XMLUtils.serializeNode(frag,
  -                                           
XMLUtils.defaultSerializeToXMLFormat(false));
  +                    Properties props = 
XMLUtils.createPropertiesForXML(false);
  +                    props.put(OutputKeys.ENCODING, "ISO-8859-1");
  +                    content = XMLUtils.serializeNode(frag, props);
                                }
                                
                   if (parameters==null) {
  
  
  

Reply via email to