#!/bin/bash

## tests a transformation by temporarily copying conf.xslt.xml to
## conf_test.xslt.xml. It is only supposed to work on xml input
## in a file

sheet_fufi=$1
in_fufi=$2
out_fufi=$3

if [ ! $out_fufi ]; then
    echo "I need a sheet, input, output file"
    exit
fi

if [ ! $in_fufi ]; then
    echo "I need a sheet, input, output file"
    exit
fi

if [ ! $sheet_fufi ]; then
    echo "I need a sheet, input, output file"
    exit
fi

if [ ! -f $sheet_fufi ]; then
    echo I don\'t see $sheet_fufi
    exit
fi

if [ ! -f $in_fufi ]; then
    echo I don\'t see $in_fufi
    exit
fi

if [ -z $IMPNA ]; then
    echo I need your impna
    exit
fi

conf_fufi=$HOME/ernad/style/$IMPNA/conf.xslt.xml
if [ ! -f $conf_fuf ]; then
    echo I don\'t see $conf_fufi
    exit
fi

conf_test_fufi=$HOME/ernad/style/$IMPNA/conf_test.xslt.xml
if [ ! -f $conf_test_fufi ]; then
    echo I don\'t see $conf_test_fufi
    exit
fi

conf_back_fufi=$HOME/ernad/style/$IMPNA/conf_back.xslt.xml
if [ -f $conf_back_fufi ]; then
    echo I see $conf_back_fufi
    exit
fi

/usr/bin/cp -a $conf_fufi $conf_back_fufi
/usr/bin/cp -a $conf_test_fufi $conf_fufi
/usr/bin/xsltproc $sheet_fufi $in_fufi > $out_fufi
/usr/bin/mv $conf_back_fufi $conf_fufi
