Add optional XSD validation with xmllint

This commit is contained in:
~lucidiot 2023-11-23 00:25:41 +01:00
parent 38d514edbd
commit 1ea09cb4c9
1 changed files with 14 additions and 0 deletions

View File

@ -1,18 +1,29 @@
.PHONY: all validate
all: css/sprites.css $(patsubst xquery/opml/%.xqy,opml/%.opml,$(wildcard xquery/opml/*.xqy) $(wildcard xquery/opml/*/*.xqy))
XMLLINT_PATH:=$(shell command -v xmllint || true)
ifeq ($(XMLLINT_PATH),)
$(info xmllint is not available, all XSD validations will be skipped)
endif
USER_AGENT:="RSRSSS/1.0 (+https://envs.net/~lucidiot/rsrsss/feed.xml)"
export XIDEL_OPTIONS:=--silent --user-agent=$(USER_AGENT) --wait=1 --trace-stack
opml/%.opml: xquery/opml/%.xqy xquery/functions.xqy
mkdir -p -ma=x,u=rwx $(dir $@)
xidel --extract-kind=xquery3 --extract-file="$<" --output-format=xml > $@.new
ifneq ($(XMLLINT_PATH),)
$(XMLLINT_PATH) --schema xsd/opml.xsd --noout $@.new
endif
mv $@.new $@
chmod a=r,u=rw $@
opml/feeds.opml: xquery/opml/feeds.xqy feed.xml
mkdir -p -ma=x,u=rwx $(dir $@)
xidel feed.xml --extract-kind=xquery3 --extract-file="$<" --output-format=xml > $@.new
ifneq ($(XMLLINT_PATH),)
$(XMLLINT_PATH) --schema xsd/opml.xsd --noout $@.new
endif
mv $@.new $@
chmod a=r,u=rw $@
@ -26,4 +37,7 @@ css/sprites.css: xquery/build_sprites_css.xqy img/sprites.png
chmod a=r,u=rw $@
validate: xquery/validator.xqy feed.xml
ifneq ($(XMLLINT_PATH),)
$(XMLLINT_PATH) --schema xsd/rss.xsd --noout feed.xml
endif
xidel --extract-kind=xquery3 --extract-file="$<"