Blame Automation/centos-art.sh-mods/Render/Docbook/docbook.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# docbook.sh -- This function performs base-rendition actions for
Alain Reguera Delgado 8f60cb
# DocBook files.
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 {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to XSL files used for transforming DocBook
Alain Reguera Delgado 8f60cb
    # into other formats.
Alain Reguera Delgado 8f60cb
    local DOCBOOK_XSL="${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Xsl"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to DocBook models. This path must take
Alain Reguera Delgado 8f60cb
    # until the directory which holds the main documentation docbook
Alain Reguera Delgado 8f60cb
    # file.
Alain Reguera Delgado 8f60cb
    local DOCBOOK_MODELS="$(dirname ${TEMPLATE})"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify absolute path to DocBook models.
Alain Reguera Delgado 8f60cb
    cli_checkFiles ${DOCBOOK_MODELS} -d
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Create the non-translated instance of design model. 
Alain Reguera Delgado 8f60cb
    cp ${TEMPLATE} ${INSTANCE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Expand common contents inside instance.
Alain Reguera Delgado 8f60cb
    docbook_setExpansionLicenses ${INSTANCE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # When translated instances are rendered, system entities (e.g.,
Alain Reguera Delgado 8f60cb
    # `%entity-name;') don't appear in the translated instance (it
Alain Reguera Delgado 8f60cb
    # seems that xml2po removes them) and this provokes DocBook
Alain Reguera Delgado 8f60cb
    # validation to fail.  So in order to pass the validation
Alain Reguera Delgado 8f60cb
    # successfully and automate the whole creation of system entities,
Alain Reguera Delgado 8f60cb
    # don't let this duty ion users'. Instead, make centos-art.sh
Alain Reguera Delgado 8f60cb
    # script responsible of it.
Alain Reguera Delgado 8f60cb
    docbook_setExpansionSystemEntities ${INSTANCE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Print validating action.
Alain Reguera Delgado 8f60cb
    cli_printMessage "${INSTANCE}" --as-validating-line
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Validate translated instance before processing it. This step is
Alain Reguera Delgado 8f60cb
    # very important in order to detect document's malformations and
Alain Reguera Delgado 8f60cb
    # warn you about it, so you can correct them. It is also necessary
Alain Reguera Delgado 8f60cb
    # to save them in a new file in order to make translation markers
Alain Reguera Delgado 8f60cb
    # expansion possible before transforming the DocBook instance into
Alain Reguera Delgado 8f60cb
    # other formats.
Alain Reguera Delgado 8f60cb
    xmllint --valid --noent ${INSTANCE} > ${INSTANCE}.tmp
Alain Reguera Delgado 8f60cb
    if [[ $? -ne 0 ]];then
Alain Reguera Delgado 8f60cb
        cli_printMessage "`gettext "Validation failed."`" --as-error-line
Alain Reguera Delgado 8f60cb
    fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Update instance to add translation markers expansion.
Alain Reguera Delgado 8f60cb
    mv ${INSTANCE}.tmp ${INSTANCE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Expand translation markers on the temporal instance with
Alain Reguera Delgado 8f60cb
    # entities already expanded.
Alain Reguera Delgado 8f60cb
    cli_expandTMarkers ${INSTANCE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify translation file existence apply translation to docbook
Alain Reguera Delgado 8f60cb
    # design model instance in order to produce the translated design
Alain Reguera Delgado 8f60cb
    # model instance.
Alain Reguera Delgado 8f60cb
    if [[ -f ${TRANSLATION} ]];then
Alain Reguera Delgado 8f60cb
        docbook_setTranslation ${INSTANCE}
Alain Reguera Delgado 8f60cb
    fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Convert DocBook source files to other formats.
Alain Reguera Delgado 8f60cb
    docbook_setConversionXhtmlChunks ${INSTANCE}
Alain Reguera Delgado 8f60cb
    docbook_setConversionXhtml ${INSTANCE}
Alain Reguera Delgado 8f60cb
    docbook_setConversionText
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # NOTE: The current transformation from DocBook to PDF fails when
Alain Reguera Delgado 8f60cb
    # we started to use DocBook <index /> tags inside DocBook files.
Alain Reguera Delgado 8f60cb
    # Probably we need to test what happen when a newer release of XSL
Alain Reguera Delgado 8f60cb
    # is used. Thus, comment production of PDF files until it can be
Alain Reguera Delgado 8f60cb
    # produced correctly.
Alain Reguera Delgado 8f60cb
    #docbook_setConversionXml2Pdf
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # NOTE: From version 5.0 on, DocBook specification is no longer a
Alain Reguera Delgado 8f60cb
    # SGML specification but an XML specification only. Thus,
Alain Reguera Delgado 8f60cb
    # transformations related to DocBook SGML specification won't be
Alain Reguera Delgado 8f60cb
    # supported in `centos-art.sh' script.
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Perform format post-rendition.
Alain Reguera Delgado 8f60cb
    docbook_setPostRendition
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Perform format last-rendition.
Alain Reguera Delgado 8f60cb
    docbook_setLastRendition
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}