Permalink
Cannot retrieve contributors at this time
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?
eoa-publication-model/scripts/rnc_to_analysis.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
132 lines (110 sloc)
2.79 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BASE_DIR="$(dirname $0)/.." | |
SCRIPT_DIR="$(dirname $0)" | |
DEP_DIR="$BASE_DIR/dependencies" | |
TRANG="java -jar $DEP_DIR/Stylesheets/lib/trang.jar" | |
####################################### | |
# variables | |
####################################### | |
input="$BASE_DIR/schema/resource/eoa-tei-strict.rnc" | |
output_dir="$BASE_DIR/schema/legacy/generated/analysis" | |
verbosity="2" | |
debug_modules=() | |
####################################### | |
# functions | |
####################################### | |
function print_help { | |
echo "analyze a schema in relaxng compact syntax" | |
echo | |
echo "usage: $0 [OPTIONS]" | |
echo | |
echo "OPTIONS:" | |
echo " -h | --help: print this help" | |
echo " -i|--input INPUT. default: '$input'" | |
echo " -o|--output-dir OUTPUT_DIR. default: '$output_dir'" | |
echo " -v|--verbosity (0: only errors, 1: warnings, 2: info, 3: debug). default: $verbosity" | |
echo " -d|--debug-module VAL (multiple options accumulate): send debug messages for the specific module" | |
} | |
####################################### | |
# parse command line arguments | |
####################################### | |
while [[ $# > 0 ]]; do | |
key="$1" | |
case $key in | |
-h | --help) | |
print_help | |
exit 0 | |
;; | |
-i | --input) | |
shift | |
input="$1" | |
shift | |
;; | |
-o | --output-dir) | |
shift | |
output_dir="$1" | |
shift | |
;; | |
-v | --verbosity) | |
shift | |
verbosity="$1" | |
shift | |
;; | |
-d | --debug-module) | |
shift | |
debug_modules+=("$1") | |
shift | |
;; | |
-* ) | |
echo "wrong syntax!" | |
print_help | |
exit 1 | |
;; | |
*) | |
break | |
;; | |
esac | |
done | |
set -e | |
mkdir -p "$output_dir" | |
input_basename=$(basename $input) | |
rng_file=$output_dir/0_input.rng | |
echo "rnc -> rng: '$input' -> '$rng_file'" | |
$SCRIPT_DIR/utils/run_with_cache.sh \ | |
--output-file "$rng_file" \ | |
--input-file "$input" \ | |
--cache 1 \ | |
--print-cmd \ | |
-- \ | |
"$TRANG" '$INPUT' '$OUTPUT' \ | |
|| exit 1 | |
rng_simplified=${rng_file%.*}_simplified7-22.rng | |
rng_simplified_arg=${rng_file%.*}_simplified | |
echo "rng -> simplified rng: '$rng_file' -> '$rng_simplified'" | |
$SCRIPT_DIR/utils/run_with_cache.sh \ | |
--output-file "$rng_simplified" \ | |
--input-file "$rng_file" \ | |
--cache 1 \ | |
--print-cmd \ | |
-- \ | |
xsltproc \ | |
--stringparam out-name "$rng_simplified_arg" \ | |
stylesheets/rnc_simplification.xsl \ | |
'$INPUT' \ | |
|| exit 1 | |
echo "simplified rng -> analysis: '$rng_simplified' -> '$output_dir/{2_flattened.xml,3_serialized.txt}'" | |
debug_modules_options="debug_modules=${debug_modules[@]}" | |
# echo "debug_modules_options: $debug_modules_options" | |
$SCRIPT_DIR/utils/run_with_cache.sh \ | |
--output-file "$output_dir/5_structured_advanced.xml" \ | |
--input-file "$rng_simplified" \ | |
--cache 1 \ | |
--print-cmd \ | |
-- \ | |
$SCRIPT_DIR/saxon.sh \ | |
"$BASE_DIR/stylesheets/rng_to_odd/rng_to_analysis.xsl" '-s:$INPUT' '-o:$OUTPUT' \ | |
"output=." \ | |
"verbosity=$verbosity" \ | |
"$debug_modules_options" \ | |
|| exit 1 | |
echo "SOURCE: $input" > $output_dir/info.cfg |