-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
verify-xml.sh
47 lines (44 loc) · 1.29 KB
/
verify-xml.sh
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
#!/bin/bash
#
## Script for verifying an xml-file against the junit.xsd
#
# Arguments:
# schema the xsd to use for verification
# xml the xml-file to verify
#
# Functions (sorted alphabetically):
# main entry-point
#
# Exit-codes:
# 1 xsd-file does not exist
# 2 xml-file does not exist
# 200 no args given for script, help is displayed and exited
# $? exit-code from xmllint is returned unmodified
#------------------------------------------------------------------------------
set -e
#------------------------------------------------------------------------------
help() {
echo "verify script"
echo ""
echo "Arguments:"
echo " schema the xsd to use for verification"
echo " xml the xml-file to verify"
}
#------------------------------------------------------------------------------
main() {
if [[ ! -f "$1" ]]; then
echo "$1 schema does not exist";
exit 1
fi
if [[ ! -f "$2" ]]; then
echo "$2 test-results do not exist"
exit 2
fi
xmllint --noout --schema "$1" "$2"
}
#------------------------------------------------------------------------------
if [[ $# -lt 2 ]]; then
help
exit 200
fi
main $*