use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.
the class IssueGlobalLetTest 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 SchematronResourceSCH(aSchematron);
final SchematronOutputType aSVRL = pure.applySchematronValidationToSVRL(anXMLSource);
assertNotNull(aSVRL);
if (false)
LOGGER.info(new SVRLMarshaller().setFormattedOutput(true).getAsString(aSVRL));
}
use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.
the class SVRLMarshallerFuncTest method testWriteValid.
@Test
public void testWriteValid() throws Exception {
final Document aDoc = SchematronResourceSCH.fromClassPath(VALID_SCHEMATRON).applySchematronValidation(new ClassPathResource(VALID_XMLINSTANCE));
assertNotNull(aDoc);
final SchematronOutputType aSO = new SVRLMarshaller().read(aDoc);
// Create XML
final Document aDoc2 = new SVRLMarshaller().getAsDocument(aSO);
assertNotNull(aDoc2);
assertEquals(CSVRL.SVRL_NAMESPACE_URI, aDoc2.getDocumentElement().getNamespaceURI());
// Create String
final String sDoc2 = new SVRLMarshaller().getAsString(aSO);
assertTrue(StringHelper.hasText(sDoc2));
assertTrue(sDoc2.contains(CSVRL.SVRL_NAMESPACE_URI));
}
use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.
the class SVRLMarshallerFuncTest method testReadInvalidSchematron.
@Test
public void testReadInvalidSchematron() {
try {
// Read null
new SVRLMarshaller().read((Node) null);
fail();
} catch (final NullPointerException ex) {
}
try {
// Read empty XML
new SVRLMarshaller().read(XMLFactory.newDocument());
fail();
} catch (final NullPointerException ex) {
}
// Read XML that is not SVRL
final ClassPathResource aRes = new ClassPathResource("test-xml/goodOrder01.xml");
assertTrue(aRes.exists());
final SchematronOutputType aSVRL = new SVRLMarshaller().read(aRes);
assertNull(aSVRL);
}
use of com.helger.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.
the class Issue085Test method validateAndProduceSVRL.
public static void validateAndProduceSVRL(@Nonnull final File aSchematron, final File aXML) throws Exception {
final SchematronResourceSCH aSCH = SchematronResourceSCH.fromFile(aSchematron);
if (false)
System.out.println(XMLWriter.getNodeAsString(aSCH.getXSLTProvider().getXSLTDocument()));
// 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.schematron.svrl.jaxb.SchematronOutputType in project ph-schematron by phax.
the class Issue108Test method _validateAndProduceSVRL.
private static void _validateAndProduceSVRL(@Nonnull final File aSchematron, @Nonnull final File aXML) throws Exception {
SchematronDebug.setSaveIntermediateXSLTFiles(true);
final ISchematronResource aSCH = SchematronResourceSCH.fromFile(aSchematron);
// Perform validation
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL(new FileSystemResource(aXML));
assertNotNull(aSVRL);
LOGGER.info("SVRL:\n" + new SVRLMarshaller().getAsString(aSVRL));
if (false)
assertTrue(SVRLHelper.getAllFailedAssertionsAndSuccessfulReports(aSVRL).isEmpty());
}
Aggregations