Hi, Attached is the diff and java files for a patch to the XMLValidateTask and doco. I implemented the todo: * @todo find a way to set any feature from build.xml
We are using this currently to validate XML documents against an XSD schema. You can set arbitrary parameters of the SAX parsers. I submitted this to the dev list a while ago. However it is not yet comitted to cvs. Cheers, Nick Pellow > -----Urspr�ngliche Nachricht----- > Von: Steve Loughran [mailto:[EMAIL PROTECTED]] > Gesendet: Dienstag, 27. August 2002 19:21 > An: Ant Users List > Betreff: Re: XML Schema validation with Ant style task > > > > ----- Original Message ----- > From: "Frank E. Weiss" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Sunday, August 25, 2002 7:53 AM > Subject: XML Schema validation with Ant style task > > > > I know that for some time Xalan hasn't come out of the box with > validation > turned on in the XML parser, namely Xerces. > > We've had to write a little wrapper to do that. I was wondering > if this is > still the case? Would you advise me to just > > write my own Ant task to get this functionality? > > > > -- Frank Weiss > > castrosf.org > > > > 1. do you mean 'XML Schema' or just plain DTDs? > 2. <xmlvalidate> does dtds > 3. I thought <style> did too > 4. I've not looked at .xsd based validation yet. It'd be nice to have this > working in <xmlvalidate> > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > >
XMLValidateTask.java
Description: Binary data
Index: src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java,v retrieving revision 1.23 diff -r1.23 XMLValidateTask.java 63a64,65 > import java.util.List; > import java.util.ArrayList; 91a94,95 > * @author <a href="mailto:[EMAIL PROTECTED]">Nick Pellow</a> > * Added support for setting features. 109,110c113 < < /** --- > /** 119c122,123 < protected Hashtable features = new Hashtable(); --- > > private List featureList = new ArrayList(); 224a229,235 > > public Feature createFeature() { > final Feature feature = new Feature(); > featureList.add(feature); > return feature; > } > 350,354c361,366 < // 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); 360,361c372 < * set a feature on the parser. < * @todo find a way to set any feature from build.xml --- > * Set a feature on the parser. 482a494,538 > } > } > > /** > * The class to create to set a feature of the parser. > * > * @author <a href="mailto:[EMAIL PROTECTED]">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 mFeatureName = null; > /** The value of the feature. **/ > private boolean mFeatureValue; > /** > * Set the feature name. > * @param aName the name to set > */ > public void setName(String aName) { > mFeatureName = aName; > } > /** > * Set the feature value. > * @param aValue > */ > public void setValue(boolean aValue) { > mFeatureValue = aValue; > } > > /** > * Gets the feature name. > * @return the feature name > */ > public String getFeatureName() { > return mFeatureName; > } > > /** > * Gets the feature value. > * @return the featuree value > */ > public boolean getFeatureValue() { > return mFeatureValue;
Index: docs/manual/OptionalTasks/xmlvalidate.html =================================================================== RCS file: /home/cvspublic/jakarta-ant/docs/manual/OptionalTasks/xmlvalidate.html,v retrieving revision 1.6 diff -r1.6 xmlvalidate.html 17,19c17,21 < <p>This task supports the use of nested <a < href="../CoreTypes/xmlcatalog.html">xmlcatalog</a> elements and/or nested < <tt><dtd></tt> elements which are used to resolve DTDs and entities.</p> --- > <p>This task supports the use of nested > <li/><a href="../CoreTypes/xmlcatalog.html"><tt><xmlcatalog></tt></a> >elements > <li/><tt><dtd></tt> elements which are used to resolve DTDs and entities. > <li/><tt><feature></tt> elements which are used to set features. These can >be any number of <a >href="http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description">http://xml.org/sax/features/</a> > </p> 86a89,94 > <h4>feature</h4> > <p>The feature element is used to set SAX Parser features. > There can an arbitrary amount of features set as defined here: > <a >href="http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description">http://xml.org/sax/features/</a> > A feature essentialy changes the mode of the parser. > </p> 116a125,134 > <br/> > <xmlvalidate failonerror="yes" lenient="no" warn="yes"> > > <fileset dir="xml" includes="**/*.xml"/> > <feature name="http://xml.org/sax/features/validation" value="true"/> > <feature name="http://apache.org/xml/features/validation/schema" >value="true"/> > > </xmlvalidate> > >
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
