root/tags/lgt2211/xml/lgt2pdf.sh

Revision 1513, 2.2 KB (checked in by pmoura, 4 years ago)

Updated release number to 2.21.1.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/bin/bash
2
3## =================================================================
4## Logtalk - Object oriented extension to Prolog
5## Release 2.21.1
6##
7## Copyright (c) 1998-2004 Paulo Moura.  All Rights Reserved.
8## =================================================================
9
10a4_xsl="$LOGTALKHOME/xml/lgtpdfa4.xsl"
11us_xsl="$LOGTALKHOME/xml/lgtpdfus.xsl"
12
13format=a4
14# format=us
15
16processor=fop
17# processor=xep
18
19directory="."
20
21usage_help()
22{
23    echo
24    echo "This script converts all Logtalk XML documenting files in the"
25    echo "current directory to PDF files"
26    echo
27    echo "Usage:"
28    echo "  $0 -f format -d directory -p processor"
29    echo "  $0 -h"
30    echo
31    echo "Optional arguments:"
32    echo "  -f paper format (either a4 or us; default is $format)"
33    echo "  -d output directory for the PDF files (default is $directory)"
34    echo "  -p XSL-FO processor (either fop or xep; default is $processor)"
35    echo "  -h help"
36    echo
37    exit 1
38}
39
40if ! [ $LOGTALKHOME ]
41then
42    echo "Error! The environment variable LOGTALKHOME must be defined first!"
43    exit 1
44else
45
46    while getopts "f:d:p:h" Option
47    do
48        case $Option in
49            f) f_arg="$OPTARG";;
50            d) d_arg="$OPTARG";;
51            p) p_arg="$OPTARG";;
52            h) usage_help;;
53            *) usage_help;;
54        esac
55    done
56
57    if [[ "$f_arg" != "" && "$f_arg" != "a4" && "$f_arg" != "us" ]]
58    then
59        echo "Error! Unsupported output format: $f_arg"
60        usage_help
61        exit 1
62    elif [ "$f_arg" != "" ]
63    then
64        format=$f_arg
65    fi
66
67    if [[ "$d_arg" != "" && ! -d "$d_arg" ]]
68    then
69        echo "Error! directory does not exists: $d_arg"
70        usage_help
71        exit 1
72    elif [ "$d_arg" != "" ]
73    then
74        directory=$d_arg
75    fi
76
77    if [[ "$p_arg" != "" && "$p_arg" != "fop" && "$p_arg" != "xep" ]]
78    then
79        echo "Error! Unsupported XSL-FO processor: $p_arg"
80        usage_help
81        exit 1
82    elif [ "$p_arg" != "" ]
83    then
84        processor=$p_arg
85    fi
86
87    if [ "$format" = "a4" ]
88    then
89        xsl=$a4_xsl
90    else
91        xsl=$us_xsl
92    fi
93
94    cp $LOGTALKHOME/xml/logtalk.dtd .
95    cp $LOGTALKHOME/xml/logtalk.xsd .
96
97    echo
98    echo "converting XML files to PDF..."
99
100    for file in *.xml; do
101        echo "  converting $file"
102        name="`expr "$file" : '\(.*\)\.[^./]*$' \| "$file"`"
103        eval $processor -q -xml $file -xsl $xsl -pdf $directory/$name.pdf
104    done
105
106    echo "conversion done"
107    echo
108
109    rm logtalk.dtd
110    rm logtalk.xsd
111
112    exit 0
113
114fi
Note: See TracBrowser for help on using the browser.