diff --git a/validator/src/main/java/org/mustangproject/validator/XMLValidator.java b/validator/src/main/java/org/mustangproject/validator/XMLValidator.java index f4caab88..d8855aea 100644 --- a/validator/src/main/java/org/mustangproject/validator/XMLValidator.java +++ b/validator/src/main/java/org/mustangproject/validator/XMLValidator.java @@ -254,7 +254,7 @@ public class XMLValidator extends Validator { the validation against the XRechnung Schematron will happen below but a XRechnung is a EN16931 subset so the validation vis a vis FACTUR-X_EN16931.xslt=schematron also has to pass * */ - //validateSchema(zfXML.getBytes(StandardCharsets.UTF_8), "ZF_211/EN16931/FACTUR-X_EN16931.xsd", 18, EPart.fx); + validateSchema(zfXML.getBytes(StandardCharsets.UTF_8), currentZFVersionDir + "/EN16931/FACTUR-X_EN16931.xsd", 18, EPart.fx); XrechnungSeverity = ESeverity.error; } else if (isExtended) { diff --git a/validator/src/test/java/org/mustangproject/validator/XMLValidatorTest.java b/validator/src/test/java/org/mustangproject/validator/XMLValidatorTest.java index 285fc77b..8b6022f5 100644 --- a/validator/src/test/java/org/mustangproject/validator/XMLValidatorTest.java +++ b/validator/src/test/java/org/mustangproject/validator/XMLValidatorTest.java @@ -226,6 +226,25 @@ public class XMLValidatorTest extends ResourceCase { content = xpath.evaluate("/validation/summary/@status", source); assertEquals("invalid", content); + } catch (final IrrecoverableValidationError e) { + // ignore, will be in XML output anyway + } + + } + + public void testXRSchemaValidation() { + final ValidationContext ctx = new ValidationContext(null); + final XMLValidator xv = new XMLValidator(ctx); + final XPathEngine xpath = new JAXPXPathEngine(); + + File tempFile = getResourceAsFile("invalidXRSchemav2.xml"); + try { + xv.setFilename(tempFile.getAbsolutePath()); + xv.validate(); + + Source source = Input.fromString("" + xv.getXMLResult() + "").build(); + String content = xpath.evaluate("/validation/summary/@status", source); + assertEquals("invalid", content); } catch (final IrrecoverableValidationError e) { // ignore, will be in XML output anyway diff --git a/validator/src/test/resources/invalidXRSchemav2.xml b/validator/src/test/resources/invalidXRSchemav2.xml new file mode 100644 index 00000000..4e623c3d --- /dev/null +++ b/validator/src/test/resources/invalidXRSchemav2.xml @@ -0,0 +1,202 @@ + + + + + urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.0 + + + + 1234567 + 380 + + Invoice Note Description + AAC + + + 20180413 + + + + + + 1 + + + Beratung + + + + 143.75 + + + + 30 + + + + VAT + S + 19 + + + 4743.75 + + + + + + 2 + + + Beratung + + + + 143.75 + + + + 42 + + + + VAT + S + 19 + + + 6037.5 + + + + + 90000000-03083-12 + + [Seller name] + + GmbH + + + Tim Tester + + 012 3456789 + + + tim.tester@test.com + + + + 12345 + [Seller city] + DE + + + ATU123456789 + + + + 138 + [Buyer name] + + GmbH + + + Tina Tester + + 0800 123456 + + + tester@test.de + + + + 98765 + [Buyer city] + DE + + + DE12345ABC + + + + [Seller tax representative name] + + DE + + + DE124567 + + + + ABC123456789 + + + 65002278 + + + + + 68 + [Deliver to party name] + + 98765 + [Deliver to street] + 4. OG + [Deliver to city] + DE + Bayern + + + + + 20180413 + + + + + Deb. 12345 / Fact. 9876543 + EUR + + 74 + [Payee name] + + + 30 + + DE12100200000123456878 + + + + 2048.44 + VAT + 10781.25 + S + 19 + + + + 20180413 + + + 20180413 + + + + + 20180413 + + + + 10781.25 + 10781.25 + 2048.44 + 12829.69 + 12829.69 + + + +