#!/bin/sh # # xmlprofile -- select portions of an XML document by attribute # # Trivial wrapper around Jirka Kosek's stylesheet-transform technique # for profiling XML documents. Uses xsltproc or saxon. # # Usage: xmlprofile param value file... # # by Eric S. Raymond 18 September 2002 param=$1; shift value=$1; shift files="$*" stylesheet=/usr/tmp/xmlprofile$$.xml trap "rm -f $stylesheet" 0 1 2 15 # Generate a stylesheet that know about the attribute we're passing in cat >$stylesheet < EOF # Apply the generated stylesheet using whatever XSLT engine is handy if which xsltproc >/dev/null then for file in $files do xsltproc --novalid --stringparam $param $value $stylesheet $file done elif which saxon >/dev/null then for file in $files do saxon $file $stylesheet "${param}=${value}" done else echo "xmlprofile: couldn't find an XSLT engine!" 1>&2 exit 1 fi exit 0 # End