use of org.oclc.purl.dsdl.svrl.SchematronOutputType in project ph-schematron by phax.
the class Issue36Test method testNestedExtends.
@Test
public void testNestedExtends() throws Exception {
final SchematronResourcePure aResPure = SchematronResourcePure.fromFile("src/test/resources/issues/github36/test2.sch");
aResPure.setErrorHandler(new LoggingPSErrorHandler());
final SchematronOutputType aSOT = aResPure.applySchematronValidationToSVRL(new FileSystemResource("src/test/resources/issues/github36/test.xml"));
assertNotNull(aSOT);
assertFalse(SVRLHelper.getAllFailedAssertions(aSOT).isEmpty());
}
use of org.oclc.purl.dsdl.svrl.SchematronOutputType in project ph-schematron by phax.
the class Issue36Test method test.
@Test
public void test() throws Exception {
final SchematronResourcePure aResPure = SchematronResourcePure.fromFile("src/test/resources/issues/github36/test.sch");
aResPure.setErrorHandler(new LoggingPSErrorHandler());
final SchematronOutputType aSOT = aResPure.applySchematronValidationToSVRL(new FileSystemResource("src/test/resources/issues/github36/test.xml"));
assertNotNull(aSOT);
assertFalse(SVRLHelper.getAllFailedAssertions(aSOT).isEmpty());
}
use of org.oclc.purl.dsdl.svrl.SchematronOutputType 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 org.oclc.purl.dsdl.svrl.SchematronOutputType in project ph-schematron by phax.
the class Issue16Test method testIssue16.
@Test
@Ignore
public void testIssue16() throws Exception {
final File schematronFile = new ClassPathResource("issues/github16/sample_schematron.sch").getAsFile();
final File xmlFile = new ClassPathResource("issues/github16/test.xml").getAsFile();
final SchematronOutputType outputType = SchematronUtil.validateXMLViaXSLTSchematronFull(schematronFile, xmlFile);
if (outputType == null)
throw new Exception("SchematronOutputType null");
final List<SVRLSuccessfulReport> succeededList = SVRLHelper.getAllSuccessfulReports(outputType);
for (final SVRLSuccessfulReport succeededReport : succeededList) {
System.out.println(succeededReport.getTest());
}
int i = 1;
final List<SVRLFailedAssert> failedList = SVRLHelper.getAllFailedAssertions(outputType);
for (final SVRLFailedAssert failedAssert : failedList) {
System.out.println(i++ + ". Location:" + failedAssert.getLocation());
System.out.println("Test: " + failedAssert.getTest());
System.out.println("Text: " + failedAssert.getText());
final List<DiagnosticReference> diagnisticReferences = failedAssert.getDiagnisticReferences();
for (final DiagnosticReference diagnisticRef : diagnisticReferences) {
System.out.println("Diag ref: " + diagnisticRef.getDiagnostic());
System.out.println("Diag text: " + diagnisticRef.getText());
}
}
if (failedList.isEmpty()) {
System.out.println("PASS");
} else {
System.out.println("FAIL");
}
}
use of org.oclc.purl.dsdl.svrl.SchematronOutputType 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());
}
Aggregations