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