Blame Automation/centos-art.sh-render/Docbook/docbook_setConversionXhtml.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# docbook_setConversionXhtml.sh -- This function uses DocBook XML as input
Alain Reguera Delgado 8f60cb
# and applies XSL stylesheets to produce a big XHTML files as output.
Alain Reguera Delgado 8f60cb
# The procedure was taken from the documentation of
Alain Reguera Delgado 8f60cb
# `docbook-style-xsl-1.69.1-5.1' package, which says: ---To publish
Alain Reguera Delgado 8f60cb
# HTML from your XML documents, you just need an XSL engine.---.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# Copyright (C) 2009-2013 The CentOS Project
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado 8f60cb
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado 8f60cb
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado 8f60cb
# your option) any later version.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado 8f60cb
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado 8f60cb
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado 8f60cb
# General Public License for more details.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado 8f60cb
# along with this program; if not, write to the Free Software
Alain Reguera Delgado 8f60cb
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
# $Id$
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
function docbook_setConversionXhtml {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    local -a STYLE_TEMPLATE
Alain Reguera Delgado 8f60cb
    local -a STYLE_INSTANCE
Alain Reguera Delgado 8f60cb
    local STYLE_INSTANCE_FINAL=''
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to DocBook source file. This is the
Alain Reguera Delgado 8f60cb
    # repository documentation manual file where DOCTYPE and ENTITY
Alain Reguera Delgado 8f60cb
    # definition lines are set.
Alain Reguera Delgado 8f60cb
    local SOURCE_FILE=${1}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to xhtml target file. This is the final
Alain Reguera Delgado 8f60cb
    # location the xhtml file produced as result of DocBook to xhtml
Alain Reguera Delgado 8f60cb
    # transformation will be stored in.
Alain Reguera Delgado 8f60cb
    local TARGET_FILE=${FILE}-xhtml/$(basename ${FILE}).xhtml
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to xhtml target file directory. This is the
Alain Reguera Delgado 8f60cb
    # location the xhtml target file will be sotred in.
Alain Reguera Delgado 8f60cb
    local TARGET_FILE_DIR=$(dirname ${TARGET_FILE})
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Print action message.
Alain Reguera Delgado 8f60cb
    if [[ -f ${FILE}.xhtml ]];then
Alain Reguera Delgado 8f60cb
        cli_printMessage "${TARGET_FILE}" --as-updating-line
Alain Reguera Delgado 8f60cb
    else
Alain Reguera Delgado 8f60cb
        cli_printMessage "${TARGET_FILE}" --as-creating-line
Alain Reguera Delgado 8f60cb
    fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Prepare XSL final instances used in transformations.
Alain Reguera Delgado 8f60cb
    docbook_setStyles $(cli_getFilesList \
Alain Reguera Delgado 8f60cb
        ${DOCBOOK_XSL} --pattern='^.*/docbook2xhtml-(single|common)\.xsl$')
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Clean up output directory. This is required in order to prevent
Alain Reguera Delgado 8f60cb
    # old files from remaining therein when they are no longer needed.
Alain Reguera Delgado 8f60cb
    if [[ -d ${TARGET_FILE_DIR} ]];then
Alain Reguera Delgado 8f60cb
        rm -r "${TARGET_FILE_DIR}"
Alain Reguera Delgado 8f60cb
    fi 
Alain Reguera Delgado 8f60cb
    mkdir ${TARGET_FILE_DIR}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Transform DocBook XML to XHTML suppressing all stderr output.
Alain Reguera Delgado 8f60cb
    xsltproc --output ${TARGET_FILE} ${STYLE_INSTANCE_FINAL} ${SOURCE_FILE} &> /dev/null
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Create `css' and `images' directories. In order to save disk
Alain Reguera Delgado 8f60cb
    # space, these directories are linked (symbolically) to their
Alain Reguera Delgado 8f60cb
    # respective locations inside the working copy. 
Alain Reguera Delgado 8f60cb
    ln -fs ${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Css ${TARGET_FILE_DIR}/Css
Alain Reguera Delgado 8f60cb
    ln -fs ${TCAR_WORKDIR}/Identity/Images/Webenv ${TARGET_FILE_DIR}/Images
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Remove XSL instance files.
Alain Reguera Delgado 8f60cb
    rm ${STYLE_INSTANCE[*]}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}