updating ph-schematron version
This commit is contained in:
@@ -11,8 +11,8 @@
|
|||||||
<artifactId>library</artifactId>
|
<artifactId>library</artifactId>
|
||||||
<version>2.5.5-SNAPSHOT</version>
|
<version>2.5.5-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Library to write, read and validate e-invoices (Factur-X, ZUGFeRD and to a limited extend XRechnung/CII). </name>
|
<name>Library to write, read and validate e-invoices (Factur-X, ZUGFeRD, Order-X, XRechnung/CII)</name>
|
||||||
<description>The Mustang project is a java library to read, write and validate Factur-X/ZUGFeRD meta data inside your invoice PDFs. To write files, a provided PDF/A will be combined with generated or provided XML.
|
<description>FOSS Java library to read, write and validate european electronic invoices and orders in the UN/CEFACT Cross Industry Invoice based formats Factur-X/ZUGFeRD, XRechnung and Order-X in your invoice PDFs.
|
||||||
</description>
|
</description>
|
||||||
<url>http://www.mustangproject.org/</url>
|
<url>http://www.mustangproject.org/</url>
|
||||||
<scm>
|
<scm>
|
||||||
@@ -105,12 +105,6 @@
|
|||||||
<version>2.3.3</version>
|
<version>2.3.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.helger</groupId>
|
|
||||||
<artifactId>ph-schematron</artifactId>
|
|
||||||
<version>5.0.4</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.xmlunit</groupId>
|
<groupId>org.xmlunit</groupId>
|
||||||
<artifactId>xmlunit-core</artifactId>
|
<artifactId>xmlunit-core</artifactId>
|
||||||
|
|||||||
@@ -78,9 +78,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.helger/ph-schematron -->
|
<!-- https://mvnrepository.com/artifact/com.helger/ph-schematron -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.helger</groupId>
|
<groupId>com.helger.schematron</groupId>
|
||||||
<artifactId>ph-schematron</artifactId>
|
<artifactId>ph-schematron-xslt</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>6.3.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.helger</groupId>
|
<groupId>com.helger</groupId>
|
||||||
@@ -158,8 +158,8 @@
|
|||||||
<!-- http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven
|
<!-- http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven
|
||||||
mvn clean compile assembly:single -->
|
mvn clean compile assembly:single -->
|
||||||
<!-- or whatever version you use -->
|
<!-- or whatever version you use -->
|
||||||
<source>8</source>
|
<source>11</source>
|
||||||
<target>8</target>
|
<target>11</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- /ZUV -->
|
<!-- /ZUV -->
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.io.StringReader;
|
|||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -13,12 +14,13 @@ import java.util.List;
|
|||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.transform.stream.StreamSource;
|
import javax.xml.transform.stream.StreamSource;
|
||||||
import javax.xml.xpath.XPath;
|
import javax.xml.xpath.*;
|
||||||
import javax.xml.xpath.XPathConstants;
|
|
||||||
import javax.xml.xpath.XPathExpression;
|
|
||||||
import javax.xml.xpath.XPathFactory;
|
|
||||||
|
|
||||||
|
import com.helger.schematron.svrl.SVRLMarshaller;
|
||||||
import com.helger.schematron.svrl.jaxb.ActivePattern;
|
import com.helger.schematron.svrl.jaxb.ActivePattern;
|
||||||
|
import com.helger.schematron.xslt.SchematronResourceXSLTCache;
|
||||||
|
import org.mustangproject.Contact;
|
||||||
|
import org.mustangproject.SchemedID;
|
||||||
import org.mustangproject.XMLTools;
|
import org.mustangproject.XMLTools;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -392,6 +394,7 @@ public class XMLValidator extends Validator {
|
|||||||
public void validateSchematron(String xml, String xsltFilename, int section, ESeverity severity) throws IrrecoverableValidationError {
|
public void validateSchematron(String xml, String xsltFilename, int section, ESeverity severity) throws IrrecoverableValidationError {
|
||||||
ISchematronResource aResSCH = null;
|
ISchematronResource aResSCH = null;
|
||||||
aResSCH = SchematronResourceXSLT.fromClassPath(xsltFilename);
|
aResSCH = SchematronResourceXSLT.fromClassPath(xsltFilename);
|
||||||
|
|
||||||
if (aResSCH != null) {
|
if (aResSCH != null) {
|
||||||
if (!aResSCH.isValidSchematron()) {
|
if (!aResSCH.isValidSchematron()) {
|
||||||
throw new IllegalArgumentException(xsltFilename + " is invalid Schematron!");
|
throw new IllegalArgumentException(xsltFilename + " is invalid Schematron!");
|
||||||
@@ -404,25 +407,68 @@ 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);
|
||||||
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
|
String expression = "//*[local-name() = 'failed-assert']";
|
||||||
|
NodeList failedAsserts = null;
|
||||||
|
try {
|
||||||
|
failedAsserts = (NodeList) xPath.compile(expression).evaluate(SVRLReport, XPathConstants.NODESET);
|
||||||
|
|
||||||
final List<Object> failedAsserts = sout.getActivePatternAndFiredRuleAndFailedAssert();
|
String thisFailText="";
|
||||||
if (failedAsserts.size() > 0) {
|
String thisFailID="";
|
||||||
for (final Object object : failedAsserts) {
|
String thisFailTest="";
|
||||||
if (object instanceof FailedAssert) {
|
String thisFailLocation="";
|
||||||
|
if (failedAsserts.getLength() > 0) {
|
||||||
|
|
||||||
final FailedAssert failedAssert = (FailedAssert) object;
|
for (int nodeIndex = 0; nodeIndex < failedAsserts.getLength(); nodeIndex++) {
|
||||||
LOGGER.info("FailedAssert ", failedAssert);
|
//nodes.item(i).getTextContent())) {
|
||||||
|
Node currentFailNode = failedAsserts.item(nodeIndex);
|
||||||
|
if (currentFailNode.getAttributes().getNamedItem("id") != null) {
|
||||||
|
thisFailID=" [ID "+currentFailNode.getAttributes().getNamedItem("id").getNodeValue()+"]";
|
||||||
|
}
|
||||||
|
if (currentFailNode.getAttributes().getNamedItem("test") != null) {
|
||||||
|
thisFailTest=currentFailNode.getAttributes().getNamedItem("test").getNodeValue();
|
||||||
|
}
|
||||||
|
if (currentFailNode.getAttributes().getNamedItem("location") != null) {
|
||||||
|
thisFailLocation=currentFailNode.getAttributes().getNamedItem("location").getNodeValue();
|
||||||
|
}
|
||||||
|
|
||||||
context.addResultItem(new ValidationResultItem(severity, SVRLHelper.getAsString(failedAssert.getText())+" (From "+xsltFilename+")")
|
NodeList failChilds = currentFailNode.getChildNodes();
|
||||||
.setLocation(failedAssert.getLocation()).setCriterion(failedAssert.getTest()).setSection(section)
|
for (int failChildIndex = 0; failChildIndex < failChilds.getLength(); failChildIndex++) {
|
||||||
.setPart(EPart.fx));
|
if (failChilds.item(failChildIndex).getLocalName() != null) {
|
||||||
failedRules++;
|
|
||||||
} else if (object instanceof FiredRule) {
|
if (failChilds.item(failChildIndex).getLocalName().equals("text")) {
|
||||||
firedRules++;
|
// if (itemChilds.item(failChildIndex).getAttributes().getNamedItem("schemeID") != null) {
|
||||||
|
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++;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (XPathExpressionException e) {
|
||||||
|
LOGGER.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
expression = "//*[local-name() = 'fired-rule']";
|
||||||
|
NodeList firedAsserts = null;
|
||||||
|
try {
|
||||||
|
firedAsserts = (NodeList) xPath.compile(expression).evaluate(SVRLReport, XPathConstants.NODESET);
|
||||||
|
firedRules=firedAsserts.getLength();
|
||||||
|
} catch (XPathExpressionException e) {
|
||||||
|
LOGGER.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (firedRules == 0) {
|
if (firedRules == 0) {
|
||||||
context.addResultItem(new ValidationResultItem(ESeverity.error, "No rules matched, XML to minimal?").setSection(26)
|
context.addResultItem(new ValidationResultItem(ESeverity.error, "No rules matched, XML to minimal?").setSection(26)
|
||||||
.setPart(EPart.fx));
|
.setPart(EPart.fx));
|
||||||
|
|||||||
Reference in New Issue
Block a user