2006-06-09 [paul] 2.2.3cvs4
[claws.git] / manual / xml2pdf
1 #!/bin/sh
2
3 # pdf generation from xml and xsl
4 # $1: .xsl file 
5 # $2: .xml file
6
7 if [ $# -ne 2 ]
8 then
9         echo "usage: ${0##*/} <file.xsl> <file.xml>"
10         exit 1
11 fi
12
13 if [ -n "$XML_CATALOG_FILES" ]
14 then
15         CATALOG_FILES=$XML_CATALOG_FILES
16 else
17         echo "warning: XML_CATALOG_FILES is not set or empty"
18         CATALOG_FILES="/usr/local/etc/xml/catalog /etc/xml/catalog $HOME/xml/catalog"
19 fi
20 KEY="http://docbook.sourceforge.net/release/xsl/current"
21
22 for CATALOG in $CATALOG_FILES
23 do
24         if [ -s "$CATALOG" ]
25         then
26                 DOCBOOKXSLPATH=$(xmlcatalog "$CATALOG" "$KEY/")
27                 # second chance
28                 if [ $? -ne 0 -o -z "$DOCBOOKXSLPATH" ]
29                 then
30                         DOCBOOKXSLPATH=$(xmlcatalog "$CATALOG" "$KEY")
31                         # still not found
32                         test $? -ne 0 -o -z "$DOCBOOKXSLPATH" && \
33                                 continue
34                 fi
35
36                 test "${DOCBOOKXSLPATH:0:7}" == "file://" && \
37                         DOCBOOKXSLPATH=${DOCBOOKXSLPATH:7}
38                 if [ -n "$DOCBOOKXSLPATH" ]
39                 then
40                         echo "docbook-xsl path found: $DOCBOOKXSLPATH"
41                         sed "s|@DOCBOOK_XSL_PATH@|$DOCBOOKXSLPATH|g" "$1" > sylpheed-claws-manual.xsl && \
42                                 saxon -o sylpheed-claws-manual.fo "$2" sylpheed-claws-manual.xsl && \
43                                 fop -fo sylpheed-claws-manual.fo -pdf sylpheed-claws-manual.pdf
44                         exit $?
45                 fi
46         fi
47 done
48 echo "couldn't find docbook-xsl path from any of the following catalog files:"
49 echo "$CATALOG_FILES"
50 exit 1