Last change
on this file since 28607 was 28383, checked in by ak19, 11 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.
|
File size:
1.8 KB
|
Line | |
---|
1 | @echo off
|
---|
2 | setlocal enabledelayedexpansion
|
---|
3 |
|
---|
4 | :: Check for 3 cmd line args
|
---|
5 | if [%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
|
---|
14 | set xsd=%1
|
---|
15 | set mds=%2
|
---|
16 |
|
---|
17 | if not exist %xsd% echo XSD file %xsd% does not exist.& goto exit
|
---|
18 |
|
---|
19 |
|
---|
20 | if "%GSDLHOME%" == "" echo No GSDLHOME set. Source the (gs3-)setup.bat file in your Greenstone before running this script.& goto exit
|
---|
21 |
|
---|
22 |
|
---|
23 | set outputdir=
|
---|
24 | if not "%GSDL3SRCHOME%" == "" (
|
---|
25 | set outputdir=%GSDL3SRCHOME%
|
---|
26 | ) else (
|
---|
27 | set outputdir=%GSDLHOME%
|
---|
28 | )
|
---|
29 | set outputfile=%outputdir%\gli\metadata\%mds%.mds
|
---|
30 | set xsl=%outputdir%\gli\classes\xml\xsd-to-mds.xsl
|
---|
31 |
|
---|
32 | if 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
|
---|
35 | 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%"
|
---|
36 |
|
---|
37 | :: Call the command
|
---|
38 | %xcmd%
|
---|
39 |
|
---|
40 | if not exist "%outputfile%" (
|
---|
41 | echo **** XSLT transform failed: the file %outputfile% was not generated. Ran command:
|
---|
42 | echo %xcmd%
|
---|
43 | ) else (
|
---|
44 | echo The file %outputfile% has been generated.
|
---|
45 | )
|
---|
46 |
|
---|
47 | goto exit
|
---|
48 |
|
---|
49 | :usage
|
---|
50 | echo.
|
---|
51 | echo Run as %0 ^<xsd file^> ^<namespace^> ^<setname (mds file name)^>
|
---|
52 | echo.
|
---|
53 | :: E.g. xsd_to_mds.bat C:\<full-path>\CDWALite-xsd-public-v1-1.xsd cdwalite CDWALite
|
---|
54 |
|
---|
55 | :exit
|
---|
56 |
|
---|
57 | endlocal |
---|
Note:
See
TracBrowser
for help on using the repository browser.