use of com.helger.commons.io.resource.inmemory.ReadableResourceString 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.inmemory.ReadableResourceString 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.commons.io.resource.inmemory.ReadableResourceString in project ph-schematron by phax.
the class IssueSO32784781Test method testBasic.
@Test
public void testBasic() {
final String sSCH = "<schema xmlns=\"http://purl.oclc.org/dsdl/schematron\">\r\n" + " <ns prefix=\"m\" uri=\"http://www.ociweb.com/movies\"/>\r\n" + " <pattern name=\"all\">\r\n" + " <rule context=\"m:actor\">\r\n" + " <report test=\"@role=preceding-sibling::m:actor/@role\"\r\n" + " diagnostics=\"duplicateActorRole\">\r\n" + " Duplicate role!\r\n" + " </report>\r\n" + " </rule>\r\n" + " </pattern>\r\n" + " <diagnostics>\r\n" + " <diagnostic id=\"duplicateActorRole\">\r\n" + " More than one actor plays the role<value-of select=\"@role\"/>.\r\n" + " A duplicate is named<value-of select=\"@name\"/>.\r\n" + " </diagnostic>\r\n" + " </diagnostics>\r\n" + "</schema>";
final ISchematronResource isr = new SchematronResourceSCH(new ReadableResourceString(sSCH, StandardCharsets.UTF_8));
assertTrue(isr.isValidSchematron());
}
Aggregations