peterreilly    2004/12/13 10:52:17

  Modified:    .        Tag: ANT_16_BRANCH WHATSNEW
               src/main/org/apache/tools/ant/taskdefs/optional Tag:
                        ANT_16_BRANCH XMLValidateTask.java
  Log:
  sync
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.503.2.148 +3 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.503.2.147
  retrieving revision 1.503.2.148
  diff -u -r1.503.2.147 -r1.503.2.148
  --- WHATSNEW  10 Dec 2004 15:20:10 -0000      1.503.2.147
  +++ WHATSNEW  13 Dec 2004 18:52:17 -0000      1.503.2.148
  @@ -79,6 +79,9 @@
     twice - if the resource is in the project classpath and if the classloader 
is requested
     with a null path.
   
  +* XMLValidate used URL#getFile rather than the ant method FileUtils#fromURI
  +  Bugzilla report 32508
  +
   Changes from Ant 1.6.1 to Ant 1.6.2
   ===================================
   
  
  
  
  No                   revision
  No                   revision
  1.36.2.6  +17 -15    
ant/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  
  Index: XMLValidateTask.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java,v
  retrieving revision 1.36.2.5
  retrieving revision 1.36.2.6
  diff -u -r1.36.2.5 -r1.36.2.6
  --- XMLValidateTask.java      2 Jun 2004 21:13:18 -0000       1.36.2.5
  +++ XMLValidateTask.java      13 Dec 2004 18:52:17 -0000      1.36.2.6
  @@ -19,8 +19,6 @@
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.IOException;
  -import java.net.MalformedURLException;
  -import java.net.URL;
   import java.util.Vector;
   
   import org.apache.tools.ant.AntClassLoader;
  @@ -59,7 +57,7 @@
       /**
        * helper for path -> URI and URI -> path conversions.
        */
  -    private static FileUtils fu = FileUtils.newFileUtils();
  +    private static final FileUtils FILE_UTILS = FileUtils.newFileUtils();
   
       protected static final String INIT_FAILED_MSG =
           "Could not start xml validation: ";
  @@ -455,7 +453,7 @@
               log("Validating " + afile.getName() + "... ", 
Project.MSG_VERBOSE);
               errorHandler.init(afile);
               InputSource is = new InputSource(new FileInputStream(afile));
  -            String uri = fu.toURI(afile.getAbsolutePath());
  +            String uri = FILE_UTILS.toURI(afile.getAbsolutePath());
               is.setSystemId(uri);
               xmlReader.parse(is);
           } catch (SAXException ex) {
  @@ -545,18 +543,22 @@
           private String getMessage(SAXParseException e) {
               String sysID = e.getSystemId();
               if (sysID != null) {
  -                try {
  -                    int line = e.getLineNumber();
  -                    int col = e.getColumnNumber();
  -                    return new URL(sysID).getFile()
  -                        + (line == -1
  -                            ? ""
  -                            : (":" + line + (col == -1 ? "" : (":" + col))))
  -                        + ": "
  -                        + e.getMessage();
  -                } catch (MalformedURLException mfue) {
  -                    // ignore and just return exception message
  +                String name = sysID;
  +                if (sysID.startsWith("file:")) {
  +                    try {
  +                        name = FILE_UTILS.fromURI(sysID);
  +                    } catch (Exception ex) {
  +                        // if this is not a valid file: just use the uri
  +                    }
                   }
  +                int line = e.getLineNumber();
  +                int col = e.getColumnNumber();
  +                return  name
  +                    + (line == -1
  +                       ? ""
  +                       : (":" + line + (col == -1 ? "" : (":" + col))))
  +                    + ": "
  +                    + e.getMessage();
               }
               return e.getMessage();
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to