use of com.helger.schematron.pure.SchematronResourcePure in project ph-schematron by phax.
the class Issue29Test method validateXmlUsingSchematron.
@Nullable
static SchematronOutputType validateXmlUsingSchematron(@Nonnull final IReadableResource aRes) {
SchematronOutputType ob = null;
// Must use the XSLT based version, because of "key" usage
final ISchematronResource aResSCH = new SchematronResourcePure(new ClassPathResource("issues/github29/pbs.sch"));
if (!aResSCH.isValidSchematron())
throw new IllegalArgumentException("Invalid Schematron!");
try {
final Document aDoc = aResSCH.applySchematronValidation(new ResourceStreamSource(aRes));
if (aDoc != null) {
final SVRLMarshaller marshaller = new SVRLMarshaller();
ob = marshaller.read(aDoc);
}
} catch (final Exception pE) {
pE.printStackTrace();
}
return ob;
}
use of com.helger.schematron.pure.SchematronResourcePure in project ph-schematron by phax.
the class Issue25Test method testIssue25Invalid.
@Test
public void testIssue25Invalid() throws Exception {
final IReadableResource aSCH = new ClassPathResource("test-sch/xfront/example05/check-classifications.sch");
final IReadableResource aXML = new ClassPathResource("test-sch/xfront/example05/invalid-document.xml");
final SchematronOutputType aSOT = SchematronHelper.applySchematron(new SchematronResourcePure(aSCH), aXML);
assertNotNull(aSOT);
assertTrue(SVRLHelper.getAllFailedAssertions(aSOT).isNotEmpty());
}
use of com.helger.schematron.pure.SchematronResourcePure in project ph-schematron by phax.
the class Issue25Test method testIssue25Valid.
@Test
public void testIssue25Valid() throws Exception {
final IReadableResource aSCH = new ClassPathResource("test-sch/xfront/example05/check-classifications.sch");
final IReadableResource aXML = new ClassPathResource("test-sch/xfront/example05/valid-document.xml");
final SchematronOutputType aSOT = SchematronHelper.applySchematron(new SchematronResourcePure(aSCH), aXML);
assertNotNull(aSOT);
assertTrue(SVRLHelper.getAllFailedAssertions(aSOT).isEmpty());
}
use of com.helger.schematron.pure.SchematronResourcePure in project ph-schematron by phax.
the class Issue6Test method validateAndProduceSVRL.
@SuppressFBWarnings("BC_IMPOSSIBLE_INSTANCEOF")
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 aSCH = new SchematronResourceSCH(aSchematron);
if (aSCH instanceof SchematronResourcePure)
((SchematronResourcePure) aSCH).setErrorHandler(new LoggingPSErrorHandler());
else
System.out.println(XMLWriter.getNodeAsString(((SchematronResourceSCH) aSCH).getXSLTProvider().getXSLTDocument()));
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(anXMLSource);
assertNotNull(aSVRL);
if (false)
System.out.println(new SVRLMarshaller().getAsString(aSVRL));
}
use of com.helger.schematron.pure.SchematronResourcePure in project ph-schematron by phax.
the class IssueGC9Test 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