diff --git a/Scripts/Bash/Functions/Render/Docbook/docbook_expandSystemEntities.sh b/Scripts/Bash/Functions/Render/Docbook/docbook_expandSystemEntities.sh new file mode 100755 index 0000000..c434548 --- /dev/null +++ b/Scripts/Bash/Functions/Render/Docbook/docbook_expandSystemEntities.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +# docbook_expandSystemEntities.sh -- This function expands system +# entities required by DocBook projects stored under +# `trunk/Documentation/Manuals' directory. +# +# Copyright (C) 2009-2012 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + + +function docbook_expandSystemEntities { + + # Define absolute path to instance where all operations will take + # place in. + local INSTANCE=$1 + + # Define absolute path to both common and specific system + # entities. + local ENTITIES_PATHS="$(cli_getFilesList ${DOCBOOK_MODELS_DIR}/Book ${ACTIONVAL} \ + --pattern=".ent$" --maxdepth=1 --mindepth=1 --type='f')" + + # Build definition of both common and specific system entities. + local ENTITIES="$(\ + for ENTITY_PATH in $ENTITIES_PATHS;do + local ENTITY_NAME=$(basename ${ENTITY_PATH}) + echo '\n\t\n' + echo '\t%'${ENTITY_NAME}';' + done)" + + # Define both xml and docbook public definition. + local PREAMBLE="" + PREAMBLE="${PREAMBLE}\n" + + # Remove both xml and docbook preamble from instance and insert + # it again with definitions of required common and specific system + # entities. + sed -r -i "1,2c$(echo $PREAMBLE)" ${INSTANCE} + +}