Hi,

I find that the xml-maven-plugin beta-1 requires us to specify the
schema file at the <systemId> element, even if the schema location is
specified in the xml file.

I don't know if it is a designed behavior, but it is annoying to use
when there are a lot of different types of XML files to be validated.

In the source code of org/codehaus/mojo/xml/ValidateMojo.java, there
is a function "newSAXParserFactory" :

   private SAXParserFactory newSAXParserFactory( ValidationSet
pValidationSet )     {
       SAXParserFactory spf = SAXParserFactory.newInstance();
       spf.setValidating( pValidationSet.isValidating() );
       spf.setNamespaceAware( true );
       return spf;
   }

It does not turn on the schema validation of the SAX parser. I tried
to change the method :

   private SAXParserFactory newSAXParserFactory( ValidationSet
pValidationSet ) throws SAXException, ParserConfigurationException
   {
       SAXParserFactory spf = SAXParserFactory.newInstance();
       spf.setValidating( pValidationSet.isValidating() );
       if (pValidationSet.isValidating()) {

spf.setFeature("http://apache.org/xml/features/validation/schema";,
true);
               }
       spf.setNamespaceAware( true );
       return spf;
   }

Then the schema validation go well without specifying the schema file
at <systemId>.

It would become Xerces dependent, but the dependency is specified in
the POM anyway.

regards,

Herman.

---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to