Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate validation for ZUGFeRD/Factur-X XMLs #143

Open
wurst-hans opened this issue Nov 30, 2024 · 3 comments
Open

How to integrate validation for ZUGFeRD/Factur-X XMLs #143

wurst-hans opened this issue Nov 30, 2024 · 3 comments

Comments

@wurst-hans
Copy link

wurst-hans commented Nov 30, 2024

I am not a professional when it comes to XML. However, I would like to check the XMLs embedded in ZUGFeRD/Factur-X with the KoSIT Validator. Extracting the XML from the PDF is not a problem. Of the ZUGFeRD profiles, only EN16931 (Comfort) and XRechnung work out-of-the-box because the XML specification is already available in the KoSIT validator. However, I would also like to integrate the other profiles.
When I download the ZUGFeRD 2.3.2 definitions, they also contain schema files for the different profiles. But is there an understandable guide for beginners on how to incorporate these schemas into the scenarios.xml? I have already looked at the content of the scenarios.xml for the XRechnung, but I still don't know which of the ZUGFeRD XSD and XSLT I need for this (in particular whether CII needs to be validated separately). Where can I get help?

@SemikolonDEV
Copy link

Here’s a concise step-by-step guide to creating a new ZUGFeRD profile scenario for the KoSIT Validator by following the structure of the XRechnung profile:


1. Understand the XRechnung Scenario

The XRechnung profile in scenarios.xml defines:

  • Namespaces for key elements.
  • Match Rules to identify documents by CustomizationID.
  • Validation Steps for XML Schema and Schematron.
  • Reporting Rules for validation output.

You’ll replicate this logic for ZUGFeRD profiles.


2. Gather Resources

Collect the ZUGFeRD-specific resources:

  • XSD files for the profile (e.g., EN16931 and ZUGFeRD-specific schemas).
  • Schematron (XSLT) for additional business rules.
  • Documentation on CustomizationID values.

3. Define Namespaces

In the scenario, declare namespaces relevant to ZUGFeRD, such as:

  • rsm: Cross-Industry Invoice (CII) namespace.
  • Any additional namespaces needed for validation.

4. Match Documents Using CustomizationID

Use the match element to identify ZUGFeRD documents based on their CustomizationID. Example:

<match>exists(/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext/rsm:GuidelineSpecifiedDocumentContextParameter/rsm:ID[ . = 'urn:factur-x.eu:1p0:extended'])</match>

Replace urn:factur-x.eu:1p0:extended with the CustomizationID for the desired profile.


5. Add XML Schema Validation

Include <validateWithXmlSchema> to ensure the document conforms to the structure defined in the XSDs:

<validateWithXmlSchema>
  <resource>
    <name>XML Schema for ZUGFeRD</name>
    <location>path/to/ZUGFeRD-schema.xsd</location>
  </resource>
</validateWithXmlSchema>

6. Add Schematron Validation

Reference Schematron rules for additional validations:

<validateWithSchematron>
  <resource>
    <name>ZUGFeRD Business Rules</name>
    <location>path/to/ZUGFeRD-rules.xsl</location>
  </resource>
</validateWithSchematron>

7. Configure Reporting

Define how validation results are reported:

<createReport>
  <resource>
    <name>Validation Report</name>
    <location>path/to/report-template.xsl</location>
  </resource>
</createReport>

This approach lets you efficiently adapt the XRechnung scenario structure for ZUGFeRD profiles without extensive rework.

@PeterSawatzki
Copy link

Ich hatte das vor ein paar Tagen mal so ähnlich gemacht und das Ergebnis war durchaus schon zu gebrauchen. Beim Punkt 7 habe ich den bisher mitgelieferten xrechnung-report.xsl verwendet und frage mich aber ob man hier eine spezielle ZUGFeRD Variante des Reports benötigt. Gibt es irgendwo eine Dokumentation zum reporting Teil ?

@landrix
Copy link

landrix commented Dec 4, 2024

ich hab das von Peter mal zusammengefasst und nur auf das ZUGFeRD-Extended Profil beschränkt. Also alles mit XRechnung rausgeworfen. Man kann dann später dem Validator mehrere Configurationen mittels -s -r übergeben (siehe hier #142)

TODO wäre noch ausmisten und weitere ZUGFeRD-Profile und Versionen ergänzen

https://github.com/LandrixSoftware/validator-configuration-zugferd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants