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