use of org.oclc.purl.dsdl.svrl.DiagnosticReference in project ph-schematron by phax.
the class Issue16Test method testIssue16.
@Test
@Ignore
public void testIssue16() throws Exception {
final File schematronFile = new ClassPathResource("issues/github16/sample_schematron.sch").getAsFile();
final File xmlFile = new ClassPathResource("issues/github16/test.xml").getAsFile();
final SchematronOutputType outputType = SchematronUtil.validateXMLViaXSLTSchematronFull(schematronFile, xmlFile);
if (outputType == null)
throw new Exception("SchematronOutputType null");
final List<SVRLSuccessfulReport> succeededList = SVRLHelper.getAllSuccessfulReports(outputType);
for (final SVRLSuccessfulReport succeededReport : succeededList) {
System.out.println(succeededReport.getTest());
}
int i = 1;
final List<SVRLFailedAssert> failedList = SVRLHelper.getAllFailedAssertions(outputType);
for (final SVRLFailedAssert failedAssert : failedList) {
System.out.println(i++ + ". Location:" + failedAssert.getLocation());
System.out.println("Test: " + failedAssert.getTest());
System.out.println("Text: " + failedAssert.getText());
final List<DiagnosticReference> diagnisticReferences = failedAssert.getDiagnisticReferences();
for (final DiagnosticReference diagnisticRef : diagnisticReferences) {
System.out.println("Diag ref: " + diagnisticRef.getDiagnostic());
System.out.println("Diag text: " + diagnisticRef.getText());
}
}
if (failedList.isEmpty()) {
System.out.println("PASS");
} else {
System.out.println("FAIL");
}
}
use of org.oclc.purl.dsdl.svrl.DiagnosticReference in project ph-schematron by phax.
the class PSXPathValidationHandlerSVRL method _handleDiagnosticReferences.
/**
* Handle the diagnostic references of a single assert/report element
*
* @param aSrcDiagnostics
* The list of diagnostic reference IDs in the source assert/report
* element. May be <code>null</code> if no diagnostic references are
* present
* @param aDstList
* The diagnostic reference list of the SchematronOutput to be filled.
* May not be <code>null</code>.
* @param aBoundAssertReport
* The bound assert report element. Never <code>null</code>.
* @param aRuleMatchingNode
* The XML node of the XML document currently validated. Never
* <code>null</code>.
* @throws SchematronValidationException
*/
private void _handleDiagnosticReferences(@Nullable final List<String> aSrcDiagnostics, @Nonnull final List<DiagnosticReference> aDstList, @Nonnull final PSXPathBoundAssertReport aBoundAssertReport, @Nonnull final Node aRuleMatchingNode) throws SchematronValidationException {
if (CollectionHelper.isNotEmpty(aSrcDiagnostics)) {
if (m_aSchema.hasDiagnostics()) {
final PSDiagnostics aDiagnostics = m_aSchema.getDiagnostics();
for (final String sDiagnosticID : aSrcDiagnostics) {
final PSXPathBoundDiagnostic aDiagnostic = aBoundAssertReport.getBoundDiagnosticOfID(sDiagnosticID);
if (aDiagnostic == null)
_warn(aDiagnostics, "Failed to resolve diagnostics with ID '" + sDiagnosticID + "'");
else {
// Create the SVRL diagnostic-reference element
final DiagnosticReference aDR = new DiagnosticReference();
aDR.setDiagnostic(sDiagnosticID);
aDR.setText(_getErrorText(aDiagnostic.getAllBoundContentElements(), aRuleMatchingNode));
aDstList.add(aDR);
}
}
} else
_warn(m_aSchema, "Failed to resolve diagnostic because schema has no diagnostics");
}
}
Aggregations