2009-01-27 [paul] 3.7.0cvs44
[claws.git] / manual / xml2pdf
blobd30fa0aa1213745e90fe9454f37c17ea5a24a2f2
1 #!/bin/sh
3 # pdf generation from xml and xsl
4 # $1: .xsl file
5 # $2: .xml file
7 if [ $# -ne 2 ]
8 then
9 echo "usage: ${0##*/} <file.xsl> <file.xml>"
10 exit 1
13 test -z "$JAVA" && \
14 JAVA=`which java`
15 test -z "$JAVA" && \
16 JAVA="$JAVA_HOME/bin/java"
17 if [ ! -x "$JAVA" ]
18 then
19 echo 'error: java not found in your $PATH or in $JAVA_HOME/bin'
20 exit 1
23 test -z "$SAXON" && \
24 SAXON=`which saxon`
25 if [ -z "$SAXON" ]
26 then
27 test -z "$SAXONJAR" && \
28 SAXONJAR='/usr/share/java/saxon.jar'
29 if [ ! -f "$SAXONJAR" ]
30 then
31 SAXONJAR='/usr/local/share/java/saxon.jar'
32 if [ ! -f "$SAXONJAR" ]
33 then
34 echo "error: neither saxon nor saxon.jar were found"
35 exit 1
38 SAXON="$JAVA -jar $SAXONJAR"
42 if [ -n "$XML_CATALOG_FILES" ]
43 then
44 CATALOG_FILES=$XML_CATALOG_FILES
45 else
46 echo "warning: XML_CATALOG_FILES is not set or empty"
47 CATALOG_FILES="/usr/local/etc/xml/catalog /etc/xml/catalog
48 /usr/local/share/xml/catalog $HOME/xml/catalog"
50 KEY="http://docbook.sourceforge.net/release/xsl/current"
52 # manual base name
53 SCM=claws-mail-manual
55 for CATALOG in $CATALOG_FILES
57 if [ -s "$CATALOG" ]
58 then
59 DOCBOOKXSLPATH=$(xmlcatalog "$CATALOG" "$KEY/")
60 # second chance
61 if [ $? -ne 0 -o -z "$DOCBOOKXSLPATH" ]
62 then
63 DOCBOOKXSLPATH=$(xmlcatalog "$CATALOG" "$KEY")
64 # still not found
65 test $? -ne 0 -o -z "$DOCBOOKXSLPATH" && \
66 continue
69 test "`echo ${DOCBOOKXSLPATH} | cut -c 1-7`" = "file://" && \
70 DOCBOOKXSLPATH=`echo ${DOCBOOKXSLPATH} | cut -c 8-`
71 if [ -n "$DOCBOOKXSLPATH" ]
72 then
73 echo "docbook-xsl path found: $DOCBOOKXSLPATH"
74 sed "s|@DOCBOOK_XSL_PATH@|$DOCBOOKXSLPATH|g" "$1" \
75 > ${SCM}.xsl && \
76 $SAXON -o ${SCM}.fo "$2" ${SCM}.xsl && \
77 fop -fo ${SCM}.fo -pdf ${SCM}.pdf
78 exit $?
81 done
82 echo "couldn't find docbook-xsl path from any of the following catalog files:"
83 echo "$CATALOG_FILES"
84 exit 1