#!/usr/bin/env sh

# Copyright 2014 Newport Software Technologies, UNICEN
#
# This file is part of XGAP.
#
# XGAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# XGAP 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with XGAP.  If not, see <http://www.gnu.org/licenses/>.

# Script para generar documentación de los esquemas XML, usando
# [DocFlex/XML](http://www.filigris.com/docflex-xml/).

XGAP_MOTOR=ultimo
# Modificar los valores de JAVA_HOME Y DFH de acuerdo al entorno local
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
DFH=/opt/docflex-xml

JAVA_OPTIONS="-Xms512m -Xmx1024m"
CLASS_PATH="${DFH}/lib/xml-apis.jar:${DFH}/lib/xercesImpl.jar:${DFH}/lib/resolver.jar:${DFH}/lib/docflex-xml.jar"

SCRIPT_DIR="`dirname "$0"`"
XGAP_DIR="`cd -P "$SCRIPT_DIR/.." && pwd`"
DOC_DIR="`cd -P "$SCRIPT_DIR" && pwd`"
XSD_DIR="$XGAP_DIR/motores/$XGAP_MOTOR/plantillas"

SRC_XSDS="$XSD_DIR/aplicacion.xsd $XSD_DIR/aplicacion.xsd $XSD_DIR/contenido.xsd $XSD_DIR/formulario.xsd $XSD_DIR/grafico.xsd $XSD_DIR/listado.xsd $XSD_DIR/menu.xsd $XSD_DIR/reporte_odt.xsd $XSD_DIR/reporte_pdf.xsd"

# No funciona si hay algun directorio con espacios
"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} -cp "${CLASS_PATH}" com.docflex.xml.Generator \
  -docflexconfig "${DFH}/linux/docflex.config" -config "$DOC_DIR/docflex-generator.config" \
  -template "${DFH}/templates/XSDDoc/FramedDoc.tpl" -d "$DOC_DIR/xsd-docflex" -nodialog=true \
  $SRC_XSDS
