#!/bin/bash # see the README in this directory for usage etc. proc usage { echo ''; echo 'Usage: xmlproc.sh -[option] '; echo 'Specify a target from:'; echo '-v verify xml file conforms to dtd'; echo '-html output in html format (single file)'; echo '-ps output in postscript format'; echo '-pdf output in pdf format'; exit; } if test $Argc -ne 2 { usage } # assign the variable for the output type setglobal action = $1; shift # assign the output filename setglobal xmlfile = $1; shift # and check user input it correct if !(test -f $xmlfile) { echo "No such file: $xmlfile"; exit; } # some other stuff we will use setglobal OUT = 'output' setglobal xsl_fo = 'bz-fo.xsl' setglobal xsl_html = 'bz-html.xsl' setglobal basename = $xmlfile setglobal basename = $(basename//'.xml'/'') setglobal fofile = ""$(basename).fo"" setglobal htmlfile = ""$(basename).html"" setglobal pdffile = ""$(basename).pdf"" setglobal psfile = ""$(basename).ps"" setglobal xmlfmtfile = ""$(basename).fmt"" # first process the xmlfile with CDATA tags ./format.pl $xmlfile $xmlfmtfile # so the shell knows where the catalogs live export XML_CATALOG_FILES=/etc/xml/catalog # post-processing tidy up proc cleanup { echo "Cleaning up: # $ifsjoin(ARGV)" while [ $# != 0 ] { setglobal arg = $1; shift; echo " deleting $arg"; rm $arg } } match $action { with -v setglobal flags = ''--noout --xinclude --noblanks --postvalid'' setglobal dtd = ''--dtdvalid http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd'' xmllint $flags $dtd $xmlfmtfile 2> $OUT egrep 'error' $OUT rm $OUT with -html echo "Creating $htmlfile ..." xsltproc --nonet --xinclude -o $htmlfile $xsl_html $xmlfmtfile cleanup $xmlfmtfile with -pdf echo "Creating $pdffile ..." xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile pdfxmltex $fofile >$OUT $OUT $OUT $OUT $OUT $OUT $OUT $OUT $OUT