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
|
Rev | Line | |
---|
[28364] | 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 | set xsd=%1
|
---|
| 14 | set mds=%2
|
---|
| 15 |
|
---|
| 16 | if not exist %1 echo XSD file %1 does not exist.& goto exit
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | if "%GSDLHOME%" == "" echo No GSDLHOME set. Source the (gs3-)setup.bat file in your Greenstone before running this script.& goto exit
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | set outputdir=
|
---|
| 23 | if not "%GSDL3SRCHOME%" == "" (
|
---|
| 24 | set outputdir=%GSDL3SRCHOME%
|
---|
| 25 | ) else (
|
---|
| 26 | set outputdir=%GSDLHOME%
|
---|
| 27 | )
|
---|
| 28 | set outputfile=%outputdir%\gli\metadata\%mds%.mds
|
---|
| 29 | set 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
|
---|
| 32 | 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%"
|
---|
| 33 |
|
---|
| 34 | :: Call the command
|
---|
| 35 | %xcmd%
|
---|
| 36 |
|
---|
| 37 | if not exist "%outputfile%" (
|
---|
| 38 | echo **** XSLT transform failed: the file %outputfile% was not generated. Ran command:
|
---|
| 39 | echo %xcmd%
|
---|
| 40 | ) else (
|
---|
| 41 | echo The file %outputfile% has been generated.
|
---|
| 42 | )
|
---|
| 43 |
|
---|
| 44 | goto exit
|
---|
| 45 |
|
---|
| 46 | :usage
|
---|
| 47 | echo 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 |
|
---|
| 52 | endlocal |
---|
Note:
See
TracBrowser
for help on using the repository browser.