|
|
be62ec |
#!/bin/bash
|
|
|
be62ec |
#
|
|
|
2fa604 |
# docbook_prepareStyles.sh -- This function prepares XSL final
|
|
|
be62ec |
# instances used in transformations based on XSL templates.
|
|
|
be62ec |
#
|
|
|
be62ec |
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
|
|
|
be62ec |
#
|
|
|
be62ec |
# This program is free software; you can redistribute it and/or modify
|
|
|
be62ec |
# it under the terms of the GNU General Public License as published by
|
|
|
be62ec |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
be62ec |
# (at your option) any later version.
|
|
|
be62ec |
#
|
|
|
be62ec |
# This program is distributed in the hope that it will be useful, but
|
|
|
be62ec |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
be62ec |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
be62ec |
# General Public License for more details.
|
|
|
be62ec |
#
|
|
|
be62ec |
# You should have received a copy of the GNU General Public License
|
|
|
be62ec |
# along with this program; if not, write to the Free Software
|
|
|
be62ec |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
be62ec |
#
|
|
|
be62ec |
# ----------------------------------------------------------------------
|
|
|
5ad52a |
# $Id$
|
|
|
be62ec |
# ----------------------------------------------------------------------
|
|
|
be62ec |
|
|
|
2fa604 |
function docbook_prepareStyles {
|
|
|
be62ec |
|
|
|
2fa604 |
local STYLE_TEMPLATE_FILE=''
|
|
|
2fa604 |
local STYLE_TEMPLATE_FILES=$@
|
|
|
2fa604 |
local STYLE_INSTANCE_COMMON=''
|
|
|
be62ec |
local COUNT=0
|
|
|
be62ec |
|
|
|
2fa604 |
for STYLE_TEMPLATE_FILE in $STYLE_TEMPLATE_FILES;do
|
|
|
be62ec |
|
|
|
2fa604 |
STYLE_TEMPLATE[((++${#STYLE_TEMPLATE[*]}))]="${STYLE_TEMPLATE_FILE}"
|
|
|
2fa604 |
STYLE_INSTANCE[((++${#STYLE_INSTANCE[*]}))]="$(cli_getTemporalFile ${STYLE_TEMPLATE_FILE})"
|
|
|
be62ec |
|
|
|
be62ec |
# Keep track of array's real index value. Remember, it starts
|
|
|
be62ec |
# at zero but counting starts at 1 instead. So, substracting 1
|
|
|
be62ec |
# from counting we have the real index value we need to work
|
|
|
be62ec |
# with the information stored in the array.
|
|
|
2fa604 |
COUNT=$(( ${#STYLE_INSTANCE[*]} - 1 ))
|
|
|
be62ec |
|
|
|
be62ec |
# Create XSL instance from XSL template.
|
|
|
2fa604 |
cp ${STYLE_TEMPLATE[$COUNT]} ${STYLE_INSTANCE[$COUNT]}
|
|
|
be62ec |
|
|
|
f8649c |
# Define both final an common XSL instances based on XSL
|
|
|
f8649c |
# template.
|
|
|
2fa604 |
if [[ $STYLE_TEMPLATE_FILE =~ 'docbook2fo\.xsl$' ]];then
|
|
|
2fa604 |
STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[$COUNT]}
|
|
|
2fa604 |
elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2pdf\.dsl$' ]];then
|
|
|
2fa604 |
STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[${COUNT}]}
|
|
|
2fa604 |
elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2xhtml-(chunks|single)\.xsl$' ]];then
|
|
|
2fa604 |
STYLE_INSTANCE_FINAL=${STYLE_INSTANCE[${COUNT}]}
|
|
|
2fa604 |
elif [[ $STYLE_TEMPLATE_FILE =~ 'docbook2xhtml-common\.xsl$' ]];then
|
|
|
2fa604 |
STYLE_INSTANCE_COMMON=${STYLE_INSTANCE[${COUNT}]}
|
|
|
be62ec |
fi
|
|
|
be62ec |
|
|
|
be62ec |
done
|
|
|
be62ec |
|
|
|
f8649c |
# Verify XSL final instance. This is the file used by `xsltproc'
|
|
|
f8649c |
# to produce the specified output. We cannot continue without it.
|
|
|
2fa604 |
cli_checkFiles $STYLE_INSTANCE_FINAL
|
|
|
be62ec |
|
|
|
f8649c |
# Expand common translation markers in XSL common instances. This
|
|
|
f8649c |
# expantion is optional.
|
|
|
2fa604 |
if [[ -f $STYLE_INSTANCE_COMMON ]];then
|
|
|
2fa604 |
cli_replaceTMarkers $STYLE_INSTANCE_COMMON
|
|
|
f8649c |
fi
|
|
|
f8649c |
|
|
|
f8649c |
# Expand specific translation markers in XSL final instance.
|
|
|
2fa604 |
sed -r -i "s!=STYLE_XHTML_COMMON=!${STYLE_INSTANCE_COMMON}!" ${STYLE_INSTANCE_FINAL}
|
|
|
f8649c |
|
|
|
be62ec |
}
|