alexbrn / probatron4j

Automatically exported from code.google.com/p/probatron4j
0 stars 0 forks source link

Sample schematron validation code #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I need to validate an xml file using a xslt transformer and of course a 
schematron schema. When I try to run probatron.jar without my custom xslt file, 
it gives me that error :

Error at xsl:stylesheet on line 297 column 31
  XTSE0010: Element xsl:stylesheet must not appear directly within xsl:stylesheet
FATAL Failed to compile stylesheet. 27 errors detected.
Exception in thread "main" java.lang.RuntimeException: Cannot instantiate XSLT 
transformer, or trans
formation failure: Failed to compile stylesheet. 27 errors detected.
        at org.probatron.SchematronSchema.validateCandidate(Unknown Source)
        at org.probatron.SchematronSchema.validateCandidate(Unknown Source)
        at org.probatron.Session.doValidation(Unknown Source)
        at org.probatron.Driver.main(Unknown Source)
Caused by: javax.xml.transform.TransformerConfigurationException: Failed to 
compile stylesheet. 27 e
rrors detected.
        at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:176)
        at net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:139)
        at net.sf.saxon.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:91)
        ... 4 more

I also need to run validation through java code, I have tried some samples but 
I couldn't manage to run validation for my local xml and schema from code. Can 
you please show me a snippet to run validation. Thanks in advance.

Original issue reported on code.google.com by msute...@gmail.com on 14 Aug 2013 at 7:04

GoogleCodeExporter commented 9 years ago
I have solved the problem as I changed my schematron schema and the exception 
has been solved. I have tried to inspect validationReport which is the output 
of my validation, validationReport.streamOut( System.out ); function outputs 
the first few lines of my schematron schema. Even If I add errors into the xml 
that I try to validate, validationReport output is always the same and it does 
not print any errors. 

I couldn't find a forum or a place to ask my questions, so I apologise for 
writing to issues page. 

Original comment by msute...@gmail.com on 14 Aug 2013 at 8:37