ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/util DOMElementWriter.java
Date Fri, 27 Apr 2001 12:48:22 GMT
bodewig     01/04/27 05:48:22

  Modified:    src/main/org/apache/tools/ant XmlLogger.java
               src/main/org/apache/tools/ant/util DOMElementWriter.java
  Log:
  specify encoding for XmlLogger, handle TEXT Elements properly in
  DOMElementWriter.
  
  Submitted by:	Stephane Bailliez <sbailliez@imediation.com>
  
  Revision  Changes    Path
  1.7       +6 -2      jakarta-ant/src/main/org/apache/tools/ant/XmlLogger.java
  
  Index: XmlLogger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/XmlLogger.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XmlLogger.java	2001/01/03 14:18:27	1.6
  +++ XmlLogger.java	2001/04/27 12:48:18	1.7
  @@ -132,8 +132,12 @@
               if (outFilename == null) {
                   outFilename = "log.xml";
               }
  -
  -            Writer out = new FileWriter(outFilename);
  +            
  +            // specify output in UTF8 otherwise accented characters will blow
  +            // up everything
  +            Writer out =
  +                new OutputStreamWriter(new FileOutputStream(outFilename),
  +                                       "UTF8");
               out.write("<?xml:stylesheet type=\"text/xsl\" href=\"log.xsl\"?>\n\n");
               (new DOMElementWriter()).write(buildElement, out, 0, "\t");
               out.flush();
  
  
  
  1.4       +12 -2     jakarta-ant/src/main/org/apache/tools/ant/util/DOMElementWriter.java
  
  Index: DOMElementWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/DOMElementWriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DOMElementWriter.java	2001/02/02 17:04:01	1.3
  +++ DOMElementWriter.java	2001/04/27 12:48:20	1.4
  @@ -67,7 +67,7 @@
    *
    * @author The original author of XmlLogger
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
  - * @author <a href="mailto:bailliez@noos.fr">Stephane Bailliez</tt>
  + * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</tt>
    */
   public class DOMElementWriter {
   
  @@ -131,6 +131,9 @@
                   break;
                   
               case Node.TEXT_NODE:
  +                out.write(encode(child.getNodeValue()));
  +                break;
  +                
               case Node.CDATA_SECTION_NODE:
                   out.write("<![CDATA[");
                   out.write(((Text)child).getData());
  @@ -170,10 +173,11 @@
           out.write(element.getTagName());
           out.write(">");
           out.write(lSep);
  +        out.flush();
       }
   
       /**
  -     * Escape &lt;, &amp; and &quot; as their entities.
  +     * Escape &lt;, &gt; &amp; &apos; and &quot; as their entities.
        */
       public String encode(String value) {
           sb.setLength(0);
  @@ -182,6 +186,12 @@
               switch (c) {
               case '<':
                   sb.append("&lt;");
  +                break;
  +            case '>':
  +                sb.append("&gt;");
  +                break;
  +            case '\'':
  +                sb.append("&apos;");
                   break;
               case '\"':
                   sb.append("&quot;");
  
  
  

Mime
View raw message