source: gs2-extensions/xsd-to-gs-metaset/xsd_to_mds.bat@ 28364

Last change on this file since 28364 was 28364, checked in by jlwhisler, 11 years ago

Adding in a new extension to demonstrate how to use the xsd-to-mds.xsl XSLT file that Jenny recently added, to regenerate the CDWA-Lite file. This extension contains a batch script and a Readme file.

File size: 1.7 KB
RevLine 
[28364]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
13set xsd=%1
14set mds=%2
15
16if not exist %1 echo XSD file %1 does not exist.& goto exit
17
18
19if "%GSDLHOME%" == "" echo No GSDLHOME set. Source the (gs3-)setup.bat file in your Greenstone before running this script.& goto exit
20
21
22set outputdir=
23if not "%GSDL3SRCHOME%" == "" (
24set outputdir=%GSDL3SRCHOME%
25) else (
26set outputdir=%GSDLHOME%
27)
28set outputfile=%outputdir%\gli\metadata\%mds%.mds
29set xsl=%outputdir%\gli\classes\xml\xsd-to-mds.xsl
30
31:: See http://internal.greenstone.org/wiki/Writing_XSL#Running_ApplyXSLT_to_apply_an_XSLT_file_from_the_command_line
32set 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%"
33
34:: Call the command
35%xcmd%
36
37if not exist "%outputfile%" (
38echo **** XSLT transform failed: the file %outputfile% was not generated. Ran command:
39echo %xcmd%
40) else (
41echo The file %outputfile% has been generated.
42)
43
44goto exit
45
46:usage
47echo Run as %0 ^<xsd file^> ^<namespace^> ^<setname (mds file name)^>
48:: E.g. xsd_to_mds.bat C:\<full-path>\CDWALite-xsd-public-v1-1.xsd cdwalite CDWALite
49
50:exit
51
52endlocal
Note: See TracBrowser for help on using the repository browser.