Skip to content

Commit

Permalink
changed zf2 schema file location, added zf1 schema files and check, a…
Browse files Browse the repository at this point in the history
…dded some tests
  • Loading branch information
Jochen Stärk authored and Jochen Stärk committed Jul 8, 2019
1 parent 3d4433a commit 20f6f5b
Show file tree
Hide file tree
Showing 22 changed files with 769 additions and 9 deletions.
7 changes: 7 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
0.8.0
======
2019-07-08

* updated Mustang to mitigate #20 zf1 validation does not always return a <xml> section
* validate not only against *schematron* but also against *schema* files

0.7.0
======
2019-05-31
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.zugferd</groupId>
<artifactId>ZUV</artifactId>
<packaging>jar</packaging>
<version>0.7.1-SNAPSHOT</version>
<version>0.8.0</version>
<repositories>
<repository>
<id>mavencentral</id>
Expand Down Expand Up @@ -71,7 +71,7 @@
<dependency>
<groupId>org.mustangproject.ZUGFeRD</groupId>
<artifactId>mustang</artifactId>
<version>1.7.1</version>
<version>1.7.2</version>
<!-- prototypes of new mustangproject versions can be installed by referring to them and installed to the local repo from a jar file with
mvn install:install-file -Dfile=mustang-1.5.4-SNAPSHOT.jar -DgroupId=org.mustangproject.ZUGFeRD -DartifactId=mustang -Dversion=1.5.4 -Dpackaging=jar -DgeneratePom=true
-->
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ZUV/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/main/java/ZUV/XMLValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
} /*
Expand All @@ -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");
}

Expand Down Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/schema/zf1/ZUGFeRD1p0.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:rsm="urn:ferd:CrossIndustryDocument:invoice:1p0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:12"
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12"
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15"
targetNamespace="urn:ferd:CrossIndustryDocument:invoice:1p0"
elementFormDefault="qualified">
<xs:import namespace="urn:un:unece:uncefact:data:standard:QualifiedDataType:12" schemaLocation="ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_QualifiedDataType_12.xsd"/>
<xs:import namespace="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12" schemaLocation="ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_12.xsd"/>
<xs:import namespace="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15" schemaLocation="ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_15.xsd"/>
<xs:element name="CrossIndustryDocument" type="rsm:CrossIndustryDocumentType"/>
<xs:complexType name="CrossIndustryDocumentType">
<xs:sequence>
<xs:element name="SpecifiedExchangedDocumentContext" type="ram:ExchangedDocumentContextType"/>
<xs:element name="HeaderExchangedDocument" type="ram:ExchangedDocumentType"/>
<xs:element name="SpecifiedSupplyChainTradeTransaction" type="ram:SupplyChainTradeTransactionType"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:12"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15"
targetNamespace="urn:un:unece:uncefact:data:standard:QualifiedDataType:12"
elementFormDefault="qualified"
version="12.0">
<xs:import namespace="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15" schemaLocation="ZUGFeRD1p0_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_15.xsd"/>
<xs:simpleType name="AllowanceChargeReasonCodeContentType">
<xs:restriction base="xs:token"/>
</xs:simpleType>
<xs:complexType name="AllowanceChargeReasonCodeType">
<xs:simpleContent>
<xs:extension base="qdt:AllowanceChargeReasonCodeContentType"/>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="CountryIDContentType">
<xs:restriction base="xs:token"/>
</xs:simpleType>
<xs:complexType name="CountryIDType">
<xs:simpleContent>
<xs:extension base="qdt:CountryIDContentType"/>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="DateMandatoryDateTimeType">
<xs:union memberTypes="xs:dateTime xs:date"/>
</xs:simpleType>
<xs:simpleType name="DeliveryTermsCodeContentType">
<xs:restriction base="xs:token"/>
</xs:simpleType>
<xs:complexType name="DeliveryTermsCodeType">
<xs:simpleContent>
<xs:extension base="qdt:DeliveryTermsCodeContentType"/>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="DocumentCodeContentType">
<xs:restriction base="xs:token"/>
</xs:simpleType>
<xs:complexType name="DocumentCodeType">
<xs:simpleContent>
<xs:extension base="qdt:DocumentCodeContentType"/>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="PaymentMeansCodeContentType">
<xs:restriction base="xs:token"/>
</xs:simpleType>
<xs:complexType name="PaymentMeansCodeType">
<xs:simpleContent>
<xs:extension base="qdt:PaymentMeansCodeContentType"/>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="ReferenceCodeContentType">
<xs:restriction base="xs:token"/>
</xs:simpleType>
<xs:complexType name="ReferenceCodeType">
<xs:simpleContent>
<xs:extension base="qdt:ReferenceCodeContentType"/>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="TaxCategoryCodeContentType">
<xs:restriction base="xs:token"/>
</xs:simpleType>
<xs:complexType name="TaxCategoryCodeType">
<xs:simpleContent>
<xs:extension base="qdt:TaxCategoryCodeContentType"/>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="TaxTypeCodeContentType">
<xs:restriction base="xs:token"/>
</xs:simpleType>
<xs:complexType name="TaxTypeCodeType">
<xs:simpleContent>
<xs:extension base="qdt:TaxTypeCodeContentType"/>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
Loading

0 comments on commit 20f6f5b

Please sign in to comment.