Skip to content

Commit

Permalink
option whether to overwrite existing output when running local styles…
Browse files Browse the repository at this point in the history
…heets
  • Loading branch information
EsGeh authored and EsGeh committed May 9, 2019
1 parent 06d58f5 commit 2e508d7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 17 additions & 4 deletions scripts/local_stylesheet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ STYLESHEET=
STYLESHEET_DIR="$BASE_DIR/stylesheets"
NAME_PATTERN='*'
SUFFIX='.xml'
CACHE=
SAXON_ARGS=

OUTPUT_DIR=

Expand All @@ -33,6 +35,8 @@ function print_help {
echo " -i|--input-dir INPUT_DIR (multiple options add multiple directories). default: '$INPUT_DIR_DEFAULT'"
echo " -o|--output-dir OUTPUT_DIR. default: '$OUTPUT_DIR_DEFAULT/STYLESHEET'"
echo " -x | --suffix SUFFIX: output files suffix. default: '$SUFFIX'"
echo " -c | --cache: only write output if not yet existing"
echo " -o | --options OPTS append these options for saxon"
echo
echo "ARGUMENTS:"
echo " STYLESHEET: a stylesheet in $STYLESHEET_DIR"
Expand Down Expand Up @@ -70,6 +74,15 @@ while [[ $# > 0 ]]; do
SUFFIX="$1"
shift
;;
-o | --options)
shift
SAXON_ARGS="$SAXON_ARGS $1"
shift
;;
-c | --cache)
shift
CACHE=1
;;
-* )
echo "wrong syntax!"
print_help
Expand Down Expand Up @@ -118,13 +131,13 @@ java -jar "$TEI_DIR/Stylesheets/lib/saxon9he.jar"
"$BASE_DIR/stylesheets/$STYLESHEET"
-s:"$file"
-o:"$OUTPUT_DIR/$output"
$SAXON_ARGS
EOF
# cmd="xsltproc -o \"$OUTPUT_DIR/$output\" \"$BASE_DIR/stylesheets/$STYLESHEET\" \"$file\""
if [[ ! -e $OUTPUT_DIR/$output ]]; then
if [[ $CACHE ]] && [[ -e $OUTPUT_DIR/$output ]]; then
echo "'$OUTPUT_DIR/$output' already exists, skipping..."
else
echo "execute $cmd"
eval $cmd
else
echo "'$OUTPUT_DIR/$output' already exists, skipping..."
fi
done < <(
find "${INPUT_DIRS[@]}" \
Expand Down
2 changes: 2 additions & 0 deletions scripts/updateOutput.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ function stage0 () {
--input-dir "$output_dir/generated/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..."
Expand Down

0 comments on commit 2e508d7

Please sign in to comment.