Blame Scripts/Bash/Functions/Render/Docbook/docbook_setConversionXhtmlChunks.sh

Alain Reguera Delgado 64aead
#!/bin/bash
Alain Reguera Delgado 64aead
#
Alain Reguera Delgado 64aead
# docbook_setConversionXhtmlChunks.sh -- This function uses DocBook XML as
Alain Reguera Delgado 64aead
# input and applies XSL stylesheets to produce a directory with many
Alain Reguera Delgado 64aead
# XHTML files as output.  The procedure was taken from the
Alain Reguera Delgado 64aead
# documentation of `docbook-style-xsl-1.69.1-5.1' package, which says:
Alain Reguera Delgado 64aead
# ---To publish HTML from your XML documents, you just need an XSLT
Alain Reguera Delgado 64aead
# engine.---.
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_setConversionXhtmlChunks {
Alain Reguera Delgado 64aead
Alain Reguera Delgado 64aead
    local -a STYLE_TEMPLATE
Alain Reguera Delgado 64aead
    local -a STYLE_INSTANCE
Alain Reguera Delgado 64aead
    local STYLE_INSTANCE_FINAL=''
Alain Reguera Delgado 64aead
Alain Reguera Delgado 64aead
    # Define absolute path to DocBook source file. This is the
Alain Reguera Delgado 64aead
    # repository documentation manual file where DOCTYPE and ENTITY
Alain Reguera Delgado 64aead
    # definition lines are set.
Alain Reguera Delgado 64aead
    local SOURCE_FILE=${1}
Alain Reguera Delgado 64aead
Alain Reguera Delgado 64aead
    # Define absolute path to XHTML target file. This is the final
Alain Reguera Delgado 64aead
    # location the XHTML file produced as result of DocBook to PDF
Alain Reguera Delgado 64aead
    # transformation will be stored in.
Alain Reguera Delgado 64aead
    local TARGET_FILE="${FILE}-xhtml-chunks/"
Alain Reguera Delgado 64aead
Alain Reguera Delgado 64aead
    # Clean up output directory. This is required in order to prevent
Alain Reguera Delgado 64aead
    # old files from remaining therein when they are no longer needed.
Alain Reguera Delgado 64aead
    if [[ -d ${TARGET_FILE} ]];then
Alain Reguera Delgado 64aead
        rm -r "${TARGET_FILE}"
Alain Reguera Delgado 64aead
    fi 
Alain Reguera Delgado 64aead
    mkdir ${TARGET_FILE}
Alain Reguera Delgado 64aead
Alain Reguera Delgado 64aead
    # Print action message.
Alain Reguera Delgado 64aead
    cli_printMessage "${TARGET_FILE}" --as-creating-line
Alain Reguera Delgado 64aead
Alain Reguera Delgado 64aead
    # Prepare XSL final instances used in transformations.
Alain Reguera Delgado 64aead
    docbook_setStyles $(cli_getFilesList \
Alain Reguera Delgado 64aead
        ${DOCBOOK_XSL} --pattern='^.*/docbook2xhtml-(chunks|common)\.xsl$')
Alain Reguera Delgado 64aead
Alain Reguera Delgado 64aead
    # Transform DocBook XML to XHTML suppressing all stderr output.
Alain Reguera Delgado 64aead
    xsltproc --output ${TARGET_FILE} ${STYLE_INSTANCE_FINAL} ${SOURCE_FILE} &> /dev/null
Alain Reguera Delgado 64aead
Alain Reguera Delgado 64aead
    # Create `css' and `images' directories. In order to save disk
Alain Reguera Delgado 64aead
    # space, these directories are linked (symbolically) to their
Alain Reguera Delgado 64aead
    # respective locations inside the working copy. Be sure to remove
Alain Reguera Delgado 64aead
    # previous links first to prevent a recursive creation of links.
Alain Reguera Delgado 64aead
    ln -sf ${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Css ${TARGET_FILE}/Css
Alain Reguera Delgado 64aead
    ln -sf ${TCAR_WORKDIR}/Identity/Images/Webenv ${TARGET_FILE}/Images
Alain Reguera Delgado 64aead
Alain Reguera Delgado 64aead
    # Remove XSL instance files.
Alain Reguera Delgado 64aead
    rm ${STYLE_INSTANCE[*]}
Alain Reguera Delgado 64aead
Alain Reguera Delgado 64aead
}