use of com.helger.schematron.svrl.SVRLMarshaller in project ph-schematron by phax.
the class Issue11Test method validateAndProduceSVRL.
public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
final SchematronResourcePure aSCH = SchematronResourcePure.fromFile(aSchematron);
aSCH.setErrorHandler(new LoggingPSErrorHandler());
assertTrue(aSCH.isValidSchematron());
// Perform validation
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
assertNotNull(aSVRL);
if (false)
System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
use of com.helger.schematron.svrl.SVRLMarshaller in project ph-schematron by phax.
the class PSXPathBoundSchemaTest method testSchematronValidation.
@Test
public void testSchematronValidation() throws SAXException, SchematronException {
for (int i = 0; i < SCH.length; ++i) {
final IReadableResource aSchRes = new ClassPathResource("test-sch/" + SCH[i]);
final IReadableResource aXmlRes = new ClassPathResource("test-xml/" + XML[i]);
// Resolve all includes
final IMicroDocument aDoc = SchematronHelper.getWithResolvedSchematronIncludes(aSchRes);
assertNotNull(aDoc);
// Read to domain object
final PSReader aReader = new PSReader(aSchRes);
final PSSchema aSchema = aReader.readSchemaFromXML(aDoc.getDocumentElement());
assertNotNull(aSchema);
// Create a compiled schema
final String sPhaseID = null;
final IPSErrorHandler aErrorHandler = null;
final IPSBoundSchema aBoundSchema = PSXPathQueryBinding.getInstance().bind(aSchema, sPhaseID, aErrorHandler);
// Validate completely
final SchematronOutputType aSVRL = aBoundSchema.validateComplete(DOMReader.readXMLDOM(aXmlRes), aXmlRes.getAsURL().toExternalForm());
assertNotNull(aSVRL);
if (false)
System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
}
use of com.helger.schematron.svrl.SVRLMarshaller in project ph-schematron by phax.
the class Issue44Test method validateAndProduceSVRL.
public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
// SchematronResourcePure fails!
ISchematronResource aSCH = SchematronResourcePure.fromFile(aSchematron);
// Parsing Schematron works!
aSCH = SchematronResourceSCH.fromFile(aSchematron);
// Perform validation
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
assertNotNull(aSVRL);
if (false)
System.out.println(new SVRLMarshaller().getAsString(aSVRL));
assertEquals(3, SVRLHelper.getAllFailedAssertionsAndSuccessfulReports(aSVRL).size());
}
use of com.helger.schematron.svrl.SVRLMarshaller in project ph-schematron by phax.
the class Issue48Test method validateAndProduceSVRL.
public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
final PSSchema aSchema = new PSReader(new FileSystemResource(aSchematron)).readSchema();
final PSPreprocessor aPreprocessor = new PSPreprocessor(PSXPathQueryBinding.getInstance());
final PSSchema aPreprocessedSchema = aPreprocessor.getAsPreprocessedSchema(aSchema);
final String sSCH = new PSWriter(new PSWriterSettings().setXMLWriterSettings(new XMLWriterSettings())).getXMLString(aPreprocessedSchema);
if (false)
System.out.println(sSCH);
final SchematronResourceSCH aSCH = new SchematronResourceSCH(new ReadableResourceString(sSCH, StandardCharsets.UTF_8));
// Perform validation
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
assertNotNull(aSVRL);
if (false)
System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
use of com.helger.schematron.svrl.SVRLMarshaller in project ph-schematron by phax.
the class IssueGC6Test method validateAndProduceSVRL.
public static void validateAndProduceSVRL(final File schematron, final File xml) throws Exception {
final IReadableResource aSchematron = new FileSystemResource(schematron.getAbsoluteFile());
final IReadableResource anXMLSource = new FileSystemResource(xml.getAbsoluteFile());
final AbstractSchematronResource pure = new SchematronResourcePure(aSchematron);
final SchematronOutputType aSVRL = pure.applySchematronValidationToSVRL(anXMLSource);
assertNotNull(aSVRL);
if (false)
System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
Aggregations