cannam@89
|
1 #!/bin/bash
|
cannam@89
|
2 # see the README file for usage etc.
|
cannam@89
|
3 #
|
cannam@89
|
4 # ------------------------------------------------------------------
|
cannam@89
|
5 # This file is part of bzip2/libbzip2, a program and library for
|
cannam@89
|
6 # lossless, block-sorting data compression.
|
cannam@89
|
7 #
|
cannam@89
|
8 # bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
cannam@89
|
9 # Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
cannam@89
|
10 #
|
cannam@89
|
11 # Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
cannam@89
|
12 # README file.
|
cannam@89
|
13 #
|
cannam@89
|
14 # This program is released under the terms of the license contained
|
cannam@89
|
15 # in the file LICENSE.
|
cannam@89
|
16 # ----------------------------------------------------------------
|
cannam@89
|
17
|
cannam@89
|
18
|
cannam@89
|
19 usage() {
|
cannam@89
|
20 echo '';
|
cannam@89
|
21 echo 'Usage: xmlproc.sh -[option] <filename.xml>';
|
cannam@89
|
22 echo 'Specify a target from:';
|
cannam@89
|
23 echo '-v verify xml file conforms to dtd';
|
cannam@89
|
24 echo '-html output in html format (single file)';
|
cannam@89
|
25 echo '-ps output in postscript format';
|
cannam@89
|
26 echo '-pdf output in pdf format';
|
cannam@89
|
27 exit;
|
cannam@89
|
28 }
|
cannam@89
|
29
|
cannam@89
|
30 if test $# -ne 2; then
|
cannam@89
|
31 usage
|
cannam@89
|
32 fi
|
cannam@89
|
33 # assign the variable for the output type
|
cannam@89
|
34 action=$1; shift
|
cannam@89
|
35 # assign the output filename
|
cannam@89
|
36 xmlfile=$1; shift
|
cannam@89
|
37 # and check user input it correct
|
cannam@89
|
38 if !(test -f $xmlfile); then
|
cannam@89
|
39 echo "No such file: $xmlfile";
|
cannam@89
|
40 exit;
|
cannam@89
|
41 fi
|
cannam@89
|
42 # some other stuff we will use
|
cannam@89
|
43 OUT=output
|
cannam@89
|
44 xsl_fo=bz-fo.xsl
|
cannam@89
|
45 xsl_html=bz-html.xsl
|
cannam@89
|
46
|
cannam@89
|
47 basename=$xmlfile
|
cannam@89
|
48 basename=${basename//'.xml'/''}
|
cannam@89
|
49
|
cannam@89
|
50 fofile="${basename}.fo"
|
cannam@89
|
51 htmlfile="${basename}.html"
|
cannam@89
|
52 pdffile="${basename}.pdf"
|
cannam@89
|
53 psfile="${basename}.ps"
|
cannam@89
|
54 xmlfmtfile="${basename}.fmt"
|
cannam@89
|
55
|
cannam@89
|
56 # first process the xmlfile with CDATA tags
|
cannam@89
|
57 ./format.pl $xmlfile $xmlfmtfile
|
cannam@89
|
58 # so the shell knows where the catalogs live
|
cannam@89
|
59 export XML_CATALOG_FILES=/etc/xml/catalog
|
cannam@89
|
60
|
cannam@89
|
61 # post-processing tidy up
|
cannam@89
|
62 cleanup() {
|
cannam@89
|
63 echo "Cleaning up: $@"
|
cannam@89
|
64 while [ $# != 0 ]
|
cannam@89
|
65 do
|
cannam@89
|
66 arg=$1; shift;
|
cannam@89
|
67 echo " deleting $arg";
|
cannam@89
|
68 rm $arg
|
cannam@89
|
69 done
|
cannam@89
|
70 }
|
cannam@89
|
71
|
cannam@89
|
72 case $action in
|
cannam@89
|
73 -v)
|
cannam@89
|
74 flags='--noout --xinclude --noblanks --postvalid'
|
cannam@89
|
75 dtd='--dtdvalid http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd'
|
cannam@89
|
76 xmllint $flags $dtd $xmlfmtfile 2> $OUT
|
cannam@89
|
77 egrep 'error' $OUT
|
cannam@89
|
78 rm $OUT
|
cannam@89
|
79 ;;
|
cannam@89
|
80
|
cannam@89
|
81 -html)
|
cannam@89
|
82 echo "Creating $htmlfile ..."
|
cannam@89
|
83 xsltproc --nonet --xinclude -o $htmlfile $xsl_html $xmlfmtfile
|
cannam@89
|
84 cleanup $xmlfmtfile
|
cannam@89
|
85 ;;
|
cannam@89
|
86
|
cannam@89
|
87 -pdf)
|
cannam@89
|
88 echo "Creating $pdffile ..."
|
cannam@89
|
89 xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile
|
cannam@89
|
90 pdfxmltex $fofile >$OUT </dev/null
|
cannam@89
|
91 pdfxmltex $fofile >$OUT </dev/null
|
cannam@89
|
92 pdfxmltex $fofile >$OUT </dev/null
|
cannam@89
|
93 cleanup $OUT $xmlfmtfile *.aux *.fo *.log *.out
|
cannam@89
|
94 ;;
|
cannam@89
|
95
|
cannam@89
|
96 -ps)
|
cannam@89
|
97 echo "Creating $psfile ..."
|
cannam@89
|
98 xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile
|
cannam@89
|
99 pdfxmltex $fofile >$OUT </dev/null
|
cannam@89
|
100 pdfxmltex $fofile >$OUT </dev/null
|
cannam@89
|
101 pdfxmltex $fofile >$OUT </dev/null
|
cannam@89
|
102 pdftops $pdffile $psfile
|
cannam@89
|
103 cleanup $OUT $xmlfmtfile $pdffile *.aux *.fo *.log *.out
|
cannam@89
|
104 # passivetex is broken, so we can't go this route yet.
|
cannam@89
|
105 # xmltex $fofile >$OUT </dev/null
|
cannam@89
|
106 # xmltex $fofile >$OUT </dev/null
|
cannam@89
|
107 # xmltex $fofile >$OUT </dev/null
|
cannam@89
|
108 # dvips -R -q -o bzip-manual.ps *.dvi
|
cannam@89
|
109 ;;
|
cannam@89
|
110
|
cannam@89
|
111 *)
|
cannam@89
|
112 usage
|
cannam@89
|
113 ;;
|
cannam@89
|
114 esac
|