From 0379a3ccfff96f318be70cbecdd56f5a0a34ced1 Mon Sep 17 00:00:00 2001 From: lew Date: Mon, 23 Mar 2026 21:11:49 +0000 Subject: [PATCH] ci(xml): xml validation --- data/schema/template.xsd | 63 ++++++++++++++++++++++++++++++++++++++++ package.json | 3 +- scripts/validate-xml.sh | 27 +++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 data/schema/template.xsd create mode 100755 scripts/validate-xml.sh diff --git a/data/schema/template.xsd b/data/schema/template.xsd new file mode 100644 index 0000000..4826112 --- /dev/null +++ b/data/schema/template.xsd @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/package.json b/package.json index 99ec109..d7123e1 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "preview": "vite preview", "prepare": "svelte-kit sync || echo ''", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "validate": "scripts/validate-xml.sh" }, "devDependencies": { "@sveltejs/adapter-auto": "^7.0.0", diff --git a/scripts/validate-xml.sh b/scripts/validate-xml.sh new file mode 100755 index 0000000..86536ff --- /dev/null +++ b/scripts/validate-xml.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +schema_dir="data/schema" +fail=0 + +validate() { + local schema="$1" file="$2" + if xmllint --noout --schema "$schema" "$file" 2>&1; then + : + else + fail=1 + fi +} + +for f in data/species/*.xml; do + validate "$schema_dir/species.xsd" "$f" +done + +validate "$schema_dir/citizenships.xsd" data/citizenships.xml +validate "$schema_dir/languages.xsd" data/languages.xml + +for f in data/templates/*.xml; do + validate "$schema_dir/template.xsd" "$f" +done + +exit $fail