added ksef schema validator
This commit is contained in:
parent
c232841ed3
commit
53b5f69329
6 changed files with 7673 additions and 1 deletions
|
|
@ -172,3 +172,24 @@ The implementation uses `PluginException` for error handling with two error type
|
||||||
- [Upload Invoice](https://ksef-test.mf.gov.pl/docs/v2/index.html#tag/Wysylka-interaktywna/paths/~1api~1v2~1sessions~1online~1%7BreferenceNumber%7D~1invoices/post)
|
- [Upload Invoice](https://ksef-test.mf.gov.pl/docs/v2/index.html#tag/Wysylka-interaktywna/paths/~1api~1v2~1sessions~1online~1%7BreferenceNumber%7D~1invoices/post)
|
||||||
- [Facture Details](https://github.com/CIRFMF/ksef-docs/blob/main/sesja-interaktywna.md#2-wys%C5%82anie-faktury)
|
- [Facture Details](https://github.com/CIRFMF/ksef-docs/blob/main/sesja-interaktywna.md#2-wys%C5%82anie-faktury)
|
||||||
- [XML Invoice Example](https://github.com/CIRFMF/ksef-docs/blob/main/faktury/weryfikacja-faktury.md)
|
- [XML Invoice Example](https://github.com/CIRFMF/ksef-docs/blob/main/faktury/weryfikacja-faktury.md)
|
||||||
|
|
||||||
|
# Validate XML
|
||||||
|
|
||||||
|
To validate XML results use xmllint. To install run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ sudo apt install libxml2-utils
|
||||||
|
```
|
||||||
|
|
||||||
|
With the bash script `src/test/resources/ksef/validate_xml.sh` you can test a xml file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ ./validate_xml.sh example-invoice-01.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
or to manual test a xml run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ xmllint --noout --schema 'schemat-FA(3)-v1-0E.xsd' example-invoice-01.xml
|
||||||
|
example-invoice-01.xml validates
|
||||||
|
```
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -45,7 +45,7 @@
|
||||||
</Podmiot2>
|
</Podmiot2>
|
||||||
<Fa>
|
<Fa>
|
||||||
<KodWaluty>PLN</KodWaluty>
|
<KodWaluty>PLN</KodWaluty>
|
||||||
<P_1>#invoicing_date#</P_1>
|
<P_1>2025-07-17</P_1>
|
||||||
<P_1M>Lidzbark</P_1M>
|
<P_1M>Lidzbark</P_1M>
|
||||||
<P_2>FA/GRQMB-#invoice_number#/05/2025</P_2>
|
<P_2>FA/GRQMB-#invoice_number#/05/2025</P_2>
|
||||||
<P_6>2025-07-11</P_6>
|
<P_6>2025-07-11</P_6>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
39
office-alexander-logistics-app/src/test/resources/ksef/validate_xml.sh
Executable file
39
office-alexander-logistics-app/src/test/resources/ksef/validate_xml.sh
Executable file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ---------------------------------------------
|
||||||
|
# validate_xml.sh
|
||||||
|
# Prüft eine XML-Datei gegen die lokale KSeF XSD
|
||||||
|
# Nutzung: ./validate_xml.sh example-invoice-01.xml
|
||||||
|
# ---------------------------------------------
|
||||||
|
|
||||||
|
# Prüfen, ob Parameter übergeben wurde
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
echo "Usage: $0 <xml-file>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
XML_FILE="$1"
|
||||||
|
XSD_FILE="schemat-FA(3)-v1-0E.xsd"
|
||||||
|
|
||||||
|
# Prüfen, ob die XML-Datei existiert
|
||||||
|
if [ ! -f "$XML_FILE" ]; then
|
||||||
|
echo "Error: XML file '$XML_FILE' not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prüfen, ob die XSD-Datei existiert
|
||||||
|
if [ ! -f "$XSD_FILE" ]; then
|
||||||
|
echo "Error: XSD file '$XSD_FILE' not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Validation durchführen
|
||||||
|
xmllint --noout --schema "$XSD_FILE" "$XML_FILE"
|
||||||
|
|
||||||
|
# Return-Code prüfen
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "✅ XML '$XML_FILE' is valid!"
|
||||||
|
else
|
||||||
|
echo "❌ XML '$XML_FILE' is INVALID!"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
Loading…
Reference in a new issue