|
|
be62ec |
#!/bin/bash
|
|
|
be62ec |
#
|
|
|
be62ec |
# docbook_prepareXsl4Using.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 |
# ----------------------------------------------------------------------
|
|
|
be62ec |
# $Id: docbook_convertToPdf.sh 3335 2011-06-10 03:52:23Z al $
|
|
|
be62ec |
# ----------------------------------------------------------------------
|
|
|
be62ec |
|
|
|
be62ec |
function docbook_prepareXsl4Using {
|
|
|
be62ec |
|
|
|
be62ec |
local XSL_TEMPLATE_FILE=''
|
|
|
be62ec |
local XSL_TEMPLATE_FILES=$@
|
|
|
be62ec |
local COUNT=0
|
|
|
be62ec |
|
|
|
be62ec |
for XSL_TEMPLATE_FILE in $XSL_TEMPLATE_FILES;do
|
|
|
be62ec |
|
|
|
be62ec |
XSL_TEMPLATE[((++${#XSL_TEMPLATE[*]}))]="${XSL_TEMPLATE_FILE}"
|
|
|
be62ec |
XSL_INSTANCE[((++${#XSL_INSTANCE[*]}))]="$(cli_getTemporalFile ${XSL_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.
|
|
|
be62ec |
COUNT=$(( ${#XSL_INSTANCE[*]} - 1 ))
|
|
|
be62ec |
|
|
|
be62ec |
# Create XSL instance from XSL template.
|
|
|
be62ec |
cp ${XSL_TEMPLATE[$COUNT]} ${XSL_INSTANCE[$COUNT]}
|
|
|
be62ec |
|
|
|
be62ec |
# Define the XSL final instance and expand translation markers
|
|
|
be62ec |
# inside it based on template files. Notice that some of the
|
|
|
be62ec |
# XSL template files need expantion of translation markers
|
|
|
be62ec |
# while others don't. Default expantion of translation markers
|
|
|
be62ec |
# is applied when no specific expantion is conditioned here.
|
|
|
be62ec |
if [[ $XSL_TEMPLATE_FILE =~ 'docbook2fo\.xsl$' ]];then
|
|
|
be62ec |
XSL_INSTANCE_FINAL=${XSL_INSTANCE[$COUNT]}
|
|
|
be62ec |
elif [[ $XSL_TEMPLATE_FILE =~ 'docbook2xhtml-(chunks|single)\.xsl$' ]];then
|
|
|
be62ec |
XSL_INSTANCE_FINAL=${XSL_INSTANCE[${COUNT}]}
|
|
|
be62ec |
sed -i -r "s!=XSL_XHTML_COMMON=!${XSL_INSTANCE_FINAL}!" ${XSL_INSTANCE_FINAL}
|
|
|
be62ec |
else
|
|
|
be62ec |
cli_replaceTMarkers ${XSL_INSTANCE[${COUNT}]}
|
|
|
be62ec |
fi
|
|
|
be62ec |
|
|
|
be62ec |
done
|
|
|
be62ec |
|
|
|
be62ec |
# Verify Xsl final instance before using it. We cannot continue
|
|
|
be62ec |
# without it.
|
|
|
be62ec |
cli_checkFiles $XSL_INSTANCE_FINAL
|
|
|
be62ec |
|
|
|
be62ec |
}
|