#! /bin/sh

# check correct usage
if test $# -lt 2;
then
  echo Usage: $0 plot.xml archive.xml 
  echo or     $0 plot.xml task1.xml task2.xml ...
  exit
fi 

f=$1
dir=`dirname $0`

# define xsl-settings from xml-plot input  
$dir/xslttransform $1 $dir/../lib/xml/plot2xsl.xsl > /tmp/archive2plot$$.xsl 

# generate xml-plot output from archive or list of task files
if test $# -gt 2;
then
  $dir/archivecat `echo $* | cut -d' ' -f2-` > /tmp/archive$$
  $dir/xslttransform /tmp/archive$$ /tmp/archive2plot$$.xsl > /tmp/plot$$
  rm /tmp/archive$$
else
  $dir/xslttransform $2 /tmp/archive2plot$$.xsl > /tmp/plot$$  
fi
rm /tmp/archive2plot$$.xsl

# generate text output from previously generated xml-plot
$dir/xslttransform /tmp/plot$$ $dir/../lib/xml/plot2text.xsl 
rm /tmp/plot$$
