xslt-examples/__relpipe-out-xml_xslt.sh
author František Kučera <franta-hg@frantovo.cz>
Fri, 31 Jul 2020 00:07:04 +0200
branchv_0
changeset 29 509cac0cf411
parent 25 8e2d9b67b51c
permissions -rwxr-xr-x
xslt: relpipe-out-xhtml: customizable strings and CSS This commands now accepts following parameters: --title --css-appendix --description --record-count-prefix --record-count-suffix --relation-name-prefix --relation-name-suffix and allows to customize (e.g. localize) the XHTML output or override CSS rules by providing own. Attribute names, types and record counts have CSS classes and can be styled or (visually) removed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
#!/bin/bash
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
# Relational pipes
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
# Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
#
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
# This program is free software: you can redistribute it and/or modify
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
# it under the terms of the GNU General Public License as published by
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
# the Free Software Foundation, version 3 of the License.
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
#
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
# This program is distributed in the hope that it will be useful,
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
# GNU General Public License for more details.
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
#
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
DIR="$(dirname $0)"
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
BASE="$(basename $0)"
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
XSL="$DIR/$BASE.xsl"
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
29
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    22
xsltParams=();
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    23
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    24
while [[ $# -gt 0 ]]; do
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    25
	argument="$1";
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    26
	case "$argument" in
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    27
		"--title")                       xsltParams+=("--stringparam" "title" "$2"); shift; shift; ;;
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    28
		"--css-appendix")                xsltParams+=("--stringparam" "cssAppendix" "$2"); shift; shift; ;;
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    29
		"--description")                 xsltParams+=("--stringparam" "description" "$2"); shift; shift; ;;
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    30
		"--record-count-prefix")         xsltParams+=("--stringparam" "recordCountPrefix" "$2"); shift; shift; ;;
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    31
		"--record-count-suffix")         xsltParams+=("--stringparam" "recordCountSuffix" "$2"); shift; shift; ;;
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    32
		"--relation-name-prefix")        xsltParams+=("--stringparam" "relationNamePrefix" "$2"); shift; shift; ;;
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    33
		"--relation-name-suffix")        xsltParams+=("--stringparam" "relationNameSuffix" "$2"); shift; shift; ;;
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    34
		*) echo "Unknown option: $argument" >&2; exit 1;
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    35
	esac
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    36
done
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    37
25
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
if [[ -f "$XSL" ]]; then
29
509cac0cf411 xslt: relpipe-out-xhtml: customizable strings and CSS
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    39
	relpipe-out-xml | xsltproc "${xsltParams[@]}" "$XSL" -
25
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
else
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
	echo "unable to find XSLT template: $XSL" 1>&2
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
	exit 1;
8e2d9b67b51c xslt: a basic XSLT template for XHTML output + helper scripts
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
fi