You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2005/05/20 23:46:55 UTC

cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional XMLValidateTask.java

mbenson     2005/05/20 14:46:55

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional
                        XMLValidateTask.java
  Log:
  Make XmlValidateTest pass.
  
  Revision  Changes    Path
  1.50      +7 -11     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.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- XMLValidateTask.java	10 May 2005 16:26:34 -0000	1.49
  +++ XMLValidateTask.java	20 May 2005 21:46:55 -0000	1.50
  @@ -332,7 +332,7 @@
        */
       protected void initValidator() {
   
  -        xmlReader=createXmlReader();
  +        xmlReader = createXmlReader();
   
           xmlReader.setEntityResolver(getEntityResolver());
           xmlReader.setErrorHandler(errorHandler);
  @@ -348,7 +348,6 @@
                   setFeature(feature.getName(), feature.getValue());
   
               }
  -
               // Sets properties
               for (int i = 0; i < propertyList.size(); i++) {
                   final Property prop = (Property) propertyList.elementAt(i);
  @@ -521,7 +520,7 @@
       protected boolean doValidate(File afile) {
           //for every file, we have a new instance of the validator
           initValidator();
  -
  +        boolean result = true;
           try {
               log("Validating " + afile.getName() + "... ", Project.MSG_VERBOSE);
               errorHandler.init(afile);
  @@ -529,31 +528,28 @@
               String uri = FILE_UTILS.toURI(afile.getAbsolutePath());
               is.setSystemId(uri);
               xmlReader.parse(is);
  -            return true;
           } catch (SAXException ex) {
               log("Caught when validating: " + ex.toString(), Project.MSG_DEBUG);
               if (failOnError) {
                   throw new BuildException(
                       "Could not validate document " + afile);
  -            } else {
  -                log("Could not validate document " + afile + ": " + ex.toString());
               }
  +            log("Could not validate document " + afile + ": " + ex.toString());
  +            result = false;
           } catch (IOException ex) {
               throw new BuildException(
                   "Could not validate document " + afile,
                   ex);
           }
  -
           if (errorHandler.getFailure()) {
               if (failOnError) {
                   throw new BuildException(
                       afile + " is not a valid XML document.");
  -            } else {
  -                log(afile + " is not a valid XML document", Project.MSG_ERR);
               }
  +            result = false;
  +            log(afile + " is not a valid XML document", Project.MSG_ERR);
           }
  -        //if we got here. it was as a result of a caught and logged exception.
  -        return false;
  +        return result;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org