Treat all fatal XR schematron rules as errors, not as warnings.

In org.mustangproject.validator.XMLValidator.validateSchematron(),
the severity has to be determined for every node of the validation
result.  Otherwise, all schematron assertions tagged as "fatal"
will be treated as warnings after the first warning.
This commit is contained in:
Matthias Kilian
2024-11-29 22:02:09 +01:00
parent 803778df57
commit d0aeffdc1c
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 { public void validateSchematron(String xml, String xsltFilename, int section, ESeverity defaultSeverity) throws IrrecoverableValidationError {
ISchematronResource aResSCH = null; ISchematronResource aResSCH = null;
ESeverity severity=defaultSeverity;
if (defaultSeverity!=ESeverity.notice) {
severity=ESeverity.error;
}
aResSCH = SchematronResourceXSLT.fromClassPath(xsltFilename); aResSCH = SchematronResourceXSLT.fromClassPath(xsltFilename);
if (aResSCH != null) { if (aResSCH != null) {
@@ -470,14 +465,15 @@ public class XMLValidator extends Validator {
thisFailLocation = currentFailNode.getAttributes().getNamedItem("location").getNodeValue(); 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 // the XR issues warnings with flag=warning
if (currentFailNode.getAttributes().getNamedItem("flag").getNodeValue().equals("warning")) { severity = ESeverity.warning;
if (defaultSeverity!=ESeverity.notice) { } else {
severity=ESeverity.warning; severity = ESeverity.error;
}
}
} }
NodeList failChilds = currentFailNode.getChildNodes(); NodeList failChilds = currentFailNode.getChildNodes();

View File

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