@ECHO OFF

if '%1 == ' goto no-params

if not exist %1 goto no-xml-file
if not exist %2 goto no-xpipe-file

set rootdir=..\..\

if not exist %rootdir%\lib\calumet\xproc.jar goto no-calumet-jar

set oldPath=%path%
set oldCLASSPATH=%CLASSPATH%

set CLASSPATH=.
set CLASSPATH=%CLASSPATH%;%rootdir%\lib\calumet\commons-codec-1.3.jar
set CLASSPATH=%CLASSPATH%;%rootdir%\lib\calumet\commons-httpclient-3.1.jar
set CLASSPATH=%CLASSPATH%;%rootdir%\lib\calumet\commons-logging-1.1.1.jar
set CLASSPATH=%CLASSPATH%;%rootdir%\lib\calumet\jing.jar
set CLASSPATH=%CLASSPATH%;%rootdir%\lib\calumet\serializer.jar
set CLASSPATH=%CLASSPATH%;%rootdir%\lib\calumet\tagsoup-1.2.jar
set CLASSPATH=%CLASSPATH%;%rootdir%\lib\calumet\xalan.jar
set CLASSPATH=%CLASSPATH%;%rootdir%\lib\calumet\xercesImpl.jar
set CLASSPATH=%CLASSPATH%;%rootdir%\lib\calumet\xml-apis.jar
set CLASSPATH=%CLASSPATH%;%rootdir%\lib\calumet\xproc.jar

java -classpath %CLASSPATH% com.emc.documentum.xml.xproc.tool.Cmd -i source=%1 %2  


set path=%oldPath%
set CLASSPATH=%oldCLASSPATH%

goto eof

:no-params
    cls
    echo Oops! You need to run the batch file with 2 arguments.
    echo Here's how to use it ...
    echo.
    echo Usage: "run-calumet <xml filename><xpipe 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-xpipe-file
   cls
   echo Oops! %1 does not exist
   echo Most likely reason: mistyped filename
   echo Exiting ...
   echo.
   goto eof

:no-calumet-jar
   cls
   echo Oops! Missing this calumet file: xproc.jar
   echo Most likely reason: calumet not installed in the correct directory
   echo Exiting ...
   goto eof


:eof