Project

General

Profile

1
@echo off
2

    
3
::
4
:: '$Id: transform.bat 2823 2005-12-09 00:38:23Z brooke $' 
5
:: 
6
:: Matthew Brooke
7
:: 8 December 2005
8
:: 
9
:: Command-line XSLT 
10
:: 
11
:: Takes 3 command-line arguments: 
12
:: 1) an existing XML document, 
13
:: 2) an existing XSL document, and 
14
:: 3) an HTML document (existing or not) 
15
:: It then uses the XSL document to transform 
16
:: the XML into HTML. 
17
:: (Note that HTML is the common usage - however, 
18
:: many other types of output documents are supported, 
19
:: limited only buy the XSL stylesheet itself)
20
::
21
:: TROUBLESHOOTING:
22
::   
23
:: i) ASSUMES the existence of:
24
::              .\lib\xalan.jar, 
25
::              .\lib\xalan.jar\xercesImpl.jar, and 
26
::              .\lib\xalan.jar\xml-apis.jar
27
:: 
28
:: ii) Use absolute paths, not relative paths, for 
29
:: the XML, XSL and HTML files. Make sure file paths 
30
:: do NOT have spaces in them (eg - NOT like: c:\Program Files\)
31
::
32

    
33
IF NOT EXIST %1 GOTO USAGE
34
IF NOT EXIST %2 GOTO USAGE
35

    
36
SET LIB=.\lib
37

    
38
SET CPATH=%LIB%\xalan.jar;%LIB%\xercesImpl.jar;%LIB%\xml-apis.jar
39

    
40

    
41
:: transformer parameters that are usually set by the java 
42
:: code in morpho or in metacat. We have to pass them on the command line:
43

    
44
SET TPARAMS=-PARAM qformat knb -PARAM action read 
45

    
46
echo Transforming XML file %1 to HTML format, using XSL file %2...
47
echo (sending the following transform parameters to the parser)
48
echo %TPARAMS%
49
echo .
50

    
51
java -cp %CPATH% org.apache.xalan.xslt.Process %TPARAMS% -IN %1 -XSL %2 -OUT %3
52

    
53
echo "Done. Results are in file %3
54

    
55
GOTO END
56

    
57
:USAGE
58

    
59
echo .
60
echo . USAGE:
61
echo . transform.bat INPUTXMLFILE.xml   XSLFILE.xsl   OUTPUTHTMLFILE.html
62
echo . 
63
echo . Use absolute paths, not relative paths, 
64
echo . and ensure paths have no spaces in them
65
echo . 
66

    
67
:END
(2-2/4)