office-alexander-logistics/office-alexander-logistics-app/src/test/resources/ksef/validate_xml.sh

39 lines
861 B
Bash
Executable file

#!/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