@ECHO OFF

if '%1 == ' goto no-params

if %1 == help goto myhelp

if not exist %1 goto no-xml-file

if not exist %2 goto no-xsl-file

if '%3 == ' goto no-output-file

set rootdir=..\..\..

set oldCLASSPATH=%CLASSPATH%

set which_saxon=saxon

set CLASSPATH=%rootdir%\%which_saxon%\saxon9ee.jar
set CLASSPATH=%CLASSPATH%;.;C:\SAXON-license\

echo ---------------------------------------------------------
echo Running the XSLT Processor, Saxon, with the following specifications:
echo    - XML File: %1
echo    - XSL File: %2
echo    - Output File: %3
echo ---------------------------------------------------------
echo.

java -classpath %CLASSPATH% -jar %rootdir%\%which_saxon%\saxon9ee.jar -o:%3 %1 %2


echo.
echo Done.
echo.
goto eof

:no-params
    cls
    echo Oops! You need to run the batch file with 3 arguments.
    echo Here's how to use it ...
    echo.
    echo Usage: "run-saxon <xml filename> <xsl filename> <output filename>"
    echo.
    goto eof

:myhelp
    cls
    echo Usage: "run-saxon <xml filename> <xsl filename> <output filename>"
    echo.
    goto eof

:no-xml-file
   cls
   echo Oops! %1 does not exist
   echo Most likely reason: mistyped filename
   echo Exiting ...
   echo.
   goto eof

:no-xsl-file
   cls
   echo Oops! %2 does not exist
   echo Most likely reason: mistyped filename
   echo Exiting ...
   echo.
   goto eof

:no-output-file
   cls
   echo Oops! You must specify an output file
   echo Exiting ...
   echo.
   goto eof

:no-saxon-jar
   cls
   echo Oops! Missing this saxon file: %rootdir%xslProcessors\%which_saxon%\saxon7.jar
   echo Most likely reason: saxon not installed in the correct directory
   echo Exiting ...
   goto eof

:eof

