use of org.oclc.purl.dsdl.svrl.SchematronOutputType 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 org.oclc.purl.dsdl.svrl.SchematronOutputType in project ph-schematron by phax.
the class AbstractSchematronXSLTBasedResource method getSchematronValidity.
@Nonnull
public EValidity getSchematronValidity(@Nonnull final Node aXMLNode, @Nullable final String sBaseURI) throws Exception {
ValueEnforcer.notNull(aXMLNode, "XMLNode");
// We don't have a short circuit here - apply the full validation
final SchematronOutputType aSO = applySchematronValidationToSVRL(aXMLNode, sBaseURI);
if (aSO == null)
return EValidity.INVALID;
// And now filter all elements that make the passed source invalid
return m_aXSLTValidator.getSchematronValidity(aSO);
}
use of org.oclc.purl.dsdl.svrl.SchematronOutputType in project ph-schematron by phax.
the class SchematronHelperTest method testReadInvalidSchematronValidXML.
@Test
public void testReadInvalidSchematronValidXML() {
final SchematronOutputType aSO = SchematronHelper.applySchematron(SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON + ".does.not.exist"), new ClassPathResource(VALID_XMLINSTANCE));
assertNull("Invalid Schematron", aSO);
}
use of org.oclc.purl.dsdl.svrl.SchematronOutputType in project ph-schematron by phax.
the class SchematronHelperTest method testReadValidSchematronValidXML.
@Test
public void testReadValidSchematronValidXML() {
final ISchematronResource aSchematron = SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON);
final IReadableResource aXML = new ClassPathResource(VALID_XMLINSTANCE);
final SchematronOutputType aSO = SchematronHelper.applySchematron(aSchematron, aXML);
assertNotNull("Failed to parse Schematron output", aSO);
}
use of org.oclc.purl.dsdl.svrl.SchematronOutputType in project ph-schematron by phax.
the class SchematronHelperTest method testReadValidSchematronValidXMLFromFile.
@Test
public void testReadValidSchematronValidXMLFromFile() {
final ISchematronResource aSchematron = SchematronResourcePure.fromClassPath(VALID_SCHEMATRON);
final SchematronOutputType aSO = SchematronHelper.applySchematron(aSchematron, TransformSourceFactory.create(new File("src/test/resources/xml-files/valid01.xml")));
assertNotNull("Failed to parse Schematron output", aSO);
}
Aggregations