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

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