Be able to validate XR 2.0 and 1.2
This commit is contained in:
@@ -84,6 +84,7 @@ public class XMLValidator extends Validator {
|
||||
public void disableNotices() {
|
||||
disableNotices = true;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param xmlString
|
||||
@@ -302,7 +303,14 @@ public class XMLValidator extends Validator {
|
||||
|
||||
public void validateXR(String xml, ESeverity errorImpact) throws IrrecoverableValidationError {
|
||||
|
||||
validateSchematron(xml, "/xslt/XR/XRechnung-CII-validation.xslt",27, errorImpact);
|
||||
//Guideline ID=urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_1.2 or
|
||||
if (xml.contains(":xrechnung_1.")) {
|
||||
// urn:cen.eu:en16931:2017#compliant#urn:xoev-dede:kosit:standard:xrechnung_2.0#conformant#urn:xoev-de:kosit:extension:xrechnung_2.0
|
||||
validateSchematron(xml, "/xslt/XR_12/XRechnung-CII-validation.xslt", 27, errorImpact);
|
||||
} else {
|
||||
// urn:cen.eu:en16931:2017#compliant#urn:xoev-dede:kosit:standard:xrechnung_2.0#conformant#urn:xoev-de:kosit:extension:xrechnung_2.0
|
||||
validateSchematron(xml, "/xslt/XR_20/XRechnung-CII-validation.xslt", 27, errorImpact);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<pattern xmlns="http://purl.oclc.org/dsdl/schematron" is-a="model"
|
||||
id="CII-model">
|
||||
<param name="BR-DE-01"
|
||||
value="rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans" />
|
||||
<param name="BR-DE-02" value="ram:DefinedTradeContact" />
|
||||
<param name="BR-DE-03" value="ram:CityName[boolean(normalize-space(.))]" />
|
||||
<param name="BR-DE-04" value="ram:PostcodeCode[boolean(normalize-space(.))]" />
|
||||
<param name="BR-DE-05"
|
||||
value="(ram:PersonName,ram:DepartmentName)[boolean(normalize-space(.))]" />
|
||||
<param name="BR-DE-06"
|
||||
value="ram:TelephoneUniversalCommunication/ram:CompleteNumber[boolean(normalize-space(.))]" />
|
||||
<param name="BR-DE-07"
|
||||
value="ram:EmailURIUniversalCommunication/ram:URIID[boolean(normalize-space(.))]" />
|
||||
<param name="BR-DE-08" value="ram:CityName[boolean(normalize-space(.))]" />
|
||||
<param name="BR-DE-09" value="ram:PostcodeCode[boolean(normalize-space(.))]" />
|
||||
<param name="BR-DE-10" value="ram:CityName[boolean(normalize-space(.))]" />
|
||||
<param name="BR-DE-11" value="ram:PostcodeCode[boolean(normalize-space(.))]" />
|
||||
<!-- Für BG-19 wird jedes Informationselement der Gruppe einzeln aufgeführt, der Pfad zu BG-19 (DIRECT DEBIT) zu unspezifisch ist und
|
||||
sich mit den Pfaden zu BG-17 und BG-18 überschneidet. -->
|
||||
<param name="BR-DE-13"
|
||||
value="count((rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans/ram:PayeePartyCreditorFinancialAccount)[1]) + count(rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans/ram:ApplicableTradeSettlementFinancialCard) + count((rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradePaymentTerms/ram:DirectDebitMandateID, rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:CreditorReferenceID, rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans/ram:PayerPartyDebtorFinancialAccount/ram:IBANID)[1]) = 1" />
|
||||
<param name="BR-DE-14"
|
||||
value="ram:RateApplicablePercent[boolean(normalize-space(.))]" />
|
||||
<param name="BR-DE-15"
|
||||
value="rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:BuyerReference[boolean(normalize-space(.))]" />
|
||||
<param name="BR-DE-16"
|
||||
value="(rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/ram:SpecifiedTaxRegistration/ram:ID[@schemeID='VA' or @schemeID='VAT' or @schemeID='FC'][boolean(normalize-space(.))], rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty)" />
|
||||
<param name="BR-DE-17"
|
||||
value="rsm:ExchangedDocument/ram:TypeCode = ('326', '380', '384', '389', '381', '875', '876', '877')" />
|
||||
<param name="BR-DE-18"
|
||||
value="every $line in rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradePaymentTerms/ram:Description/tokenize(.,'(\r\n|\r|\n)') satisfies if(count(tokenize($line,'#')) > 1) then tokenize($line,'#')[1]='' and (tokenize($line,'#')[2]='SKONTO' or tokenize($line,'#')[2]='VERZUG') and string-length(replace(tokenize($line,'#')[3],'TAGE=[0-9]+',''))=0 and string-length(replace(tokenize($line,'#')[4],'PROZENT=[0-9]+\.[0-9]{2}',''))=0 and (tokenize($line,'#')[5]='' and empty(tokenize($line,'#')[6]) or string-length(replace(tokenize($line,'#')[5],'BASISBETRAG=[0-9]+\.[0-9]{2}',''))=0 and tokenize($line,'#')[6]='' and empty(tokenize($line,'#')[7])) else true()" />
|
||||
<param name="BR-DE-19"
|
||||
value=" not(ram:TypeCode = '58') or matches(ram:PayeePartyCreditorFinancialAccount/ram:IBANID, '^[A-Z]{2}[0-9]{2}[a-zA-Z0-9]{0,30}$') and xs:integer( replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace( upper-case(concat(substring(ram:PayeePartyCreditorFinancialAccount/ram:IBANID,5),substring(ram:PayeePartyCreditorFinancialAccount/ram:IBANID,1,4))) ,'A','10'),'B','11'),'C','12'),'D','13'),'E','14'),'F','15'),'G','16'),'H','17'),'I','18'),'J','19'),'K','20'),'L','21'),'M','22') ,'N','23'),'O','24'),'P','25'),'Q','26'),'R','27'),'S','28'),'T','29'),'U','30'),'V','31'),'W','32'),'X','33'),'Y','34'),'Z','35') ) mod 97 = 1 " />
|
||||
<param name="BR-DE-20"
|
||||
value=" not(ram:TypeCode = '59') or matches(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '^[A-Z]{2}[0-9]{2}[a-zA-Z0-9]{0,30}$') and xs:integer( replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace( upper-case(concat(substring(ram:PayerPartyDebtorFinancialAccount/ram:IBANID,5),substring(ram:PayerPartyDebtorFinancialAccount/ram:IBANID,1,4))) ,'A','10'),'B','11'),'C','12'),'D','13'),'E','14'),'F','15'),'G','16'),'H','17'),'I','18'),'J','19'),'K','20'),'L','21'),'M','22') ,'N','23'),'O','24'),'P','25'),'Q','26'),'R','27'),'S','28'),'T','29'),'U','30'),'V','31'),'W','32'),'X','33'),'Y','34'),'Z','35') ) mod 97 = 1" />
|
||||
<param name="BR-DE-21"
|
||||
value="ram:GuidelineSpecifiedDocumentContextParameter/ram:ID = 'urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_1.2'" />
|
||||
|
||||
<param name="INVOICE" value="//rsm:CrossIndustryInvoice" />
|
||||
<param name="BG-2_PROCESS_CONTROL"
|
||||
value="/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext" />
|
||||
<param name="BG-4_SELLER"
|
||||
value="//rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty" />
|
||||
<param name="BG-5_SELLER_POSTAL_ADDRESS"
|
||||
value="//rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/ram:PostalTradeAddress" />
|
||||
<param name="BG-6_SELLER_CONTACT"
|
||||
value="//rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/ram:DefinedTradeContact" />
|
||||
|
||||
<param name="BG-8_BUYER_POSTAL_ADDRESS"
|
||||
value="//rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty/ram:PostalTradeAddress" />
|
||||
|
||||
<param name="BG-15_DELIVER_TO_ADDRESS"
|
||||
value="//rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeDelivery/ram:ShipToTradeParty/ram:PostalTradeAddress" />
|
||||
|
||||
<param name="BG-16_PAYMENT_INSTRUCTIONS"
|
||||
value="//rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans" />
|
||||
|
||||
<param name="BG-23_VAT_BREAKDOWN"
|
||||
value="//rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:ApplicableTradeTax" />
|
||||
|
||||
</pattern>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<schema xmlns="http://purl.oclc.org/dsdl/schematron"
|
||||
xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
|
||||
xmlns:ccts="urn:un:unece:uncefact:documentation:standard:CoreComponentsTechnicalSpecification:2"
|
||||
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"
|
||||
xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100"
|
||||
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
|
||||
schemaVersion="2.0.0" queryBinding="xslt2">
|
||||
<title>Schematron Version 1.3.0 - XRechnung
|
||||
1.2.2 compatible - CII</title>
|
||||
<ns prefix="rsm"
|
||||
uri="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" />
|
||||
<ns prefix="ccts"
|
||||
uri="urn:un:unece:uncefact:documentation:standard:CoreComponentsTechnicalSpecification:2" />
|
||||
<ns prefix="udt"
|
||||
uri="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" />
|
||||
<ns prefix="qdt"
|
||||
uri="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" />
|
||||
<ns prefix="ram"
|
||||
uri="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" />
|
||||
|
||||
<phase id="XRechnung_model">
|
||||
<active pattern="CII-model" />
|
||||
</phase>
|
||||
|
||||
<!-- Abstract CEN BII patterns -->
|
||||
<!-- ========================= -->
|
||||
<!-- in the original these includes are mistakenly called .sch but that has to be changed manually
|
||||
since they are no complete schematrons which otherwise conflicts with ph-schematron -->
|
||||
<include href="abstract/XRechnung-model.part" />
|
||||
|
||||
<!-- Data Binding parameters -->
|
||||
<!-- ======================= -->
|
||||
<include href="CII/XRechnung-CII-model.part" />
|
||||
|
||||
|
||||
</schema>
|
||||
@@ -0,0 +1,59 @@
|
||||
<pattern xmlns="http://purl.oclc.org/dsdl/schematron" abstract="true" id="model">
|
||||
<rule context="$INVOICE">
|
||||
<assert test="$BR-DE-01" flag="fatal" id="BR-DE-1"
|
||||
>[BR-DE-1] Eine Rechnung (INVOICE) muss Angaben zu "PAYMENT INSTRUCTIONS" (BG-16) enthalten.</assert>
|
||||
<assert test="$BR-DE-13" flag="fatal" id="BR-DE-13"
|
||||
>[BR-DE-13] In der Rechnung müssen Angaben zu genau einer der drei Gruppen "CREDIT TRANSFER" (BG-17), "PAYMENT CARD INFORMATION" (BG-18) oder "DIRECT DEBIT" (BG-19) übermittelt werden.</assert>
|
||||
<assert test="$BR-DE-15" flag="fatal" id="BR-DE-15"
|
||||
>[BR-DE-15] Das Element "Buyer reference" (BT-10) muss übermittelt werden.</assert>
|
||||
<assert test="$BR-DE-16" flag="fatal" id="BR-DE-16"
|
||||
>[BR-DE-16] In der Rechnung muss mindestens eines der Elemente "Seller VAT identifier" (BT-31), "Seller tax registration identifier" (BT-32) oder "SELLER TAX REPRESENTATIVE PARTY" (BG-11) übermittelt werden.</assert>
|
||||
<assert test="$BR-DE-17" flag="warning" id="BR-DE-17" >[BR-DE-17] Mit dem Element "Invoice type code" (BT-3) sollen ausschließlich folgende Codes aus der Codeliste UNTDID 1001 übermittelt werden: 326 (Partial invoice), 380 (Commercial invoice), 384 (Corrected invoice), 389 (Self-billed invoice) und 381 (Credit note),875 (Partial construction invoice), 876 (Partial final construction invoice), 877 (Final construction invoice).</assert>
|
||||
<assert test="$BR-DE-18" flag="fatal" id="BR-DE-18"
|
||||
>[BR-DE-18] Die Informationen zur Gewährung von Skonto oder zur Berechnung von Verzugszinsen müssen wie folgt im Element "Payment terms" (BT-20) übermittelt werden: Anzugeben ist im ersten Segment "SKONTO" oder "VERZUG", im zweiten "TAGE=n", im dritten "PROZENT=n". Prozentzahlen sind ohne Vorzeichen sowie mit Punkt getrennt von zwei Nachkommastellen anzugeben. Liegt dem zu berechnenden Betrag nicht BT-115, "fälliger Betrag" zugrunde, sondern nur ein Teil des fälligen Betrags der Rechnung, ist der Grundwert zur Berechnung von Skonto oder Verzugszins als viertes Segment "BASISBETRAG=n" gemäß dem semantischen Datentypen Amount anzugeben. Jeder Eintrag beginnt mit einer #, die Segmente sind mit einer # getrennt und eine Zeile schließt mit einer # ab. Am Ende einer vollständigen Skonto oder Verzugsangabe muss ein XML-konformer Zeilenumbruch folgen. Alle Angaben zur Gewährung von Skonto oder zur Berechnung von Verzugszinsen müssen in Großbuchstaben gemacht werden. Zusätzliches Whitespace (Leerzeichen, Tabulatoren oder Zeilenumbrüche) ist nicht zulässig. Andere Zeichen oder Texte als in den oberen Vorgaben genannt sind nicht zulässig.</assert>
|
||||
</rule>
|
||||
<rule context="$BG-2_PROCESS_CONTROL">
|
||||
<assert test="$BR-DE-21" flag="warning" id="BR-DE-21"
|
||||
>[BR-DE-21] Das Element "Specification identifier" (BT-24) soll syntaktisch der Kennung des Standards XRechnung entsprechen.</assert>
|
||||
</rule>
|
||||
<rule context="$BG-4_SELLER">
|
||||
<assert test="$BR-DE-02" flag="fatal" id="BR-DE-2"
|
||||
>[BR-DE-2] Die Gruppe "SELLER CONTACT" (BG-6) muss übermittelt werden.</assert>
|
||||
</rule>
|
||||
<rule context="$BG-5_SELLER_POSTAL_ADDRESS">
|
||||
<assert test="$BR-DE-03" flag="fatal" id="BR-DE-3"
|
||||
>[BR-DE-3] Das Element "Seller city" (BT-37) muss übermittelt werden.</assert>
|
||||
<assert test="$BR-DE-04" flag="fatal" id="BR-DE-4"
|
||||
>[BR-DE-4] Das Element "Seller post code" (BT-38) muss übermittelt werden.</assert>
|
||||
</rule>
|
||||
<rule context="$BG-6_SELLER_CONTACT">
|
||||
<assert test="$BR-DE-05" flag="fatal" id="BR-DE-5"
|
||||
>[BR-DE-5] Das Element "Seller contact point" (BT-41) muss übermittelt werden.</assert>
|
||||
<assert test="$BR-DE-06" flag="fatal" id="BR-DE-6"
|
||||
>[BR-DE-6] Das Element "Seller contact telephone number" (BT-42) muss übermittelt werden.</assert>
|
||||
<assert test="$BR-DE-07" flag="fatal" id="BR-DE-7"
|
||||
>[BR-DE-7] Das Element "Seller contact email address" (BT-43) muss übermittelt werden.</assert>
|
||||
</rule>
|
||||
<rule context="$BG-8_BUYER_POSTAL_ADDRESS">
|
||||
<assert test="$BR-DE-08" flag="fatal" id="BR-DE-8"
|
||||
>[BR-DE-8] Das Element "Buyer city" (BT-52) muss übermittelt werden.</assert>
|
||||
<assert test="$BR-DE-09" flag="fatal" id="BR-DE-9"
|
||||
>[BR-DE-9] Das Element "Buyer post code" (BT-53) muss übermittelt werden.</assert>
|
||||
</rule>
|
||||
<rule context="$BG-15_DELIVER_TO_ADDRESS">
|
||||
<assert test="$BR-DE-10" flag="fatal" id="BR-DE-10"
|
||||
>[BR-DE-10] Das Element "Deliver to city" (BT-77) muss übermittelt werden, wenn die Gruppe "DELIVER TO ADDRESS" (BG-15) übermittelt wird.</assert>
|
||||
<assert test="$BR-DE-11" flag="fatal" id="BR-DE-11"
|
||||
>[BR-DE-11] Das Element "Deliver to post code" (BT-78) muss übermittelt werden, wenn die Gruppe "DELIVER TO ADDRESS" (BG-15) übermittelt wird.</assert>
|
||||
</rule>
|
||||
<rule context="$BG-16_PAYMENT_INSTRUCTIONS">
|
||||
<assert test="$BR-DE-19" flag="warning" id="BR-DE-19"
|
||||
>[BR-DE-19] "Payment account identifier" (BT-84) soll eine korrekte IBAN enthalten, wenn in "Payment means type code" (BT-81) mit dem Code 58 SEPA als Zahlungsmittel gefordert wird.</assert>
|
||||
<assert test="$BR-DE-20" flag="warning" id="BR-DE-20"
|
||||
>[BR-DE-20] "Debited account identifier" (BT-91) soll eine korrekte IBAN enthalten, wenn in "Payment means type code" (BT-81) mit dem Code 59 SEPA als Zahlungsmittel gefordert wird.</assert>
|
||||
</rule>
|
||||
<rule context="$BG-23_VAT_BREAKDOWN">
|
||||
<assert test="$BR-DE-14" flag="fatal" id="BR-DE-14"
|
||||
>[BR-DE-14] Das Element "VAT category rate" (BT-119) muss übermittelt werden.</assert>
|
||||
</rule>
|
||||
</pattern>
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<xsl:stylesheet xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:ccts="urn:un:unece:uncefact:documentation:standard:CoreComponentsTechnicalSpecification:2" xmlns:iso="http://purl.oclc.org/dsdl/schematron" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:saxon="http://saxon.sf.net/" xmlns:schold="http://www.ascc.net/xml/schematron" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
|
||||
<!--Implementers: please note that overriding process-prolog or process-root is
|
||||
the preferred method for meta-stylesheets to use where possible. -->
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -191,4 +191,25 @@ public class XMLValidatorTest extends ResourceCase {
|
||||
|
||||
}
|
||||
|
||||
public void testXRValidation() {
|
||||
ValidationContext ctx = new ValidationContext(null);
|
||||
XMLValidator xv = new XMLValidator(ctx);
|
||||
XPathEngine xpath = new JAXPXPathEngine();
|
||||
|
||||
File tempFile = getResourceAsFile("validXRv2.xml");
|
||||
try {
|
||||
xv.setFilename(tempFile.getAbsolutePath());
|
||||
xv.validate();
|
||||
|
||||
Source source = Input.fromString("<validation>" + xv.getXMLResult() + "</validation>").build();
|
||||
String content = xpath.evaluate("/validation/summary/@status", source);
|
||||
assertEquals("valid", content);
|
||||
|
||||
|
||||
} catch (IrrecoverableValidationError e) {
|
||||
// ignore, will be in XML output anyway
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user