Skip to content
Permalink
93dbab13a5
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 92 lines (81 sloc) 1.75 KB
#!/bin/bash
BASE_DIR=$(dirname $0)/..
DEP_DIR=$BASE_DIR/dependencies
input_dir="$BASE_DIR/examples/tei"
schema_dir="$BASE_DIR/schema/rnc"
input_pattern='*.xml'
#######################################
# functions
#######################################
function print_help {
echo "validate all XML in INPUT_DIR based on a schemata in RelaxNG Compact syntax found in SCHEMA_DIR"
echo
echo "usage: $0 [OPTIONS] [INPUT_PATTERN]"
echo
echo "OPTIONS:"
echo " -s|--schema-dir SCHEMA_DIR. default: '$schema_dir'"
echo " -i|--input-dir INPUT_DIR. default: '$input_dir'"
echo
echo "ARGUMENTS:"
echo " INPUT_PATTERN. default: '$input_pattern'"
}
#######################################
# parse command line arguments
#######################################
while [[ $# > 0 ]]; do
key="$1"
case $key in
-h | --help)
print_help
exit 0
;;
-i|--input-dir)
shift
input_dir="$1"
shift
;;
-s|--schema-dir)
shift
schema_dir="$1"
shift
;;
-* )
echo "wrong syntax!"
print_help
exit 1
;;
*)
break
;;
esac
done
if [[ $1 != "" ]]; then
input_pattern="$1"
shift
fi
if [[ $# > 0 ]]; then
echo "too many arguments!"
print_help
exit 1
fi
# echo "input_pattern: $input_pattern"
# exit
while read schema_file; do
echo "checking schema '$schema_file'"
while read input_file; do
echo -en " with '$input_file'..."
log="$(mktemp)"
java -jar $DEP_DIR/Stylesheets/lib/lib/jing.jar \
-c \
"$schema_file" \
"$input_file" \
> "$log"
if [[ "$?" = "0" ]]; then
echo -en " ok :-)\n"
else
echo -en " failed!\n"
echo -en " log:\n"
cat "$log" | sed 's/^/ /'
fi
done < <(find "$input_dir" \( -type f -o -type l \) -name "$input_pattern")
done < <(find "$schema_dir" \( -type f -o -type l \) -name '*.rnc')