cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/xml XMLUtils.java
Date Wed, 17 Mar 2004 11:50:21 GMT
cziegeler    2004/03/17 03:50:21

  Modified:    src/java/org/apache/cocoon/transformation
                        CIncludeTransformer.java
                        AbstractSAXTransformer.java
               src/java/org/apache/cocoon/xml XMLUtils.java
  Log:
  Don't use hard-coded encoding for serializing dom to string (addresses bug 26924)
  
  Revision  Changes    Path
  1.10      +2 -2      cocoon-2.1/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java
  
  Index: CIncludeTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CIncludeTransformer.java	5 Mar 2004 13:02:59 -0000	1.9
  +++ CIncludeTransformer.java	17 Mar 2004 11:50:21 -0000	1.10
  @@ -290,7 +290,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      +3 -3      cocoon-2.1/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java
  
  Index: AbstractSAXTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/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	5 Mar 2004 13:02:59 -0000	1.10
  +++ AbstractSAXTransformer.java	17 Mar 2004 11:50:21 -0000	1.11
  @@ -476,7 +476,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");
  @@ -628,7 +628,7 @@
           if (this.getLogger().isDebugEnabled()) {
               Object serializedXML = null;
               try {
  -                serializedXML = (recordedDocFrag == null ? "null" : XMLUtils.serializeNodeToXML(recordedDocFrag));
  +                serializedXML = (recordedDocFrag == null ? "null" : XMLUtils.serializeNode(recordedDocFrag,
XMLUtils.createPropertiesForXML(false)));
               } catch (ProcessingException ignore) {
                   serializedXML = recordedDocFrag;
               }
  
  
  
  1.7       +27 -8     cocoon-2.1/src/java/org/apache/cocoon/xml/XMLUtils.java
  
  Index: XMLUtils.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/xml/XMLUtils.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLUtils.java	5 Mar 2004 13:03:01 -0000	1.6
  +++ XMLUtils.java	17 Mar 2004 11:50:21 -0000	1.7
  @@ -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);
  +        }
       }
   
       /**
  @@ -143,6 +147,7 @@
       /**
        * Serialize a DOM node to a String.
        * The defaultSerializeToXMLFormat() is used to format the serialized xml.
  +     * @deprecated use serializeNode(Node, Properties) instead
        */
       public static String serializeNodeToXML(Node node)
       throws ProcessingException {
  @@ -157,6 +162,7 @@
        * Encoding: ISO-8859-1
        * Omit xml declaration: no
        * Indent: yes
  +     * @deprecated Use createPropertiesForXML(false) instead and add the encoding
        */
       public static Properties defaultSerializeToXMLFormat() {
           return defaultSerializeToXMLFormat(false);
  @@ -170,17 +176,30 @@
        * Encoding: ISO-8859-1
        * Omit xml declaration: according to the flag
        * Indent: yes
  +     * @deprecated Use createPropertiesForXML(boolean) instead and add the encoding
        */
       public static Properties defaultSerializeToXMLFormat(boolean omitXMLDeclaration) {
  -        Properties format = new Properties();
  -        format.put(OutputKeys.METHOD, "xml");
  +        final Properties format = createPropertiesForXML(omitXMLDeclaration);
           format.put(OutputKeys.ENCODING, "ISO-8859-1");
  -        format.put(OutputKeys.OMIT_XML_DECLARATION, (omitXMLDeclaration ? "yes" : "no"));
  -        format.put(OutputKeys.INDENT, "yes");
           return format;
       }
   
       /**
  +     * Create a new properties set for serializing xml
  +     * The omit xml declaration property can be controlled by the flag.
  +     * Method: xml
  +     * Omit xml declaration: according to the flag
  +     * Indent: yes
  +     */
  +    public static Properties createPropertiesForXML(boolean omitXMLDeclaration) {
  +        final Properties format = new Properties();
  +        format.put(OutputKeys.METHOD, "xml");
  +        format.put(OutputKeys.OMIT_XML_DECLARATION, (omitXMLDeclaration ? "yes" : "no"));
  +        format.put(OutputKeys.INDENT, "yes");
  +        return format;        
  +    }
  +    
  +    /**
        * Serialize a DOM node to a String.
        * The format of the output can be specified with the properties.
        * If the node is null the empty string is returned.
  @@ -209,7 +228,7 @@
               throw new ProcessingException("TransformerException: " + local, local);
           } catch (SAXException local) {
               throw new ProcessingException("SAXException while streaming DOM node to SAX:
" + local, local);
  -        }
  +        }        
       }
   
       /**
  
  
  

Mime
View raw message