#! /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 

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

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

# generate gnuplot output from previously generated xml-plot
/usr/bin/xslttransform /tmp/plot$$ /usr/lib/xml/plot2gp.xsl 
rm /tmp/plot$$
