Merge pull request #595 from mkilian/xr-val-schematron-err

Treat all fatal XR schematron rules as errors, not as warnings.
This commit is contained in:
Jochen Staerk
2024-12-03 13:18:59 +01:00
committed by GitHub
2 changed files with 10 additions and 14 deletions

View File

@@ -424,11 +424,6 @@ public class XMLValidator extends Validator {
*/
public void validateSchematron(String xml, String xsltFilename, int section, ESeverity defaultSeverity) throws IrrecoverableValidationError {
ISchematronResource aResSCH = null;
ESeverity severity=defaultSeverity;
if (defaultSeverity!=ESeverity.notice) {
severity=ESeverity.error;
}
aResSCH = SchematronResourceXSLT.fromClassPath(xsltFilename);
if (aResSCH != null) {
@@ -472,14 +467,15 @@ public class XMLValidator extends Validator {
thisFailLocation = currentFailNode.getAttributes().getNamedItem("location").getNodeValue();
}
if (currentFailNode.getAttributes().getNamedItem("flag") != null) {
ESeverity severity;
if (defaultSeverity == ESeverity.notice) {
severity = defaultSeverity;
} else if (currentFailNode.getAttributes().getNamedItem("flag") != null
&& currentFailNode.getAttributes().getNamedItem("flag").getNodeValue().equals("warning")) {
// the XR issues warnings with flag=warning
if (currentFailNode.getAttributes().getNamedItem("flag").getNodeValue().equals("warning")) {
if (defaultSeverity!=ESeverity.notice) {
severity=ESeverity.warning;
}
}
severity = ESeverity.warning;
} else {
severity = ESeverity.error;
}
NodeList failChilds = currentFailNode.getChildNodes();

View File

@@ -216,10 +216,10 @@ public class ZUGFeRDValidatorTest extends ResourceCase {
assertThat(res).valueByXPath("count(//error)")
.asInt()
.isEqualTo(1);
.isEqualTo(2);
assertThat(res).valueByXPath("count(//warning)")
.asInt()
.isEqualTo(3);
.isEqualTo(2);
assertThat(res).valueByXPath("count(//notice)")
.asInt()