root/gs2-extensions/xsd-to-gs-metaset/xsd_to_mds.bat @ 28383

Revision 28383, 1.8 KB (checked in by ak19, 6 years ago)

Added a bash script equivalent to the batch script added yesterday. Updated the Readme file and minor changes to the batch file too.

Line 
1@echo off
2setlocal enabledelayedexpansion
3
4:: Check for 3 cmd line args
5if [%3]==[] goto usage
6
7:: Passing cmd line parameters to xslt using Windows' msxml.exe
8:: http://stackoverflow.com/questions/4322807/how-to-pass-a-parameter-and-use-that-in-my-xslt
9:: http://stackoverflow.com/questions/2058247/successor-of-msxsl-exe
10:: Using Saxon: http://forums.devshed.com/xml-programming-19/how-to-pass-all-command-line-parameters-to-xsl-processor-673679.html
11:: http://www.sourceware.org/ml/xsl-list/2002-03/msg00838.html
12
13:: xsd input file and setName of mds file for output
14set xsd=%1
15set mds=%2
16
17if not exist %xsd% echo XSD file %xsd% does not exist.& goto exit
18
19
20if "%GSDLHOME%" == "" echo No GSDLHOME set. Source the (gs3-)setup.bat file in your Greenstone before running this script.& goto exit
21
22
23set outputdir=
24if not "%GSDL3SRCHOME%" == "" (
25set outputdir=%GSDL3SRCHOME%
26) else (
27set outputdir=%GSDLHOME%
28)
29set outputfile=%outputdir%\gli\metadata\%mds%.mds
30set xsl=%outputdir%\gli\classes\xml\xsd-to-mds.xsl
31
32if not exist %xsl% echo XSLT file %xsl% can't be found.& goto exit
33
34:: See internal wiki page Writing_XSL#Running_ApplyXSLT_to_apply_an_XSLT_file_from_the_command_line
35set 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%"
36
37:: Call the command
38%xcmd%
39
40if not exist "%outputfile%" (
41echo **** XSLT transform failed: the file %outputfile% was not generated. Ran command:
42echo %xcmd%
43) else (
44echo The file %outputfile% has been generated.
45)
46
47goto exit
48
49:usage
50echo.
51echo Run as %0 ^<xsd file^> ^<namespace^> ^<setname (mds file name)^>
52echo.
53:: E.g. xsd_to_mds.bat C:\<full-path>\CDWALite-xsd-public-v1-1.xsd cdwalite CDWALite
54
55:exit
56
57endlocal
Note: See TracBrowser for help on using the browser.