source: trunk/minix/commands/bzip2-1.0.3/xmlproc.sh@ 12

Last change on this file since 12 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

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