@echo off setlocal enabledelayedexpansion :: Check for 3 cmd line args if [%3]==[] goto usage :: Passing cmd line parameters to xslt using Windows' msxml.exe :: http://stackoverflow.com/questions/4322807/how-to-pass-a-parameter-and-use-that-in-my-xslt :: http://stackoverflow.com/questions/2058247/successor-of-msxsl-exe :: Using Saxon: http://forums.devshed.com/xml-programming-19/how-to-pass-all-command-line-parameters-to-xsl-processor-673679.html :: http://www.sourceware.org/ml/xsl-list/2002-03/msg00838.html :: xsd input file and setName of mds file for output set xsd=%1 set mds=%2 if not exist %xsd% echo XSD file %xsd% does not exist.& goto exit if "%GSDLHOME%" == "" echo No GSDLHOME set. Source the (gs3-)setup.bat file in your Greenstone before running this script.& goto exit set outputdir= if not "%GSDL3SRCHOME%" == "" ( set outputdir=%GSDL3SRCHOME% ) else ( set outputdir=%GSDLHOME% ) set outputfile=%outputdir%\gli\metadata\%mds%.mds set xsl=%outputdir%\gli\classes\xml\xsd-to-mds.xsl if not exist %xsl% echo XSLT file %xsl% can't be found.& goto exit :: See internal wiki page Writing_XSL#Running_ApplyXSLT_to_apply_an_XSLT_file_from_the_command_line set xcmd=java -cp "%GSDLHOME%/bin/java/xalan.jar";"%GSDLHOME%/bin/java/ApplyXSLT.jar";"%GSDLHOME%/bin/java/." org.nzdl.gsdl.ApplyXSLT -t "%xsl%" -x "%xsd%" -o "%outputfile%" :: Call the command %xcmd% if not exist "%outputfile%" ( echo **** XSLT transform failed: the file %outputfile% was not generated. Ran command: echo %xcmd% ) else ( echo The file %outputfile% has been generated. ) goto exit :usage echo. echo Run as %0 ^ ^ ^ echo. :: E.g. xsd_to_mds.bat C:\\CDWALite-xsd-public-v1-1.xsd cdwalite CDWALite :exit endlocal