2006-06-02 [wwp] 2.2.0cvs72
[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 fi
11
12 test -n "$XML_CATALOG_FILES" && \
13         CATALOG_FILES=$XML_CATALOG_FILES || \
14         CATALOG_FILES="/usr/local/etc/xml/catalog /etc/xml/catalog $HOME/xml/catalog"
15 KEY="http://docbook.sourceforge.net/release/xsl/current"
16
17 for CATALOG in $CATALOG_FILES
18 do
19         if [ -s "$CATALOG" ]
20         then
21                 DOCBOOKXSLPATH=$(xmlcatalog "$CATALOG" "$KEY/")
22                 # second chance
23                 test $? -ne 0 -o -z "$DOCBOOKXSLPATH" && \
24                         DOCBOOKXSLPATH=$(xmlcatalog "$CATALOG" "$KEY")
25
26                 test "${DOCBOOKXSLPATH:0:7}" == "file://" && \
27                         DOCBOOKXSLPATH=${DOCBOOKXSLPATH:7}
28                 if [ -n "$DOCBOOKXSLPATH" ]
29                 then
30                         echo "docbook-xsl path found: $DOCBOOKXSLPATH"
31                         sed "s|@DOCBOOK_XSL_PATH@|$DOCBOOKXSLPATH|g" "$1" > sylpheed-claws-manual.xsl && \
32                                 saxon -o sylpheed-claws-manual.fo "$2" sylpheed-claws-manual.xsl && \
33                                 fop -fo sylpheed-claws-manual.fo -pdf sylpheed-claws-manual.pdf
34                         exit $?
35                 fi
36         fi
37 done
38 echo "couldn't find docbook-xsl path from any of the following catalog files:"
39 echo "$CATALOG_FILES"
40 exit 1