use of com.helger.commons.io.resource.IReadableResource in project ph-schematron by phax.
the class PSWriterTest method testReadAll.
@Test
public void testReadAll() throws Exception {
final PSWriter aWriter = new PSWriter();
for (final IReadableResource aRes : SchematronTestHelper.getAllValidSchematronFiles()) {
// Parse the schema
final PSSchema aSchema1 = new PSReader(aRes).readSchema();
assertNotNull(aSchema1);
final CollectingPSErrorHandler aLogger = new CollectingPSErrorHandler();
assertTrue(aRes.getPath(), aSchema1.isValid(aLogger));
assertTrue(aLogger.isEmpty());
// Convert back to XML
final String sXML1 = aWriter.getXMLStringNotNull(aSchema1);
// Re-read the created XML and re-create it
final PSSchema aSchema2 = new PSReader(new ReadableResourceString(sXML1, StandardCharsets.UTF_8)).readSchema();
final String sXML2 = aWriter.getXMLStringNotNull(aSchema2);
// Originally created XML and re-created-written XML must match
assertEquals(sXML1, sXML2);
}
}
use of com.helger.commons.io.resource.IReadableResource in project ph-schematron by phax.
the class Issue30Test method testOfSchematronPH.
@Test
public void testOfSchematronPH() throws Exception {
final SchematronResourcePure aResPure = SchematronResourcePure.fromFile("src/test/resources/issues/github30/ph-test.sch");
aResPure.setEntityResolver(DefaultEntityResolver.createOnDemand(aResPure.getResource()));
final IPSErrorHandler aErrorHandler = new IPSErrorHandler() {
@Override
public void warn(final IReadableResource aRes, final IPSElement aSourceElement, final String sMessage) {
s_aLogger.info(sMessage);
}
@Override
public void error(final IReadableResource aRes, final IPSElement aSourceElement, final String sMessage, final Throwable t) {
s_aLogger.info(sMessage);
}
@Override
public void error(final IPSElement aSourceElement, final String sMessage) {
s_aLogger.info(sMessage);
}
};
aResPure.setErrorHandler(aErrorHandler);
aResPure.validateCompletely();
assertFalse(aResPure.isValidSchematron());
}
use of com.helger.commons.io.resource.IReadableResource 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 com.helger.commons.io.resource.IReadableResource 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));
}
use of com.helger.commons.io.resource.IReadableResource in project ph-schematron by phax.
the class IssueGC7Test 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