blob: adb6b80fcd53da7de11ac66d771271784daade67 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/bin/bash
# Find xml2
XML2=`which xml2` || { echo "Could not find command xml2"; exit 1; }
# Find xsltproc
XSLTPROC=`which xsltproc` || { echo "Could not find command xsltproc"; exit 1; }
XSD=osisCore.2.1.1.xsd
# Find a validator, prefer Xerces
VALIDATOR=""
XMLSTARLET=`which xmlstarlet` && { VALIDATOR="XMLSTARLET"; }
XERCESVALIDATOR=/usr/share/doc/libxml-xerces-perl/examples/validator.plDONTUSE
if [ -f $XERCESVALIDATOR ]
then
VALIDATOR="XERCES"
fi
if [ "$VALIDATOR" == "" ]
then
echo "No validator found"
exit 1
fi
FAILED="false"
for TESTTHML in *.thml;
do
TESTOSIS=${TESTTHML%%.thml}.osis
TESTOSISFLAT=${TESTTHML%%.thml}.osis.flat
$XSLTPROC --novalid ../thml2osis.xslt $TESTTHML > $TESTOSIS || exit 1
if [ -f $TESTOSISFLAT ]
then
TMP=`mktemp -p .`
$XML2 < $TESTOSIS > $TMP
diff -u $TESTOSISFLAT $TMP || FAILED="true"
rm "$TMP"
fi
# Validate
if [ $VALIDATOR == "XERCES" ]
then
$XERCESVALIDATOR --full_schema --schema $XSD --file=$TESTOSIS || { echo "$TESTOSIS - invalid OSIS"; FAILED="true"; }
elif [ $VALIDATOR == "XMLSTARLET" ]
then
$XMLSTARLET val --err -s $XSD $TESTOSIS > /dev/null || { echo "$TESTOSIS - invalid OSIS"; FAILED="true"; }
fi
done
if [ $FAILED = "true" ]
then
exit 1
else
exit 0
fi
|