You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by st...@apache.org on 2002/09/09 04:50:17 UTC

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

stevel      2002/09/08 19:50:17

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional
                        XMLValidateTask.java
  Log:
  Feature support from Nick Pellow, nick.pellow@mindmatics.de.
  
  Revision  Changes    Path
  1.24      +75 -12    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  
  Index: XMLValidateTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- XMLValidateTask.java	25 Jul 2002 15:21:11 -0000	1.23
  +++ XMLValidateTask.java	9 Sep 2002 02:50:17 -0000	1.24
  @@ -58,9 +58,10 @@
   import java.io.IOException;
   import java.net.MalformedURLException;
   import java.net.URL;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
   import java.util.Vector;
  +import java.util.List;
  +import java.util.LinkedList;
  +
   import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
  @@ -89,6 +90,8 @@
    * (probably the one that is used by Ant itself), but one can specify any
    * SAX1/2 parser if needed
    * @author Raphael Pierquin <a href="mailto:raphael.pierquin@agisphere.com">raphael.pierquin@agisphere.com</a>
  + * @author <a href="mailto:nick.pellow@mindmatics.de">Nick Pellow</a>
  + * Added support for setting features.
    */
   public class XMLValidateTask extends Task {
   
  @@ -106,8 +109,7 @@
       protected Vector filesets = new Vector(); // sets of file to be validated
       protected Path classpath;
   
  -
  -    /**
  +   /**
        * the parser is viewed as a SAX2 XMLReader. If a SAX1 parser is specified,
        * it's wrapped in an adapter that make it behave as a XMLReader.
        * a more 'standard' way of doing this would be to use the JAXP1.1 SAXParser
  @@ -116,7 +118,8 @@
       protected XMLReader xmlReader = null; // XMLReader used to validation process
       protected ValidatorErrorHandler errorHandler
           = new ValidatorErrorHandler(); // to report sax parsing errors
  -    protected Hashtable features = new Hashtable();
  +
  +    private List featureList = new LinkedList();
   
       private XMLCatalog xmlCatalog = new XMLCatalog();
   
  @@ -222,6 +225,17 @@
           filesets.addElement(set);
       }
   
  +
  +    /**
  +     * add a feature nested element
  +     * @since ant1.6
  +     */
  +    public Feature createFeature() {
  +        final Feature feature = new Feature();
  +        featureList.add(feature);
  +        return feature;
  +    }
  +
       public void init() throws BuildException {
           super.init();
           xmlCatalog.setProject(getProject());
  @@ -347,18 +361,18 @@
                                                + " doesn't provide validation");
                   }
               }
  -            // set other features
  -            Enumeration enum = features.keys();
  -            while (enum.hasMoreElements()) {
  -                String featureId = (String) enum.nextElement();
  -                setFeature(featureId, ((Boolean) features.get(featureId)).booleanValue(), true);
  +            // set the feature from the feature list
  +            for (int i = 0; i < featureList.size(); i++) {
  +                Feature feature = (Feature) featureList.get(i);
  +                setFeature(feature.getFeatureName(),
  +                        feature.getFeatureValue(),
  +                        true);
               }
           }
       }
   
       /**
  -     * set a feature on the parser.
  -     * @todo find a way to set any feature from build.xml
  +     * Set a feature on the parser.
        */
       private boolean setFeature(String feature, boolean value, boolean warn) {
   
  @@ -480,6 +494,55 @@
                   }
               }
               return e.getMessage();
  +        }
  +    }
  +
  +    /**
  +     * The class to create to set a feature of the parser.
  +     * @since ant1.6
  +     * @author <a href="mailto:nick.pellow@mindmatics.de">Nick Pellow</a>
  +     */
  +    public class Feature {
  +        /** The name of the feature to set.
  +         *
  +         * Valid features <a href=http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description">include.</a>
  +         */
  +        private String featureName = null;
  +        
  +        /** 
  +         * The value of the feature. 
  +         **/
  +        private boolean featureValue;
  +        
  +        /**
  +         * Set the feature name.
  +         * @param name the name to set
  +         */
  +        public void setName(String name) {
  +            featureName = name;
  +        }
  +        /**
  +         * Set the feature value to true or false. 
  +         * @param value
  +         */
  +        public void setValue(boolean value) {
  +            featureValue = value;
  +        }
  +
  +        /**
  +         * Gets the feature name.
  +         * @return the feature name
  +         */
  +        public String getFeatureName() {
  +            return featureName;
  +        }
  +
  +        /**
  +         * Gets the feature value.
  +         * @return the featuree value
  +         */
  +        public boolean getFeatureValue() {
  +            return featureValue;
           }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


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

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Stefan Bodewig" <bo...@apache.org>
To: <an...@jakarta.apache.org>
Sent: Monday, September 09, 2002 22:57
Subject: Re: cvs commit:
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional
XMLValidateTask.java


> On Mon, 9 Sep 2002, Steve Loughran <st...@iseran.com> wrote:
>
> > I thought It was 1.1 compliant when I replaced ArrayList with
> > List.
>
> There has been ArrayList in the source?

was in the patch; I downgraded it to LinkedList.

>
> > Will back out.
>
> Thanks
>
>         Stefan
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


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

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 10 Sep 2002, Nick Pellow <ni...@mindmatics.de> wrote:

> I will rework it to compile under 1.1 and also bring it into
> line with xstyle task.

Great!

Thanks

        Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


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

Posted by Nick Pellow <ni...@mindmatics.de>.
Okay, 
sorry about that, I was not aware it had to be 1.1 compliant.
I will rework it to compile under 1.1 and also bring it into
line with xstyle task.

Coming late next week,

Cheers, 
nick 

> -----Ursprungliche Nachricht-----
> Von: Stefan Bodewig [mailto:bodewig@apache.org]
> Gesendet: Dienstag, 10. September 2002 07:57
> An: ant-dev@jakarta.apache.org
> Betreff: Re: cvs commit:
> jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional
> XMLValidateTask.java
> 
> 
> On Mon, 9 Sep 2002, Steve Loughran <st...@iseran.com> wrote:
> 
> > I thought It was 1.1 compliant when I replaced ArrayList with
> > List.
> 
> There has been ArrayList in the source?
> 
> > Will back out.
> 
> Thanks
> 
>         Stefan
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


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

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 9 Sep 2002, Steve Loughran <st...@iseran.com> wrote:

> I thought It was 1.1 compliant when I replaced ArrayList with
> List.

There has been ArrayList in the source?

> Will back out.

Thanks

        Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


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

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Stefan Bodewig" <bo...@apache.org>
To: <an...@jakarta.apache.org>
Sent: Monday, September 09, 2002 12:25 AM
Subject: Re: cvs commit:
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional
XMLValidateTask.java


> I don't like this patch, sorry.
>
> (1) XMLValidate used to compile fine with JDK 1.1, now all the 1.1
> collection classes have been replaced with 1.2 classes for no gain.

ok. I thought It was 1.1 compliant when I replaced ArrayList with List. Will
back out.




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: XMLValidateTask and Factory nested element?

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 18 Sep 2002, Nick Pellow <ni...@mindmatics.de> wrote:

> Well, the XSLTProcess uses a nested factory to configure the
> parser. I do not see this nescessary for the validate task just now.

Because we have the classname attribute?

> Does the XMLValidateTask need to support the nested factory element
> at all?

I don't care too much whether we have that factory element at all, but
I'd like to see the parser configuration done via nested <attribute>
elements to make those similar things more consistent for the users.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


AW: XMLValidateTask and Factory nested element?

Posted by Nick Pellow <ni...@mindmatics.de>.

> -----Ursprungliche Nachricht-----
> Von: Stefan Bodewig [mailto:bodewig@apache.org]
> Gesendet: Mittwoch, 11. September 2002 10:37
> An: ant-dev@jakarta.apache.org
> Betreff: Re: XMLValidateTask and Factory nested element?
>
>
> On Tue, 10 Sep 2002, Nick Pellow <ni...@mindmatics.de> wrote:
>
> > I have been looking at XSLTProcess and have started bringing
> > XMLValidate up to paar. Should XMLValidate handle the factory
> > configuration exactly the same way as the XSLT task?
>
> In a similar way would be prefered, what would need to be different in
> your opinion?

Well, the XSLTProcess uses a nested factory to configure the parser. I do
not see this nescessary for the validate task just now.

>
> > I am using an XSLTProcess.Factory, however, should I rework
> > XMLValidate so that it configures the Liason in the same as
> > XSLTProcessor ?
>
> Is that necessary IYO?

No. Does the XMLValidateTask need to support the nested factory element at
all?



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: XMLValidateTask and Factory nested element?

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 10 Sep 2002, Nick Pellow <ni...@mindmatics.de> wrote:

> I have been looking at XSLTProcess and have started bringing
> XMLValidate up to paar. Should XMLValidate handle the factory
> configuration exactly the same way as the XSLT task?

In a similar way would be prefered, what would need to be different in
your opinion?

> I am using an XSLTProcess.Factory, however, should I rework
> XMLValidate so that it configures the Liason in the same as
> XSLTProcessor ?

Is that necessary IYO?

> viz, XSLT uses a "processor" attribute and XMLValidate uses just a
> "className", where "processor" can be "trax" etc.

They serve a bit different purposes.  The processor attribute - if
XMLValidate had one - could hold some shortcuts for well known parsers
(i.e. crimson, xerces, aelfred, xerces1?), but that would only be
sugar IMHO.

> Or should XMLValidate provide both mechanisms for setting the
> processor in the future?

We need to keep the old one for backwards compatibility.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


XMLValidateTask and Factory nested element?

Posted by Nick Pellow <ni...@mindmatics.de>.
Hi Stefan, Steve,

I have been looking at XSLTProcess and have started bringing XMLValidate
up to paar. Should XMLValidate handle the factory configuration exactly the
same way
as the XSLT task?

I am using an XSLTProcess.Factory, however, should I rework XMLValidate so
that
it configures the Liason in the same as XSLTProcessor ?
viz, XSLT uses a "processor" attribute and XMLValidate uses just a
"className",
where "processor" can be "trax" etc.

Or should XMLValidate provide both mechanisms for setting the processor in
the future?

Hope I am not too far off the track.

Cheers,
Nick





> -----Ursprungliche Nachricht-----
> Von: Stefan Bodewig [mailto:bodewig@apache.org]
> Gesendet: Montag, 9. September 2002 09:25
> An: ant-dev@jakarta.apache.org
> Betreff: Re: cvs commit:
> jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional
> XMLValidateTask.java
>
>
> I don't like this patch, sorry.
>
> (1) XMLValidate used to compile fine with JDK 1.1, now all the 1.1
> collection classes have been replaced with 1.2 classes for no gain.
>
> (2) I've twiced asked (Nick on this list) to rework this patch to
> allow configuring the factory in the same way Stephane has modified
> <xslt> so that we have a single consistent way to do so (and I think
> <xslt>'s way is superior).
>
> Stefan
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


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

Posted by Stefan Bodewig <bo...@apache.org>.
I don't like this patch, sorry.

(1) XMLValidate used to compile fine with JDK 1.1, now all the 1.1
collection classes have been replaced with 1.2 classes for no gain.

(2) I've twiced asked (Nick on this list) to rework this patch to
allow configuring the factory in the same way Stephane has modified
<xslt> so that we have a single consistent way to do so (and I think
<xslt>'s way is superior).

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>