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