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/update_output.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
143 lines (115 sloc)
3.83 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) | |
INTERMEDIATE_DIR="$BASE_DIR/schema/intermediate" | |
# make this script fail on first error: | |
set -e | |
########################################## | |
# stage 0: p5subset.xml: | |
########################################## | |
# just create some schemata for debugging: | |
function stage0 () { | |
output_dir="$INTERMEDIATE_DIR/s0" | |
echo "clean_odd.xsl..." | |
$SCRIPT_DIR/local_stylesheet.sh \ | |
--input-dir "$output_dir/odd_compiled" \ | |
--output-dir "$output_dir/generated/odd_cleaned" \ | |
--suffix '.xml' \ | |
--cache \ | |
clean_odd.xsl | |
echo "statistics.xsl..." | |
$SCRIPT_DIR/local_stylesheet.sh \ | |
--input-dir "$output_dir/generated/odd_cleaned" \ | |
--output-dir "$output_dir/generated/statistics" \ | |
--suffix '.xml' \ | |
--cache \ | |
statistics.xsl | |
echo "htmlstatistics.xsl..." | |
which pandoc &> /dev/null | |
if [[ "$?" != "0" ]]; then | |
echo "WARNING: pandoc not found. No HTML statistics generated." | |
else | |
input_dir="$output_dir/generated/statistics" | |
outdir="$output_dir/generated/statistics_html" | |
mkdir -vp "$outdir" | |
while read file; do | |
output=${file##*/} | |
output=${output%.*}.html | |
cmd="pandoc -o $outdir/$output $file" | |
echo "execute $cmd" | |
eval $cmd | |
done < <(find "$input_dir" -type f) | |
fi | |
} | |
stage0 | |
########################################## | |
echo "##########################################" | |
echo "# stage 1: generate ODD from corpus" | |
echo "##########################################" | |
echo "create ODD from corpus..." | |
$SCRIPT_DIR/example2odd.sh \ | |
--input-dir "$BASE_DIR/schema/resource" \ | |
--output-dir "$INTERMEDIATE_DIR/s1/odd" \ | |
--combinations 'all' \ | |
--suffix '.odd' \ | |
'*.xml' | |
$SCRIPT_DIR/apply_odd.sh \ | |
--input-dir "$INTERMEDIATE_DIR/s0/odd_compiled/p5subset.xml" \ | |
--output-dir "$INTERMEDIATE_DIR/s1" | |
echo "create RELAX-NG Compact..." | |
$SCRIPT_DIR/tei_stylesheet.sh \ | |
--cmd "teitornc" \ | |
--input-dir "$INTERMEDIATE_DIR/s1/odd" \ | |
--output-dir "$INTERMEDIATE_DIR/s1/generated/rnc" \ | |
--suffix '.rnc' \ | |
--option "--localsource='$INTERMEDIATE_DIR/s0/odd_compiled/p5subset.xml'" \ | |
"$@" | |
########################################## | |
echo "##########################################" | |
echo "# stage 2: autogenerate ODD from RELAX-NG schema" | |
echo "##########################################" | |
mkdir -p $INTERMEDIATE_DIR/s2 | |
mkdir -p $INTERMEDIATE_DIR/s2/logs | |
echo "prepare: rnc -> analyis..." | |
$SCRIPT_DIR/rnc_to_analysis.sh \ | |
--output-dir "$INTERMEDIATE_DIR/s2/prepare/rnc_analysis" \ | |
--verbosity 3 \ | |
>$INTERMEDIATE_DIR/s2/logs/rnc_to_analysis.log \ | |
2>&1 | |
echo "prepare: analyis -> odd..." | |
$SCRIPT_DIR/rnc_analysis_to_odd.sh \ | |
--verbosity 3 \ | |
--input-dir "$INTERMEDIATE_DIR/s2/prepare/rnc_analysis" \ | |
--output-dir "$INTERMEDIATE_DIR/s2/odd" \ | |
--modules 'core,tei,header,namesdates,figures,transcr,linking,textstructure' \ | |
>$INTERMEDIATE_DIR/s2/logs/rnc_analysis_to_odd.log \ | |
2>&1 | |
echo "apply odd" | |
$SCRIPT_DIR/apply_odd.sh \ | |
--input-dir "$INTERMEDIATE_DIR/s1/generated/odd_compiled/autogen_all.xml" \ | |
--output-dir "$INTERMEDIATE_DIR/s2" | |
echo "create RELAX-NG Compact..." | |
$SCRIPT_DIR/tei_stylesheet.sh \ | |
--cmd "teitornc" \ | |
--input-dir "$INTERMEDIATE_DIR/s2/odd" \ | |
--output-dir "$INTERMEDIATE_DIR/s2/generated/rnc" \ | |
--suffix '.rnc' \ | |
--option "--localsource='$INTERMEDIATE_DIR/s0/odd_compiled/p5subset.xml'" \ | |
"$@" | |
echo "create schematron (for more complex rules)..." | |
$SCRIPT_DIR/tei_stylesheet.sh \ | |
--input-dir "$INTERMEDIATE_DIR/s2/odd" \ | |
--output-dir "$INTERMEDIATE_DIR/s2/generated/schematron" \ | |
--cmd "teitoschematron" \ | |
--suffix '.xml' \ | |
>$INTERMEDIATE_DIR/s2/logs/teitoschematron.log \ | |
2>&1 | |
echo "schematron -> xslt 2" | |
$SCRIPT_DIR/local_stylesheet.sh \ | |
--input-dir "$INTERMEDIATE_DIR/s2/generated/schematron" \ | |
--output-dir "$INTERMEDIATE_DIR/s2/generated/schematron" \ | |
--suffix '.xsl' \ | |
"schematron/iso_svrl_for_xslt2.xsl" \ | |
>$INTERMEDIATE_DIR/s2/logs/schematron_to_xsl.log \ | |
2>&1 | |
echo "done" |