#!/bin/sh show_help() { echo "Usage: s1kd2pdf [-c ] [-d ] [-o ] [-s ] []" echo echo "Options:" echo " -c Specify a FOP XML configuration file." echo " -D Create template for -d option." echo " -d Use a custom stylesheet for Docbook-to-FO conversion." echo " -F Output XSL-FO instead of PDF." echo " -I Output Apache FOP intermediary format instead of PDF." echo " -o Output to instead of .pdf." echo " -S Create template for -S option." echo " -s Use a custom stylesheet for S1000D-to-DocBook conversion." echo " Source S1000D module." echo " xsltproc parameters to pass to both stylesheets." echo echo "Example:" echo " s1kd2pdf -o test.pdf test.xml -param show.unclassified 0 -stringparam publication.code 'Test'" } FOP_CONFIG=/etc/fop.xml dir="$(dirname $(dirname "$0"))/share/xml/s1000d/stylesheet/S1000D-XSL-Stylesheets" s2d="$dir/s1000dtodb/s1000dtodb.xsl" d2f="$dir/dbtofo/dbtofo.xsl" fmt=pdf out= cfg= custom_s1000dtodb() { cat <<-EOF EOF } custom_dbtofo() { cat <<-EOF EOF } while getopts c:Dd:FIo:Ss:h? opt do case $opt in c) cfg="$OPTARG" ;; D) custom_dbtofo exit ;; d) d2f="$OPTARG" ;; F) fmt='fo' ;; I) fmt='if' ;; o) out="$OPTARG" ;; S) custom_s1000dtodb exit ;; s) s2d="$OPTARG" ;; h|?) show_help exit 2 ;; esac done shift $((OPTIND - 1)) src="$1" shift if test -z "$out" then out="$(echo "$src"|rev|cut -d. -f2-|rev).$fmt" fi # Use the global FOP config if -c is not specified if test -z "$cfg" -a -e "$FOP_CONFIG" then cfg="$FOP_CONFIG" fi args= if test -n "$cfg" then args="$args -c $cfg" fi case $fmt in pdf) xsltproc --xinclude "$@" "$s2d" "$src" | xsltproc --xinclude -param fop1.extensions 1 "$@" "$d2f" - | fop $args - "$out" ;; fo) xsltproc --xinclude "$@" "$s2d" "$src" | xsltproc --xinclude -param fop1.extensions 1 "$@" "$d2f" - > "$out" ;; if) xsltproc --xinclude "$@" "$s2d" "$src" | xsltproc --xinclude -param fop1.extensions 1 "$@" "$d2f" - | fop $args -fo - -if application/pdf "$out" ;; esac