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