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

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