diff --git a/History.md b/History.md index 505b6cc..fd9add1 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +0.8.0 +====== +2019-07-08 + +* updated Mustang to mitigate #20 zf1 validation does not always return a section +* validate not only against *schematron* but also against *schema* files + 0.7.0 ====== 2019-05-31 diff --git a/pom.xml b/pom.xml index c7f4e95..775ab51 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.zugferd ZUV jar - 0.7.1-SNAPSHOT + 0.8.0 mavencentral @@ -71,7 +71,7 @@ org.mustangproject.ZUGFeRD mustang - 1.7.1 + 1.7.2 diff --git a/src/main/java/ZUV/Main.java b/src/main/java/ZUV/Main.java index 569027e..8fc9a8a 100644 --- a/src/main/java/ZUV/Main.java +++ b/src/main/java/ZUV/Main.java @@ -153,6 +153,7 @@ private boolean performValidation(String pdfFileName, String xmlFileName) { displayXMLValidationOutput=true; } else { //no XML found. This could also be an error. + LOGGER.error("No XML could be extracted"); } } diff --git a/src/main/java/ZUV/XMLValidator.java b/src/main/java/ZUV/XMLValidator.java index d276f73..0b5b3a1 100644 --- a/src/main/java/ZUV/XMLValidator.java +++ b/src/main/java/ZUV/XMLValidator.java @@ -195,15 +195,15 @@ public void validate() { isExtended = context.getProfile().contains("extended"); if (isMiniumum) { - validateSchema("BASIC"); + validateSchema("zf2/BASIC/zugferd2p0_basicwl_minimum.xsd"); aResSCH = SchematronResourceXSLT.fromClassPath("/xslt/zugferd2p0_basicwl_minimum.xslt"); } else if (isEN16931) { - validateSchema("EN16931"); + validateSchema("zf2/EN16931/zugferd2p0_en16931.xsd"); aResSCH = SchematronResourceXSLT.fromClassPath("/xslt/zugferd2p0_en16931.xslt"); } else if (isExtended) { - validateSchema("EXTENDED"); + validateSchema("zf2/EXTENDED/zugferd2p0_extended.xsd"); aResSCH = SchematronResourceXSLT.fromClassPath("/xslt/zugferd2p0_extended.xslt"); } /* @@ -227,6 +227,8 @@ public void validate() { context.addResultItem(new ValidationResultItem(ESeverity.error, "Unsupported profile type") .setSection(25).setPart(EPart.xml)); } + validateSchema("zf1/ZUGFeRD1p0.xsd"); + aResSCH = SchematronResourceXSLT.fromClassPath("/xslt/ZUGFeRD_1p0.xslt"); } @@ -328,7 +330,7 @@ public void validate() { } protected void validateSchema(String path) { - URL schemaFile = ClassLoader.getSystemResource("schema/"+path+"/zugferd2p0_en16931.xsd"); + URL schemaFile = ClassLoader.getSystemResource("schema/"+path); Source xmlFile = new StreamSource(new StringReader(zfXML)); SchemaFactory schemaFactory = SchemaFactory .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); diff --git a/src/main/resources/schema/zf1/ZUGFeRD1p0.xsd b/src/main/resources/schema/zf1/ZUGFeRD1p0.xsd new file mode 100644 index 0000000..70dd2b3 --- /dev/null +++ b/src/main/resources/schema/zf1/ZUGFeRD1p0.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + diff --git a/src/main/resources/schema/zf1/ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_QualifiedDataType_12.xsd b/src/main/resources/schema/zf1/ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_QualifiedDataType_12.xsd new file mode 100644 index 0000000..2185d7b --- /dev/null +++ b/src/main/resources/schema/zf1/ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_QualifiedDataType_12.xsd @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/schema/zf1/ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_12.xsd b/src/main/resources/schema/zf1/ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_12.xsd new file mode 100644 index 0000000..41ad6b9 --- /dev/null +++ b/src/main/resources/schema/zf1/ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_12.xsd @@ -0,0 +1,352 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/schema/zf1/ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_15.xsd b/src/main/resources/schema/zf1/ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_15.xsd new file mode 100644 index 0000000..2e3f0e1 --- /dev/null +++ b/src/main/resources/schema/zf1/ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_15.xsd @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/schema/BASIC/zugferd2p0_basicwl_minimum.xsd b/src/main/resources/schema/zf2/BASIC/zugferd2p0_basicwl_minimum.xsd similarity index 100% rename from src/main/resources/schema/BASIC/zugferd2p0_basicwl_minimum.xsd rename to src/main/resources/schema/zf2/BASIC/zugferd2p0_basicwl_minimum.xsd diff --git a/src/main/resources/schema/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd b/src/main/resources/schema/zf2/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd similarity index 100% rename from src/main/resources/schema/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd rename to src/main/resources/schema/zf2/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd diff --git a/src/main/resources/schema/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd b/src/main/resources/schema/zf2/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd similarity index 100% rename from src/main/resources/schema/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd rename to src/main/resources/schema/zf2/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd diff --git a/src/main/resources/schema/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd b/src/main/resources/schema/zf2/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd similarity index 100% rename from src/main/resources/schema/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd rename to src/main/resources/schema/zf2/BASIC/zugferd2p0_basicwl_minimum_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd diff --git a/src/main/resources/schema/EN16931/zugferd2p0_en16931.xsd b/src/main/resources/schema/zf2/EN16931/zugferd2p0_en16931.xsd similarity index 100% rename from src/main/resources/schema/EN16931/zugferd2p0_en16931.xsd rename to src/main/resources/schema/zf2/EN16931/zugferd2p0_en16931.xsd diff --git a/src/main/resources/schema/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd b/src/main/resources/schema/zf2/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd similarity index 100% rename from src/main/resources/schema/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd rename to src/main/resources/schema/zf2/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd diff --git a/src/main/resources/schema/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd b/src/main/resources/schema/zf2/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd similarity index 100% rename from src/main/resources/schema/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd rename to src/main/resources/schema/zf2/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd diff --git a/src/main/resources/schema/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd b/src/main/resources/schema/zf2/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd similarity index 100% rename from src/main/resources/schema/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd rename to src/main/resources/schema/zf2/EN16931/zugferd2p0_en16931_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd diff --git a/src/main/resources/schema/EXTENDED/zugferd2p0_extended.xsd b/src/main/resources/schema/zf2/EXTENDED/zugferd2p0_extended.xsd similarity index 100% rename from src/main/resources/schema/EXTENDED/zugferd2p0_extended.xsd rename to src/main/resources/schema/zf2/EXTENDED/zugferd2p0_extended.xsd diff --git a/src/main/resources/schema/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd b/src/main/resources/schema/zf2/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd similarity index 100% rename from src/main/resources/schema/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd rename to src/main/resources/schema/zf2/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd diff --git a/src/main/resources/schema/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd b/src/main/resources/schema/zf2/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd similarity index 100% rename from src/main/resources/schema/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd rename to src/main/resources/schema/zf2/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd diff --git a/src/main/resources/schema/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd b/src/main/resources/schema/zf2/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd similarity index 100% rename from src/main/resources/schema/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd rename to src/main/resources/schema/zf2/EXTENDED/zugferd2p0_extended_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd diff --git a/src/test/java/ZUV/XMLValidatorTest.java b/src/test/java/ZUV/XMLValidatorTest.java index b06b091..3787ad8 100644 --- a/src/test/java/ZUV/XMLValidatorTest.java +++ b/src/test/java/ZUV/XMLValidatorTest.java @@ -44,12 +44,19 @@ public void testZF2XMLValidation() { public void testZF1XMLValidation() { ValidationContext ctx=new ValidationContext(); XMLValidator xv = new XMLValidator(ctx); - File tempFile = getResourceAsFile("invalidV1TooMinimal.xml"); - + File tempFile = getResourceAsFile("validV1.xml"); xv.setFilename(tempFile.getAbsolutePath()); + xv.validate(); + assertEquals(true, xv.getXMLResult().contains("valid")&&!xv.getXMLResult().contains("invalid")); + tempFile = getResourceAsFile("invalidV1ExtraTags.xml"); + xv.setFilename(tempFile.getAbsolutePath()); + xv.validate(); + assertEquals(true, xv.getXMLResult().contains("invalid")); + + tempFile = getResourceAsFile("invalidV1TooMinimal.xml"); + xv.setFilename(tempFile.getAbsolutePath()); xv.validate(); - assertEquals(true, xv.getXMLResult().contains(" + + + + false + + + urn:ferd:CrossIndustryDocument:invoice:1p0:extended + + + + RE-20171118/506 + RECHNUNG + 380 + + 20171118 + + + + + + + + + Bei Spiel GmbH + + 12345 + Ecke 12 + Stadthausen + DE + + + 22/815/0815/4 + + + DE136695976 + + + + Theodor Est + + 88802 + Bahnstr. 42 + Spielkreis + DE + + + DE999999999 + + + + + + + 20171117 + + + + + RE-20171118/506 + EUR + + 42 + Überweisung + + DE88 2008 0000 0970 3757 00 + + + COBADEFFXXX + Commerzbank + + + + 11.20 + VAT + 160.00 + S + 7.00 + + + 63.84 + VAT + 336.00 + S + 19.00 + + + Zahlbar ohne Abzug bis zum 09.12.2017 + + 20171209 + + + + 496.00 + 0.00 + 0.00 + 496.00 + 75.04 + 571.04 + 571.04 + + + + + 1 + + + + 160.0000 + 1.0000 + + + 160.0000 + 1.0000 + + + + 1.0000 + + + + VAT + S + 7.00 + + + 160.00 + + + + Künstlerische Gestaltung (Stunde): Einer Beispielrechnung + + + + + + 2 + + + + 0.7900 + 1.0000 + + + 0.7900 + 1.0000 + + + + 400.0000 + + + + VAT + S + 19.00 + + + 316.00 + + + + Luftballon: Bunt, ca. 500ml + + + + + + 3 + + + + 0.1000 + 1.0000 + + + 0.1000 + 1.0000 + + + + 200.0000 + + + + VAT + S + 19.00 + + + 20.00 + + + + Heiße Luft pro Liter + + + + +