Home → DobuDish → Validate as dependency
|
Hello everyone We try to use dopus as our docbook distribution. Last step in configuration was to strip down docbooks allowed tags. We used a own tailored dbtiny.rng that is including docbook.rng and switching off all not allowed tags. The ANT task "validate" now uses dbtiny.rng. So far so good. That works, "generator.bat test validate" gives us correct messages. Next step is to include validate as dependencing task when doing document creation(pdf, html, ...), cause we want to be sure validation is done everytime a document output is generated. Unfortunately it seems as valdiate doesn't stops ANT from further processing if the doc is not valid. failonerror should stop ANT so we think com.sun.msv.schematron.Driver doesn't give a proper returncode. We coudn't find any documentation about com.sun.msv.schematron.Driver. And also we were not able to fix this problem yet... Any help? |
|
Michael Beumers
| email
August 25 2009, 04:47 PM |
|
Hi Michael, I have used Suns MSV once in a project. Here's the code we used to validate a document- I hope this is of help to you: public boolean validate(String documentPath, String schemaPath) throws Exception { // (1) use autodetection of schemas VerifierFactory factory = new com.sun.msv.verifier.jarv.TheFactoryImpl(); Schema schema = null; schema = factory.compileSchema( schemaPath ); // (2) configure a Vertifier Verifier verifier = schema.newVerifier(); verifier.setErrorHandler( new ErrorHandler() { //todo: we might want to throw exceptions here? public void error(SAXParseException saxParseEx) { System.out.println( "Error during validation."+ saxParseEx.getMessage()); } public void fatalError(SAXParseException saxParseEx) { System.out.println( "Fatal error during validation. "+ saxParseEx.getMessage()); } public void warning(SAXParseException saxParseEx) { System.out.println( "Warning during validation."+ saxParseEx.getMessage()); } } ); boolean isValid = false; if(verifier.verify(new File(documentPath))) { isValid = true; } return isValid; } Kind Regards, Torsten. |
|
Torsten Uhlmann
| email
22 hours, 22 mins since original post |