From aeb491873dbc7486cfc21d7d0609561e74942f55 Mon Sep 17 00:00:00 2001 From: jstaerk Date: Tue, 29 Oct 2024 07:03:19 +0100 Subject: [PATCH] closes #532 --- .../validator/XMLValidator.java | 19 +++++++++++++++++-- validator/src/test/resources/invalidXRV30.xml | 3 --- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/validator/src/main/java/org/mustangproject/validator/XMLValidator.java b/validator/src/main/java/org/mustangproject/validator/XMLValidator.java index abe94216..4392448e 100644 --- a/validator/src/main/java/org/mustangproject/validator/XMLValidator.java +++ b/validator/src/main/java/org/mustangproject/validator/XMLValidator.java @@ -419,11 +419,16 @@ public void validateXR(String xml, ESeverity errorImpact) throws IrrecoverableVa * @param xml the xml to be checked * @param xsltFilename the filename of the intermediate XSLT file * @param section the error type code, if one arises - * @param severity how serious a error should be treated - may only be notice + * @param defaultSeverity how serious a error should be treated - may only be notice * @throws IrrecoverableValidationError if anything happened that prevents further checks */ - public void validateSchematron(String xml, String xsltFilename, int section, ESeverity severity) throws IrrecoverableValidationError { + 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) { @@ -465,6 +470,16 @@ public void validateSchematron(String xml, String xsltFilename, int section, ESe thisFailLocation = currentFailNode.getAttributes().getNamedItem("location").getNodeValue(); } + if (currentFailNode.getAttributes().getNamedItem("flag") != null) { + // the XR issues warnings with flag=warning + if (currentFailNode.getAttributes().getNamedItem("flag").getNodeValue().equals("warning")) { + if (defaultSeverity!=ESeverity.notice) { + severity=ESeverity.warning; + } + } + + } + NodeList failChilds = currentFailNode.getChildNodes(); for (int failChildIndex = 0; failChildIndex < failChilds.getLength(); failChildIndex++) { if (failChilds.item(failChildIndex).getLocalName() != null) { diff --git a/validator/src/test/resources/invalidXRV30.xml b/validator/src/test/resources/invalidXRV30.xml index 6b62123d..0aa3b42c 100644 --- a/validator/src/test/resources/invalidXRV30.xml +++ b/validator/src/test/resources/invalidXRV30.xml @@ -115,9 +115,6 @@ [Seller city] DE - - seller@email.de - DE 123456789