1 | /*
|
---|
2 | *************************************************************************************
|
---|
3 | *
|
---|
4 | * DocBook Framework for OS/2 and eComStation
|
---|
5 | * Convert DocBook to HTML
|
---|
6 | *
|
---|
7 | * More info on the web:
|
---|
8 | * http://www.kacer.biz/os2/docbook-framework/
|
---|
9 | *
|
---|
10 | * Author:
|
---|
11 | * Jarda Kacer <mailto:jarda@kacer.biz>
|
---|
12 | *
|
---|
13 | *************************************************************************************
|
---|
14 | *
|
---|
15 | * This script converts a DocBook document into a single HTML file.
|
---|
16 | *
|
---|
17 | *************************************************************************************
|
---|
18 | *
|
---|
19 | * $Author: jkacer $
|
---|
20 | * $Revision: 2 $
|
---|
21 | * $Date: 2007-09-05 20:07:46 +0000 (Wed, 05 Sep 2007) $
|
---|
22 | * $HeadURL: trunk/Distribution/Scripts/DB2HTML.CMD $
|
---|
23 | *
|
---|
24 | *************************************************************************************
|
---|
25 | */
|
---|
26 |
|
---|
27 | OuterEnv = SetLocal()
|
---|
28 |
|
---|
29 | CALL RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
|
---|
30 | CALL SysLoadFuncs
|
---|
31 |
|
---|
32 | ScriptDir = GetScriptPath()
|
---|
33 | RootDir = GetParentDirectory(ScriptDir)
|
---|
34 |
|
---|
35 | Arguments = ARG(1)
|
---|
36 |
|
---|
37 | IF WORDS(Arguments) = 1
|
---|
38 | THEN DO
|
---|
39 | InputFile = WORD(Arguments, 1)
|
---|
40 | OutputFile = SUBSTR(InputFile, 1, LASTPOS(".", InputFile)-1) || ".HTML"
|
---|
41 | CALL Saxon "-o " || OutputFile || " " || InputFile || " " || RootDir || "\XSL\html\docbook.xsl use.extensions=1"
|
---|
42 | END
|
---|
43 | ELSE DO
|
---|
44 | CALL PrintUsage
|
---|
45 | END
|
---|
46 |
|
---|
47 | CALL EndLocal
|
---|
48 | EXIT
|
---|
49 |
|
---|
50 |
|
---|
51 | /***********************************************************************************************/
|
---|
52 | /* Procedures and functions */
|
---|
53 | /***********************************************************************************************/
|
---|
54 |
|
---|
55 |
|
---|
56 | /*
|
---|
57 | * Sets an environment variable or appends a value to it.
|
---|
58 | */
|
---|
59 | AddEnvironment: PROCEDURE
|
---|
60 | PARSE ARG VarName, VarValue
|
---|
61 | IF (Value(VarName, , "OS2ENVIRONMENT")="")
|
---|
62 | THEN CALL SetEnvironment VarName, VarValue
|
---|
63 | ELSE CALL Value VarName, GetEnvironment(VarName) || ";" || VarValue, "OS2ENVIRONMENT"
|
---|
64 | RETURN
|
---|
65 |
|
---|
66 |
|
---|
67 | /*
|
---|
68 | * Sets an environment variable, overwriting its previous value.
|
---|
69 | */
|
---|
70 | SetEnvironment: PROCEDURE
|
---|
71 | PARSE ARG VarName, VarValue
|
---|
72 | CALL Value VarName, VarValue, "OS2ENVIRONMENT"
|
---|
73 | RETURN
|
---|
74 |
|
---|
75 |
|
---|
76 | /*
|
---|
77 | * Returns the value of an environment variable.
|
---|
78 | */
|
---|
79 | GetEnvironment: PROCEDURE
|
---|
80 | PARSE ARG VarName
|
---|
81 | RETURN Value(VarName, , "OS2ENVIRONMENT")
|
---|
82 |
|
---|
83 |
|
---|
84 | /*
|
---|
85 | * Returns the current script name.
|
---|
86 | */
|
---|
87 | GetScriptName: PROCEDURE
|
---|
88 | PARSE SOURCE Result
|
---|
89 | RETURN WORD(Result, 3)
|
---|
90 |
|
---|
91 |
|
---|
92 | /*
|
---|
93 | * Returns the current script path, without "\" at the end.
|
---|
94 | */
|
---|
95 | GetScriptPath: PROCEDURE
|
---|
96 | ScriptName = GetScriptName()
|
---|
97 | RETURN SUBSTR(ScriptName, 1, LASTPOS("\", ScriptName)-1)
|
---|
98 |
|
---|
99 |
|
---|
100 | /*
|
---|
101 | * Returns True if the given file exists.
|
---|
102 | */
|
---|
103 | FileExists: PROCEDURE
|
---|
104 | PARSE ARG FileName
|
---|
105 | CALL SysFileTree FileName, Result
|
---|
106 | RETURN Result.0 > 0
|
---|
107 |
|
---|
108 |
|
---|
109 | /*
|
---|
110 | * Returns the current directory, without "\" at the end.
|
---|
111 | */
|
---|
112 | GetCurrentDir: PROCEDURE
|
---|
113 | RETURN DIRECTORY()
|
---|
114 |
|
---|
115 |
|
---|
116 | /*
|
---|
117 | * Returns the parent directory of the directory passed as argument, without "\" at the end.
|
---|
118 | */
|
---|
119 | GetParentDirectory: PROCEDURE
|
---|
120 | PARSE ARG DirName
|
---|
121 | RETURN SUBSTR(DirName, 1, LASTPOS("\", DirName)-1)
|
---|
122 |
|
---|
123 |
|
---|
124 | /*
|
---|
125 | * Prints out a short help on how to call this script.
|
---|
126 | */
|
---|
127 | PrintUsage: PROCEDURE
|
---|
128 | SAY "DocBook Framework for OS/2, DocBook --> HTML"
|
---|
129 | SAY "Usage: DB2HTML <DocBook Source>"
|
---|
130 | RETURN
|
---|
131 |
|
---|