reporting all errors, not just the last
This commit is contained in:
@@ -407,30 +407,36 @@ public class XMLValidator extends Validator {
|
|||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new IrrecoverableValidationError(e.getMessage());
|
throw new IrrecoverableValidationError(e.getMessage());
|
||||||
}
|
}
|
||||||
Document SVRLReport=new SVRLMarshaller().getAsDocument(sout);
|
Document SVRLReport = new SVRLMarshaller().getAsDocument(sout);
|
||||||
|
String SVRLReports = new SVRLMarshaller().getAsString(sout);
|
||||||
|
try {
|
||||||
|
Files.writeString(Paths.get("C:\\Users\\jstaerk\\workspace\\mustangproject\\log\\detail3.log"), SVRLReports, StandardCharsets.UTF_8);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
String expression = "//*[local-name() = 'failed-assert']";
|
String expression = "//*[local-name() = 'failed-assert']";
|
||||||
NodeList failedAsserts = null;
|
NodeList failedAsserts = null;
|
||||||
try {
|
try {
|
||||||
failedAsserts = (NodeList) xPath.compile(expression).evaluate(SVRLReport, XPathConstants.NODESET);
|
failedAsserts = (NodeList) xPath.compile(expression).evaluate(SVRLReport, XPathConstants.NODESET);
|
||||||
|
|
||||||
String thisFailText="";
|
String thisFailText = "";
|
||||||
String thisFailID="";
|
String thisFailID = "";
|
||||||
String thisFailTest="";
|
String thisFailTest = "";
|
||||||
String thisFailLocation="";
|
String thisFailLocation = "";
|
||||||
if (failedAsserts.getLength() > 0) {
|
if (failedAsserts.getLength() > 0) {
|
||||||
|
|
||||||
for (int nodeIndex = 0; nodeIndex < failedAsserts.getLength(); nodeIndex++) {
|
for (int nodeIndex = 0; nodeIndex < failedAsserts.getLength(); nodeIndex++) {
|
||||||
//nodes.item(i).getTextContent())) {
|
//nodes.item(i).getTextContent())) {
|
||||||
Node currentFailNode = failedAsserts.item(nodeIndex);
|
Node currentFailNode = failedAsserts.item(nodeIndex);
|
||||||
if (currentFailNode.getAttributes().getNamedItem("id") != null) {
|
if (currentFailNode.getAttributes().getNamedItem("id") != null) {
|
||||||
thisFailID=" [ID "+currentFailNode.getAttributes().getNamedItem("id").getNodeValue()+"]";
|
thisFailID = " [ID " + currentFailNode.getAttributes().getNamedItem("id").getNodeValue() + "]";
|
||||||
}
|
}
|
||||||
if (currentFailNode.getAttributes().getNamedItem("test") != null) {
|
if (currentFailNode.getAttributes().getNamedItem("test") != null) {
|
||||||
thisFailTest=currentFailNode.getAttributes().getNamedItem("test").getNodeValue();
|
thisFailTest = currentFailNode.getAttributes().getNamedItem("test").getNodeValue();
|
||||||
}
|
}
|
||||||
if (currentFailNode.getAttributes().getNamedItem("location") != null) {
|
if (currentFailNode.getAttributes().getNamedItem("location") != null) {
|
||||||
thisFailLocation=currentFailNode.getAttributes().getNamedItem("location").getNodeValue();
|
thisFailLocation = currentFailNode.getAttributes().getNamedItem("location").getNodeValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeList failChilds = currentFailNode.getChildNodes();
|
NodeList failChilds = currentFailNode.getChildNodes();
|
||||||
@@ -439,21 +445,21 @@ public class XMLValidator extends Validator {
|
|||||||
|
|
||||||
if (failChilds.item(failChildIndex).getLocalName().equals("text")) {
|
if (failChilds.item(failChildIndex).getLocalName().equals("text")) {
|
||||||
// if (itemChilds.item(failChildIndex).getAttributes().getNamedItem("schemeID") != null) {
|
// if (itemChilds.item(failChildIndex).getAttributes().getNamedItem("schemeID") != null) {
|
||||||
thisFailText=failChilds.item(failChildIndex).getTextContent();
|
thisFailText = failChilds.item(failChildIndex).getTextContent();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOGGER.info("FailedAssert ", thisFailText);
|
||||||
|
|
||||||
|
context.addResultItem(new ValidationResultItem(severity, thisFailText + thisFailID + " from " + xsltFilename + ")")
|
||||||
|
.setLocation(thisFailLocation).setCriterion(thisFailTest).setSection(section)
|
||||||
|
.setPart(EPart.fx));
|
||||||
|
failedRules++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.info("FailedAssert ", thisFailText);
|
|
||||||
|
|
||||||
context.addResultItem(new ValidationResultItem(severity, thisFailText + thisFailID + " from " + xsltFilename + ")")
|
|
||||||
.setLocation(thisFailLocation).setCriterion(thisFailTest).setSection(section)
|
|
||||||
.setPart(EPart.fx));
|
|
||||||
failedRules++;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (XPathExpressionException e) {
|
} catch (XPathExpressionException e) {
|
||||||
@@ -463,7 +469,7 @@ public class XMLValidator extends Validator {
|
|||||||
NodeList firedAsserts = null;
|
NodeList firedAsserts = null;
|
||||||
try {
|
try {
|
||||||
firedAsserts = (NodeList) xPath.compile(expression).evaluate(SVRLReport, XPathConstants.NODESET);
|
firedAsserts = (NodeList) xPath.compile(expression).evaluate(SVRLReport, XPathConstants.NODESET);
|
||||||
firedRules=firedAsserts.getLength();
|
firedRules = firedAsserts.getLength();
|
||||||
} catch (XPathExpressionException e) {
|
} catch (XPathExpressionException e) {
|
||||||
LOGGER.error(e.getMessage(), e);
|
LOGGER.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user