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

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# docbook_setConversionXhtmlChunks.sh -- This function uses DocBook XML as
Alain Reguera Delgado 8f60cb
# input and applies XSL stylesheets to produce a directory with many
Alain Reguera Delgado 8f60cb
# XHTML files as output.  The procedure was taken from the
Alain Reguera Delgado 8f60cb
# documentation of `docbook-style-xsl-1.69.1-5.1' package, which says:
Alain Reguera Delgado 8f60cb
# ---To publish HTML from your XML documents, you just need an XSLT
Alain Reguera Delgado 8f60cb
# 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_setConversionXhtmlChunks {
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 PDF
Alain Reguera Delgado 8f60cb
    # transformation will be stored in.
Alain Reguera Delgado 8f60cb
    local TARGET_FILE="${FILE}-xhtml-chunks/"
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} ]];then
Alain Reguera Delgado 8f60cb
        rm -r "${TARGET_FILE}"
Alain Reguera Delgado 8f60cb
    fi 
Alain Reguera Delgado 8f60cb
    mkdir ${TARGET_FILE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Print action message.
Alain Reguera Delgado 8f60cb
    cli_printMessage "${TARGET_FILE}" --as-creating-line
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-(chunks|common)\.xsl$')
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. Be sure to remove
Alain Reguera Delgado 8f60cb
    # previous links first to prevent a recursive creation of links.
Alain Reguera Delgado 8f60cb
    ln -sf ${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Css ${TARGET_FILE}/Css
Alain Reguera Delgado 8f60cb
    ln -sf ${TCAR_WORKDIR}/Identity/Images/Webenv ${TARGET_FILE}/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
}