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