Allow xsltproc options to be given in input XML test files
[pazpar2-moved-to-github.git] / etc / xsl / test_xsl.sh
1 #!/bin/sh
2 res=0
3 for x in *.xsl; do
4     t=`basename $x .xsl`
5     if test ! -f ${t}1.xml; then
6         continue
7     fi
8     echo "$t"
9     for m in ${t}?.xml; do
10         b=`basename $m .xml`
11         opt=`grep 'xsltproc:' $m|cut -d: -f2|cut -d- -f1|tr '#' '-'`
12         l=$b.log.xml
13         r=$b.res.xml
14         d=$b.dif
15         xsltproc $opt $x $m >$l
16         if test -f $r; then
17             if diff $l $r >$d; then
18                 rm $d
19             else
20                 echo "$b: FAIL; check $d"
21                 res=1
22             fi
23         else
24             echo "$b: making $r for the first time"
25             mv $l $r
26             res=1
27         fi
28     done
29 done
30 exit $res