Add optional XSD validation with xmllint
This commit is contained in:
parent
38d514edbd
commit
1ea09cb4c9
14
Makefile
14
Makefile
|
@ -1,18 +1,29 @@
|
||||||
.PHONY: all validate
|
.PHONY: all validate
|
||||||
all: css/sprites.css $(patsubst xquery/opml/%.xqy,opml/%.opml,$(wildcard xquery/opml/*.xqy) $(wildcard xquery/opml/*/*.xqy))
|
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)"
|
USER_AGENT:="RSRSSS/1.0 (+https://envs.net/~lucidiot/rsrsss/feed.xml)"
|
||||||
export XIDEL_OPTIONS:=--silent --user-agent=$(USER_AGENT) --wait=1 --trace-stack
|
export XIDEL_OPTIONS:=--silent --user-agent=$(USER_AGENT) --wait=1 --trace-stack
|
||||||
|
|
||||||
opml/%.opml: xquery/opml/%.xqy xquery/functions.xqy
|
opml/%.opml: xquery/opml/%.xqy xquery/functions.xqy
|
||||||
mkdir -p -ma=x,u=rwx $(dir $@)
|
mkdir -p -ma=x,u=rwx $(dir $@)
|
||||||
xidel --extract-kind=xquery3 --extract-file="$<" --output-format=xml > $@.new
|
xidel --extract-kind=xquery3 --extract-file="$<" --output-format=xml > $@.new
|
||||||
|
ifneq ($(XMLLINT_PATH),)
|
||||||
|
$(XMLLINT_PATH) --schema xsd/opml.xsd --noout $@.new
|
||||||
|
endif
|
||||||
mv $@.new $@
|
mv $@.new $@
|
||||||
chmod a=r,u=rw $@
|
chmod a=r,u=rw $@
|
||||||
|
|
||||||
opml/feeds.opml: xquery/opml/feeds.xqy feed.xml
|
opml/feeds.opml: xquery/opml/feeds.xqy feed.xml
|
||||||
mkdir -p -ma=x,u=rwx $(dir $@)
|
mkdir -p -ma=x,u=rwx $(dir $@)
|
||||||
xidel feed.xml --extract-kind=xquery3 --extract-file="$<" --output-format=xml > $@.new
|
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 $@
|
mv $@.new $@
|
||||||
chmod a=r,u=rw $@
|
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 $@
|
chmod a=r,u=rw $@
|
||||||
|
|
||||||
validate: xquery/validator.xqy feed.xml
|
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="$<"
|
xidel --extract-kind=xquery3 --extract-file="$<"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user