From 4d09fd9ce36b767c1ed99e9c66816dc0c4f735f9 Mon Sep 17 00:00:00 2001 From: cmdln Date: Sat, 16 Oct 2010 11:49:56 -0400 Subject: [PATCH] Added detection of when to use which transform. --- outline.bash | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/outline.bash b/outline.bash index aa20cdb..207c060 100755 --- a/outline.bash +++ b/outline.bash @@ -37,13 +37,24 @@ cp "$src" ./contents.xml.gz # gunzip original file gunzip contents.xml.gz + # makes sure the ns is only on one line, also # makes the interim file more readable for debugging tidy -config tidyrc -xml -m contents.xml + # xalan doesn't handle ns well, stripp them sed -e "s/ xmlns=\".*\"//g" -i contents.xml -# TODO use grep to figure out which xsl to use -xalan -xsl without_offset.xsl -in contents.xml -text -out contents.txt + +# use grep to figure out which xsl to use +grep "[0-9]\{2\}:[0-9]\{2\}" contents.xml > /dev/null +if [ "$?" == "0" ] +then + xsl=with_offset.xsl +else + xsl=without_offset +fi +xalan -xsl $xsl -in contents.xml -text -out contents.txt + # expand the indent counts to proper leading white space sed -e "s/^2/ /" -i contents.txt sed -e "s/^3/ /" -i contents.txt