1 | <?xml version="1.0"?>
|
---|
2 | <!--
|
---|
3 | docbook-refentry-to-manual-sect1.xsl:
|
---|
4 | XSLT stylesheet for nicking the refsynopsisdiv bit of a
|
---|
5 | refentry (manpage) for use in the command overview section
|
---|
6 | in the user manual.
|
---|
7 |
|
---|
8 | Copyright (C) 2006-2015 Oracle Corporation
|
---|
9 |
|
---|
10 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | available from http://www.virtualbox.org. This file is free software;
|
---|
12 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | General Public License (GPL) as published by the Free Software
|
---|
14 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | -->
|
---|
18 |
|
---|
19 | <xsl:stylesheet
|
---|
20 | version="1.0"
|
---|
21 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
22 | xmlns:str="http://xsltsl.org/string"
|
---|
23 | >
|
---|
24 |
|
---|
25 | <xsl:import href="string.xsl"/>
|
---|
26 | <xsl:import href="common-formatcfg.xsl"/>
|
---|
27 |
|
---|
28 | <xsl:output method="text" version="1.0" encoding="utf-8" indent="yes"/>
|
---|
29 | <xsl:strip-space elements="*"/>
|
---|
30 |
|
---|
31 | <xsl:param name="g_fDebugText" select="0"/>
|
---|
32 |
|
---|
33 | <xsl:variable name="g_sUnderlineRefSect1">
|
---|
34 | <xsl:text>===================================================================================================================</xsl:text>
|
---|
35 | </xsl:variable>
|
---|
36 | <xsl:variable name="g_sUnderlineRefSect2">
|
---|
37 | <xsl:text>-------------------------------------------------------------------------------------------------------------------</xsl:text>
|
---|
38 | </xsl:variable>
|
---|
39 |
|
---|
40 | <!-- Sub-command style command (true) or single command (false). -->
|
---|
41 | <xsl:variable name="g_fSubCommands" select="not(not(//refsect2[@id]))" />
|
---|
42 |
|
---|
43 | <!-- Default action, do nothing. -->
|
---|
44 | <xsl:template match="node()|@*"/>
|
---|
45 |
|
---|
46 | <!--
|
---|
47 | main() - because we need to order the output in a specific manner
|
---|
48 | that is contrary to the data flow in the refentry, this is
|
---|
49 | going to look a bit more like a C program than a stylesheet.
|
---|
50 | -->
|
---|
51 | <xsl:template match="refentry">
|
---|
52 | <!-- Assert refetry expectations. -->
|
---|
53 | <xsl:if test="not(./refsynopsisdiv)">
|
---|
54 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refsynopsisdiv</xsl:message>
|
---|
55 | </xsl:if>
|
---|
56 | <xsl:if test="not(./refentryinfo/title)">
|
---|
57 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refentryinfo with title</xsl:message>
|
---|
58 | </xsl:if>
|
---|
59 | <xsl:if test="not(./refmeta/refentrytitle)">
|
---|
60 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refentryinfo with title</xsl:message>
|
---|
61 | </xsl:if>
|
---|
62 | <xsl:if test="./refmeta/refentrytitle != ./refnamediv/refname">
|
---|
63 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The refmeta/refentrytitle and the refnamediv/refname must be identical</xsl:message>
|
---|
64 | </xsl:if>
|
---|
65 | <xsl:if test="not(./refsect1/title)">
|
---|
66 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refsect1 with title</xsl:message>
|
---|
67 | </xsl:if>
|
---|
68 | <xsl:if test="not(@id) or @id = ''">
|
---|
69 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have an id attribute</xsl:message>
|
---|
70 | </xsl:if>
|
---|
71 |
|
---|
72 | <!-- variables -->
|
---|
73 | <xsl:variable name="sBaseId" select="@id"/>
|
---|
74 | <xsl:variable name="sDataBaseSym" select="concat('g_', translate(@id, '-', '_'))"/>
|
---|
75 |
|
---|
76 |
|
---|
77 | <!--
|
---|
78 | Convert the refsynopsisdiv into REFENTRY::Synopsis data.
|
---|
79 | -->
|
---|
80 | <xsl:text>
|
---|
81 |
|
---|
82 | static const RTMSGREFENTRYSTR </xsl:text><xsl:value-of select="$sDataBaseSym"/><xsl:text>_synopsis[] =
|
---|
83 | {</xsl:text>
|
---|
84 | <xsl:for-each select="./refsynopsisdiv/cmdsynopsis">
|
---|
85 | <!-- Assert synopsis expectations -->
|
---|
86 | <xsl:if test="not(@id) or substring-before(@id, '-') != 'synopsis'">
|
---|
87 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The refsynopsisdiv/cmdsynopsis elements must have an id starting with 'synopsis-'.</xsl:message>
|
---|
88 | </xsl:if>
|
---|
89 | <xsl:if test="not(starts-with(substring-after(@id, '-'), $sBaseId))">
|
---|
90 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The refsynopsisdiv/cmdsynopsis elements @id is expected to include the refentry @id.</xsl:message>
|
---|
91 | </xsl:if>
|
---|
92 | <xsl:if test="not(../../refsect1/refsect2[@id=./@id]) and $g_fSubCommands">
|
---|
93 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>No refsect2 with id="<xsl:value-of select="@id"/>" found.</xsl:message>
|
---|
94 | </xsl:if>
|
---|
95 |
|
---|
96 | <!-- Do the work. -->
|
---|
97 | <xsl:apply-templates select="."/>
|
---|
98 |
|
---|
99 | </xsl:for-each>
|
---|
100 | <xsl:text>
|
---|
101 | };</xsl:text>
|
---|
102 |
|
---|
103 |
|
---|
104 | <!--
|
---|
105 | Convert the whole manpage to help text.
|
---|
106 | -->
|
---|
107 | <xsl:text>
|
---|
108 | static const RTMSGREFENTRYSTR </xsl:text><xsl:value-of select="$sDataBaseSym"/><xsl:text>_full_help[] =
|
---|
109 | {</xsl:text>
|
---|
110 | <!-- We start by combining the refentry title and the refpurpose into a short description. -->
|
---|
111 | <xsl:text>
|
---|
112 | { </xsl:text><xsl:call-template name="calc-scope-for-refentry"/><xsl:text>,
|
---|
113 | "</xsl:text>
|
---|
114 | <xsl:apply-templates select="./refentryinfo/title/node()"/>
|
---|
115 | <xsl:text> -- </xsl:text>
|
---|
116 | <xsl:call-template name="capitalize">
|
---|
117 | <xsl:with-param name="text">
|
---|
118 | <xsl:apply-templates select="./refnamediv/refpurpose/node()"/>
|
---|
119 | </xsl:with-param>
|
---|
120 | </xsl:call-template>
|
---|
121 | <xsl:text>." },
|
---|
122 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
123 |
|
---|
124 | <!-- The follows the usage (synopsis) section. -->
|
---|
125 | <xsl:text>
|
---|
126 | { RTMSGREFENTRYSTR_SCOPE_GLOBAL,
|
---|
127 | "Usage" },
|
---|
128 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
129 | "=====" },</xsl:text>
|
---|
130 | <xsl:apply-templates select="./refsynopsisdiv/node()"/>
|
---|
131 |
|
---|
132 | <!-- Then comes the description and other refsect1 -->
|
---|
133 | <xsl:for-each select="./refsect1">
|
---|
134 | <xsl:if test="name(*[1]) != 'title'"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Expected title as the first element in refsect1.</xsl:message></xsl:if>
|
---|
135 | <xsl:if test="text()"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>No text supported in refsect1.</xsl:message></xsl:if>
|
---|
136 | <xsl:if test="not(./remark[@role='help-skip'])">
|
---|
137 | <xsl:variable name="sTitle">
|
---|
138 | <xsl:apply-templates select="./title/node()"/>
|
---|
139 | </xsl:variable>
|
---|
140 | <xsl:text>
|
---|
141 | { </xsl:text><xsl:call-template name="calc-scope-refsect1"/><xsl:text>, "" },
|
---|
142 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
143 | "</xsl:text><xsl:value-of select="$sTitle"/><xsl:text>" },
|
---|
144 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
145 | "</xsl:text>
|
---|
146 | <xsl:value-of select="substring($g_sUnderlineRefSect1, 1, string-length($sTitle))"/>
|
---|
147 | <xsl:text>" },</xsl:text>
|
---|
148 |
|
---|
149 | <xsl:apply-templates select="./*[name() != 'title']"/>
|
---|
150 |
|
---|
151 | <xsl:text>
|
---|
152 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
153 | </xsl:if>
|
---|
154 | </xsl:for-each>
|
---|
155 |
|
---|
156 | <xsl:text>
|
---|
157 | };</xsl:text>
|
---|
158 |
|
---|
159 | <!--
|
---|
160 | Generate the refentry structure.
|
---|
161 | -->
|
---|
162 | <xsl:text>
|
---|
163 | static const RTMSGREFENTRY </xsl:text><xsl:value-of select="$sDataBaseSym"/><xsl:text> =
|
---|
164 | {
|
---|
165 | /* .idInternal = */ HELP_CMD_</xsl:text>
|
---|
166 | <xsl:choose>
|
---|
167 | <xsl:when test="contains(@id, '-')">
|
---|
168 | <xsl:call-template name="str:to-upper"> <!-- Multi level command. -->
|
---|
169 | <xsl:with-param name="text" select="translate(substring-after(@id, '-'), '-', '_')"/>
|
---|
170 | </xsl:call-template>
|
---|
171 | </xsl:when>
|
---|
172 | <xsl:otherwise>
|
---|
173 | <xsl:call-template name="str:to-upper"> <!-- Simple command. -->
|
---|
174 | <xsl:with-param name="text" select="@id"/>
|
---|
175 | </xsl:call-template>
|
---|
176 | </xsl:otherwise>
|
---|
177 | </xsl:choose>
|
---|
178 | <xsl:text>,
|
---|
179 | /* .Synopsis = */ { RT_ELEMENTS(</xsl:text>
|
---|
180 | <xsl:value-of select="$sDataBaseSym"/><xsl:text>_synopsis), 0, </xsl:text>
|
---|
181 | <xsl:value-of select="$sDataBaseSym"/><xsl:text>_synopsis },
|
---|
182 | /* .Help = */ { RT_ELEMENTS(</xsl:text>
|
---|
183 | <xsl:value-of select="$sDataBaseSym"/><xsl:text>_full_help), 0, </xsl:text>
|
---|
184 | <xsl:value-of select="$sDataBaseSym"/><xsl:text>_full_help },
|
---|
185 | /* pszBrief = */ "</xsl:text>
|
---|
186 | <xsl:apply-templates select="./refnamediv/refpurpose/node()"/>
|
---|
187 | <!-- TODO: Add the command name too. -->
|
---|
188 | <xsl:text>"
|
---|
189 | };
|
---|
190 | </xsl:text>
|
---|
191 | </xsl:template>
|
---|
192 |
|
---|
193 |
|
---|
194 | <!--
|
---|
195 | Convert command synopsis to text.
|
---|
196 | -->
|
---|
197 | <xsl:template match="cmdsynopsis">
|
---|
198 | <xsl:if test="text()"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>cmdsynopsis with text is not supported.</xsl:message></xsl:if>
|
---|
199 | <xsl:if test="position() = 1">
|
---|
200 | <xsl:text>
|
---|
201 | { </xsl:text><xsl:call-template name="calc-scope-cmdsynopsis"/><xsl:text> | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS, "" }, </xsl:text>
|
---|
202 | </xsl:if>
|
---|
203 | <xsl:text>
|
---|
204 | { </xsl:text><xsl:call-template name="calc-scope-cmdsynopsis"/><xsl:text> | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS,
|
---|
205 | "</xsl:text><xsl:call-template name="emit-indentation"/><xsl:apply-templates select="*|@*"/><xsl:text>" },</xsl:text>
|
---|
206 | </xsl:template>
|
---|
207 |
|
---|
208 | <xsl:template match="sbr">
|
---|
209 | <xsl:text>" },
|
---|
210 | { RTMSGREFENTRYSTR_SCOPE_SAME | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS,
|
---|
211 | " </xsl:text><xsl:call-template name="emit-indentation"/> <!-- hardcoded in VBoxManageHelp.cpp too -->
|
---|
212 | </xsl:template>
|
---|
213 |
|
---|
214 | <xsl:template match="cmdsynopsis/command">
|
---|
215 | <xsl:text>" },
|
---|
216 | { RTMSGREFENTRYSTR_SCOPE_SAME | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS,
|
---|
217 | "</xsl:text><xsl:call-template name="emit-indentation"/>
|
---|
218 | <xsl:apply-templates select="node()|@*"/>
|
---|
219 | </xsl:template>
|
---|
220 |
|
---|
221 | <xsl:template match="cmdsynopsis/command[1]" priority="2">
|
---|
222 | <xsl:apply-templates select="node()|@*"/>
|
---|
223 | </xsl:template>
|
---|
224 |
|
---|
225 | <xsl:template match="command|option|computeroutput">
|
---|
226 | <xsl:apply-templates select="node()|@*"/>
|
---|
227 | </xsl:template>
|
---|
228 |
|
---|
229 | <xsl:template match="replaceable">
|
---|
230 | <xsl:choose>
|
---|
231 | <xsl:when test="ancestor::arg">
|
---|
232 | <xsl:apply-templates />
|
---|
233 | </xsl:when>
|
---|
234 | <xsl:otherwise>
|
---|
235 | <xsl:text><</xsl:text>
|
---|
236 | <xsl:apply-templates />
|
---|
237 | <xsl:text>></xsl:text>
|
---|
238 | </xsl:otherwise>
|
---|
239 | </xsl:choose>
|
---|
240 | </xsl:template>
|
---|
241 |
|
---|
242 | <!-- duplicated in docbook2latex.xsl -->
|
---|
243 | <xsl:template match="arg|group">
|
---|
244 | <!-- separator char if we're not the first child -->
|
---|
245 | <xsl:if test="position() > 1">
|
---|
246 | <xsl:choose>
|
---|
247 | <xsl:when test="parent::group"><xsl:value-of select="$arg.or.sep"/></xsl:when>
|
---|
248 | <xsl:when test="parent::arg and self::group"></xsl:when>
|
---|
249 | <xsl:when test="ancestor-or-self::*/@sepchar"><xsl:value-of select="ancestor-or-self::*/@sepchar"/></xsl:when>
|
---|
250 | <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
|
---|
251 | </xsl:choose>
|
---|
252 | </xsl:if>
|
---|
253 |
|
---|
254 | <!-- Make sure group choice and arg choice matches. -->
|
---|
255 | <xsl:if test="self::arg and ancestor::group">
|
---|
256 | <xsl:if test="@choice != ancestor::group/@choice and (@choice = 'opt' or @choice = '' or ancestor::group/@choice = 'opt' or ancestor::group/@choice = '')">
|
---|
257 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Mismatching group and arg choice: "<xsl:value-of select="@choice"/>" (arg) vs "<xsl:value-of select="ancestor::group/@choice"/>" (group)</xsl:message>
|
---|
258 | </xsl:if>
|
---|
259 | </xsl:if>
|
---|
260 |
|
---|
261 | <!-- open wrapping -->
|
---|
262 | <xsl:variable name="fWrappers" select="not(ancestor::group)"/>
|
---|
263 | <xsl:if test="$fWrappers">
|
---|
264 | <xsl:choose>
|
---|
265 | <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.open.str"/></xsl:when>
|
---|
266 | <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.open.str"/></xsl:when>
|
---|
267 | <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.open.str"/></xsl:when>
|
---|
268 | <xsl:when test="@choice = 'plain'"/>
|
---|
269 | <xsl:otherwise><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Invalid arg choice: "<xsl:value-of select="@choice"/>"</xsl:message></xsl:otherwise>
|
---|
270 | </xsl:choose>
|
---|
271 | </xsl:if>
|
---|
272 |
|
---|
273 | <!-- render the arg (TODO: may need to do more work here) -->
|
---|
274 | <xsl:apply-templates />
|
---|
275 |
|
---|
276 | <!-- repeat wrapping -->
|
---|
277 | <xsl:choose>
|
---|
278 | <xsl:when test="@rep = 'norepeat' or not(@rep) or @rep = ''"/>
|
---|
279 | <xsl:when test="@rep = 'repeat'"> <xsl:value-of select="$arg.rep.repeat.str"/></xsl:when>
|
---|
280 | <xsl:otherwise><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Invalid rep choice: "<xsl:value-of select="@rep"/>"</xsl:message></xsl:otherwise>
|
---|
281 | </xsl:choose>
|
---|
282 |
|
---|
283 | <!-- close wrapping -->
|
---|
284 | <xsl:if test="$fWrappers">
|
---|
285 | <xsl:choose>
|
---|
286 | <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.close.str"/></xsl:when>
|
---|
287 | <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.close.str"/></xsl:when>
|
---|
288 | <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.close.str"/></xsl:when>
|
---|
289 | </xsl:choose>
|
---|
290 | </xsl:if>
|
---|
291 | </xsl:template>
|
---|
292 |
|
---|
293 |
|
---|
294 | <!--
|
---|
295 | refsect2
|
---|
296 | -->
|
---|
297 | <xsl:template match="refsect2">
|
---|
298 | <!-- assertions -->
|
---|
299 | <xsl:if test="text()"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refsect2 shouldn't contain text</xsl:message></xsl:if>
|
---|
300 | <xsl:if test="count(./title) != 1"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refsect2 requires a title (<xsl:value-of select="ancestor-or-self::*[@id][1]/@id"/>)</xsl:message></xsl:if>
|
---|
301 |
|
---|
302 | <!-- title / command synopsis - sets the scope. -->
|
---|
303 | <xsl:variable name="sTitle">
|
---|
304 | <xsl:apply-templates select="./title/text()"/>
|
---|
305 | </xsl:variable>
|
---|
306 | <xsl:text>
|
---|
307 | { </xsl:text><xsl:call-template name="calc-scope-refsect2"/><xsl:text>, "" },
|
---|
308 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
309 | "</xsl:text><xsl:call-template name="emit-indentation"/>
|
---|
310 | <xsl:value-of select="$sTitle"/>
|
---|
311 | <xsl:text>" },
|
---|
312 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
313 | "</xsl:text><xsl:call-template name="emit-indentation"/>
|
---|
314 | <xsl:value-of select="substring($g_sUnderlineRefSect2, 1, string-length($sTitle))"/>
|
---|
315 | <xsl:text>" },</xsl:text>
|
---|
316 |
|
---|
317 | <!-- <xsl:if test="./*[name() != 'title']/following::
|
---|
318 | { RTMSGREFENTRYSTR_SCOPE_SAME, "y" },</xsl:text> cmdsynopsis -->
|
---|
319 |
|
---|
320 | <!-- Format the text in the section -->
|
---|
321 | <xsl:for-each select="./*[name() != 'title']">
|
---|
322 | <xsl:apply-templates select="."/>
|
---|
323 | </xsl:for-each>
|
---|
324 |
|
---|
325 | <!-- Add two blank lines, unless we're the last element in this refsect1. -->
|
---|
326 | <xsl:if test="position() != last()">
|
---|
327 | <xsl:text>
|
---|
328 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
329 | </xsl:if>
|
---|
330 | </xsl:template>
|
---|
331 |
|
---|
332 |
|
---|
333 | <!--
|
---|
334 | para
|
---|
335 | -->
|
---|
336 | <xsl:template match="para">
|
---|
337 | <xsl:if test="position() != 1 or not(parent::listitem)">
|
---|
338 | <xsl:text>
|
---|
339 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
340 | </xsl:if>
|
---|
341 | <xsl:call-template name="process-mixed"/>
|
---|
342 | </xsl:template>
|
---|
343 |
|
---|
344 |
|
---|
345 | <!--
|
---|
346 | variablelist
|
---|
347 | -->
|
---|
348 | <xsl:template match="variablelist">
|
---|
349 | <xsl:if test="*[not(self::varlistentry)]|text()">
|
---|
350 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Only varlistentry elements are supported in variablelist </xsl:message>
|
---|
351 | </xsl:if>
|
---|
352 | <xsl:for-each select="./varlistentry">
|
---|
353 | <xsl:if test="not(term) or not(listitem) or count(listitem) > 1">
|
---|
354 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Expected one or more term members and exactly one listentry member in varlistentry element.</xsl:message>
|
---|
355 | </xsl:if>
|
---|
356 | <xsl:if test="(not(@spacing) or @spacing != 'compact') and (position() > 1 or (count(../preceding-sibling::*) - count(../preceding-sibling::title) > 0))">
|
---|
357 | <xsl:text>
|
---|
358 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
359 | </xsl:if>
|
---|
360 | <xsl:apply-templates select="*"/>
|
---|
361 | </xsl:for-each>
|
---|
362 | </xsl:template>
|
---|
363 |
|
---|
364 | <xsl:template match="varlistentry/term">
|
---|
365 | <xsl:call-template name="process-mixed"/>
|
---|
366 | </xsl:template>
|
---|
367 |
|
---|
368 | <xsl:template match="varlistentry/listitem">
|
---|
369 | <xsl:call-template name="check-children">
|
---|
370 | <xsl:with-param name="UnsupportedNodes" select="*[not(self::para or self::itemizedlist or self::orderedlist or self::variablelist)]|text()"/>
|
---|
371 | <xsl:with-param name="SupportedNames">para, itemizedlist and orderedlist</xsl:with-param>
|
---|
372 | </xsl:call-template>
|
---|
373 |
|
---|
374 | <xsl:apply-templates select="*"/>
|
---|
375 | </xsl:template>
|
---|
376 |
|
---|
377 |
|
---|
378 | <!--
|
---|
379 | itemizedlist and orderedlist
|
---|
380 | -->
|
---|
381 | <xsl:template match="itemizedlist|orderedlist">
|
---|
382 | <xsl:if test="*[not(self::listitem)]|text()">
|
---|
383 | <xsl:message terminate="yes">
|
---|
384 | <xsl:call-template name="error-prefix"/>Only listitem elements are supported in <xsl:value-of select="name()"/>:
|
---|
385 | <xsl:call-template name="list-nodes">
|
---|
386 | <xsl:with-param name="Nodes" select="*[not(self::listitem)]|text()"/>
|
---|
387 | </xsl:call-template>
|
---|
388 | </xsl:message>
|
---|
389 | </xsl:if>
|
---|
390 | <xsl:if test="parent::para">
|
---|
391 | <xsl:message terminate="yes"><xsl:value-of select="name()"/> inside a para is current not supported. <!-- no newline
|
---|
392 | -->Close the para before the list, it makes no difference to html and latex/pdf output.</xsl:message>
|
---|
393 | </xsl:if>
|
---|
394 | <xsl:if test="position() != 1 and (not(@spacing) or @spacing != 'compact')">
|
---|
395 | <xsl:text>
|
---|
396 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
397 | </xsl:if>
|
---|
398 | <xsl:for-each select="./listitem">
|
---|
399 | <xsl:apply-templates select="*"/>
|
---|
400 | </xsl:for-each>
|
---|
401 | </xsl:template>
|
---|
402 |
|
---|
403 | <xsl:template match="itemizedlist/listitem|orderedlist/listitem">
|
---|
404 | <xsl:if test="*[not(self::para)]|text()">
|
---|
405 | <xsl:message terminate="yes">
|
---|
406 | <xsl:call-template name="error-prefix"/>Expected <xsl:value-of select="name()"/>/listitem to only contain para elements:
|
---|
407 | <xsl:call-template name="list-nodes">
|
---|
408 | <xsl:with-param name="Nodes" select="*[not(self::para)]|text()"/>
|
---|
409 | </xsl:call-template>
|
---|
410 | </xsl:message>
|
---|
411 | </xsl:if>
|
---|
412 |
|
---|
413 | <xsl:if test="position() != 1 and @spaceing != 'compact'">
|
---|
414 | <xsl:text>
|
---|
415 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
416 | </xsl:if>
|
---|
417 | <xsl:apply-templates select="*"/>
|
---|
418 | </xsl:template>
|
---|
419 |
|
---|
420 |
|
---|
421 | <!--
|
---|
422 | Screen
|
---|
423 | -->
|
---|
424 | <xsl:template match="screen">
|
---|
425 | <xsl:if test="ancestor::para">
|
---|
426 | <xsl:text>" },</xsl:text>
|
---|
427 | </xsl:if>
|
---|
428 |
|
---|
429 | <xsl:text>
|
---|
430 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
431 | "</xsl:text>
|
---|
432 |
|
---|
433 | <xsl:for-each select="node()">
|
---|
434 | <xsl:choose>
|
---|
435 | <xsl:when test="name() = ''">
|
---|
436 | <xsl:call-template name="screen_text_line">
|
---|
437 | <xsl:with-param name="sText" select="."/>
|
---|
438 | </xsl:call-template>
|
---|
439 | </xsl:when>
|
---|
440 | <xsl:otherwise>
|
---|
441 | <xsl:if test="*">
|
---|
442 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Support for elements under screen has not been implemented: <xsl:value-of select="name()"/></xsl:message>
|
---|
443 | </xsl:if>
|
---|
444 | </xsl:otherwise>
|
---|
445 | </xsl:choose>
|
---|
446 | </xsl:for-each>
|
---|
447 |
|
---|
448 | <xsl:if test="not(ancestor::para)">
|
---|
449 | <xsl:text>" },</xsl:text>
|
---|
450 | </xsl:if>
|
---|
451 | </xsl:template>
|
---|
452 |
|
---|
453 | <xsl:template name="screen_text_line">
|
---|
454 | <xsl:param name="sText"/>
|
---|
455 | <xsl:call-template name="escape_fixed_text">
|
---|
456 | <xsl:with-param name="sText" select="substring-before($sText,'
')"/>
|
---|
457 | </xsl:call-template>
|
---|
458 |
|
---|
459 | <xsl:if test="substring-after($sText,'
')">
|
---|
460 | <xsl:text>" },
|
---|
461 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
462 | "</xsl:text>
|
---|
463 | <xsl:call-template name="screen_text_line">
|
---|
464 | <xsl:with-param name="sText" select="substring-after($sText,'
')"/>
|
---|
465 | </xsl:call-template>
|
---|
466 | </xsl:if>
|
---|
467 | </xsl:template>
|
---|
468 |
|
---|
469 |
|
---|
470 | <!--
|
---|
471 | Text escaping for C.
|
---|
472 | -->
|
---|
473 | <xsl:template match="text()" name="escape_text">
|
---|
474 | <!-- Leading whitespace hack! -->
|
---|
475 | <xsl:if test="substring(.,1,1) = ' ' and position() != 1">
|
---|
476 | <xsl:text> </xsl:text>
|
---|
477 | <xsl:if test="boolean($g_fDebugText)">
|
---|
478 | <xsl:message>text: add space</xsl:message>
|
---|
479 | </xsl:if>
|
---|
480 | </xsl:if>
|
---|
481 |
|
---|
482 | <!-- Body of text -->
|
---|
483 | <xsl:choose>
|
---|
484 |
|
---|
485 | <xsl:when test="contains(., '\') or contains(., '"')">
|
---|
486 | <xsl:variable name="sTmp">
|
---|
487 | <xsl:call-template name="str:subst">
|
---|
488 | <xsl:with-param name="text" select="normalize-space(.)"/>
|
---|
489 | <xsl:with-param name="replace" select="'\'"/>
|
---|
490 | <xsl:with-param name="with" select="'\\'"/>
|
---|
491 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
492 | </xsl:call-template>
|
---|
493 | </xsl:variable>
|
---|
494 | <xsl:variable name="sTmp2">
|
---|
495 | <xsl:call-template name="str:subst">
|
---|
496 | <xsl:with-param name="text" select="$sTmp"/>
|
---|
497 | <xsl:with-param name="replace" select="'"'"/>
|
---|
498 | <xsl:with-param name="with" select="'\"'"/>
|
---|
499 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
500 | </xsl:call-template>
|
---|
501 | </xsl:variable>
|
---|
502 | <xsl:value-of select="$sTmp2"/>
|
---|
503 | <xsl:if test="boolean($g_fDebugText)">
|
---|
504 | <xsl:message>text: |<xsl:value-of select="$sTmp2"/>|</xsl:message>
|
---|
505 | </xsl:if>
|
---|
506 | </xsl:when>
|
---|
507 |
|
---|
508 | <xsl:otherwise>
|
---|
509 | <xsl:value-of select="normalize-space(.)"/>
|
---|
510 | <xsl:if test="boolean($g_fDebugText)">
|
---|
511 | <xsl:message>text: |<xsl:value-of select="normalize-space(.)"/>|</xsl:message>
|
---|
512 | </xsl:if>
|
---|
513 | </xsl:otherwise>
|
---|
514 | </xsl:choose>
|
---|
515 |
|
---|
516 | <!-- Trailing whitespace hack! -->
|
---|
517 | <xsl:if test="substring(.,string-length(.)) = ' ' and position() != last() and string-length(.) != 1">
|
---|
518 | <xsl:text> </xsl:text>
|
---|
519 | <xsl:if test="boolean($g_fDebugText)">
|
---|
520 | <xsl:message>text: add space</xsl:message>
|
---|
521 | </xsl:if>
|
---|
522 | </xsl:if>
|
---|
523 |
|
---|
524 | </xsl:template>
|
---|
525 |
|
---|
526 | <!-- Elements producing non-breaking strings (single line). -->
|
---|
527 | <xsl:template match="command/text()|option/text()|computeroutput/text()|arg/text()" name="escape_fixed_text">
|
---|
528 | <xsl:param name="sText" select="normalize-space(.)"/>
|
---|
529 | <xsl:choose>
|
---|
530 |
|
---|
531 | <xsl:when test="contains($sText, '\') or contains($sText, '"')">
|
---|
532 | <xsl:variable name="sTmp1">
|
---|
533 | <xsl:call-template name="str:subst">
|
---|
534 | <xsl:with-param name="text" select="$sText"/>
|
---|
535 | <xsl:with-param name="replace" select="'\'"/>
|
---|
536 | <xsl:with-param name="with" select="'\\'"/>
|
---|
537 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
538 | </xsl:call-template>
|
---|
539 | </xsl:variable>
|
---|
540 | <xsl:variable name="sTmp2">
|
---|
541 | <xsl:call-template name="str:subst">
|
---|
542 | <xsl:with-param name="text" select="$sTmp1"/>
|
---|
543 | <xsl:with-param name="replace" select="'"'"/>
|
---|
544 | <xsl:with-param name="with" select="'\"'"/>
|
---|
545 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
546 | </xsl:call-template>
|
---|
547 | </xsl:variable>
|
---|
548 | <xsl:variable name="sTmp3">
|
---|
549 | <xsl:call-template name="str:subst">
|
---|
550 | <xsl:with-param name="text" select="$sTmp2"/>
|
---|
551 | <xsl:with-param name="replace" select="' '"/>
|
---|
552 | <xsl:with-param name="with" select="'\b'"/>
|
---|
553 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
554 | </xsl:call-template>
|
---|
555 | </xsl:variable>
|
---|
556 | <xsl:value-of select="$sTmp3"/>
|
---|
557 | <xsl:if test="boolean($g_fDebugText)">
|
---|
558 | <xsl:message>text! |<xsl:value-of select="$sTmp3"/>|</xsl:message>
|
---|
559 | </xsl:if>
|
---|
560 | </xsl:when>
|
---|
561 |
|
---|
562 | <xsl:when test="contains($sText, ' ')">
|
---|
563 | <xsl:variable name="sTmp">
|
---|
564 | <xsl:call-template name="str:subst">
|
---|
565 | <xsl:with-param name="text" select="$sText"/>
|
---|
566 | <xsl:with-param name="replace" select="' '"/>
|
---|
567 | <xsl:with-param name="with" select="'\b'"/>
|
---|
568 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
569 | </xsl:call-template>
|
---|
570 | </xsl:variable>
|
---|
571 | <xsl:value-of select="$sTmp"/>
|
---|
572 | <xsl:if test="boolean($g_fDebugText)">
|
---|
573 | <xsl:message>text! |<xsl:value-of select="$sTmp"/>|</xsl:message>
|
---|
574 | </xsl:if>
|
---|
575 | </xsl:when>
|
---|
576 |
|
---|
577 | <xsl:otherwise>
|
---|
578 | <xsl:value-of select="$sText"/>
|
---|
579 | <xsl:if test="boolean($g_fDebugText)">
|
---|
580 | <xsl:message>text! |<xsl:value-of select="$sText"/>|</xsl:message>
|
---|
581 | </xsl:if>
|
---|
582 | </xsl:otherwise>
|
---|
583 | </xsl:choose>
|
---|
584 | </xsl:template>
|
---|
585 |
|
---|
586 |
|
---|
587 | <!--
|
---|
588 | Unsupported elements and elements handled directly.
|
---|
589 | -->
|
---|
590 | <xsl:template match="synopfragment|synopfragmentref|title|refsect1">
|
---|
591 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The <xsl:value-of select="name()"/> element is not supported</xsl:message>
|
---|
592 | </xsl:template>
|
---|
593 |
|
---|
594 | <!--
|
---|
595 | Fail on misplaced scoping remarks.
|
---|
596 | -->
|
---|
597 | <xsl:template match="remark[@role = 'help-scope']">
|
---|
598 | <xsl:choose>
|
---|
599 | <xsl:when test="parent::refsect1"/>
|
---|
600 | <xsl:when test="parent::refsect2"/>
|
---|
601 | <xsl:when test="parent::cmdsynopsis and ancestor::refsynopsisdiv"/>
|
---|
602 | <xsl:otherwise>
|
---|
603 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Misplaced remark/@role=help-scope element.
|
---|
604 | Only supported on: refsect1, refsect2, refsynopsisdiv/cmdsynopsis</xsl:message>
|
---|
605 | </xsl:otherwise>
|
---|
606 | </xsl:choose>
|
---|
607 | </xsl:template>
|
---|
608 |
|
---|
609 | <!--
|
---|
610 | Execute synopsis copy remark (avoids duplication for complicated xml).
|
---|
611 | -->
|
---|
612 | <xsl:template match="remark[@role = 'help-copy-synopsis']">
|
---|
613 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>remark/@role=help-copy-synopsis is not supported by this stylesheet. Must preprocess input!</xsl:message>
|
---|
614 | </xsl:template>
|
---|
615 |
|
---|
616 | <!--
|
---|
617 | Warn about unhandled elements
|
---|
618 | -->
|
---|
619 | <xsl:template match="*">
|
---|
620 | <xsl:message terminate="no">Warning: Unhandled element: <!-- no newline -->
|
---|
621 | <xsl:for-each select="ancestor-or-self::*">
|
---|
622 | <xsl:text>/</xsl:text>
|
---|
623 | <xsl:value-of select="name(.)"/>
|
---|
624 | <xsl:if test="@id">
|
---|
625 | <xsl:value-of select="concat('[id=', @id ,']')"/>
|
---|
626 | </xsl:if>
|
---|
627 | </xsl:for-each>
|
---|
628 | </xsl:message>
|
---|
629 | </xsl:template>
|
---|
630 |
|
---|
631 |
|
---|
632 | <!--
|
---|
633 | Functions
|
---|
634 | Functions
|
---|
635 | Functions
|
---|
636 | -->
|
---|
637 |
|
---|
638 | <!--
|
---|
639 | Processes mixed children, i.e. both text and regular elements.
|
---|
640 | Normalizes whitespace. -->
|
---|
641 | <xsl:template name="process-mixed">
|
---|
642 | <xsl:text>
|
---|
643 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
644 | "</xsl:text><xsl:call-template name="emit-indentation"/>
|
---|
645 |
|
---|
646 | <xsl:for-each select="node()[not(self::remark)]">
|
---|
647 | <xsl:choose>
|
---|
648 | <xsl:when test="name() = ''">
|
---|
649 | <xsl:call-template name="escape_text"/>
|
---|
650 | </xsl:when>
|
---|
651 | <xsl:otherwise>
|
---|
652 | <xsl:apply-templates select="."/>
|
---|
653 | </xsl:otherwise>
|
---|
654 | </xsl:choose>
|
---|
655 | </xsl:for-each>
|
---|
656 |
|
---|
657 | <xsl:text>" },</xsl:text>
|
---|
658 | </xsl:template>
|
---|
659 |
|
---|
660 |
|
---|
661 | <!--
|
---|
662 | Element specific scoping.
|
---|
663 | -->
|
---|
664 |
|
---|
665 | <xsl:template name="calc-scope-for-refentry">
|
---|
666 | <xsl:text>HELP_SCOPE_</xsl:text>
|
---|
667 | <xsl:choose>
|
---|
668 | <xsl:when test="contains(@id, '-')"> <!-- Multi level command. -->
|
---|
669 | <xsl:call-template name="str:to-upper">
|
---|
670 | <xsl:with-param name="text" select="translate(substring-after(@id, '-'), '-', '_')"/>
|
---|
671 | </xsl:call-template>
|
---|
672 | </xsl:when>
|
---|
673 | <xsl:otherwise> <!-- Single command. -->
|
---|
674 | <xsl:call-template name="str:to-upper">
|
---|
675 | <xsl:with-param name="text" select="@id"/>
|
---|
676 | </xsl:call-template>
|
---|
677 | </xsl:otherwise>
|
---|
678 | </xsl:choose>
|
---|
679 | </xsl:template>
|
---|
680 |
|
---|
681 | <!-- Figures out the scope of a refsect1 element. -->
|
---|
682 | <xsl:template name="calc-scope-refsect1">
|
---|
683 | <xsl:choose>
|
---|
684 | <xsl:when test="title[text() = 'Description']">
|
---|
685 | <xsl:text>RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
|
---|
686 | </xsl:when>
|
---|
687 | <xsl:when test="@id or remark[@role='help-scope']">
|
---|
688 | <xsl:call-template name="calc-scope-from-remark-or-id"/>
|
---|
689 | </xsl:when>
|
---|
690 | <xsl:otherwise>
|
---|
691 | <xsl:text>RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
|
---|
692 | </xsl:otherwise>
|
---|
693 | </xsl:choose>
|
---|
694 | </xsl:template>
|
---|
695 |
|
---|
696 | <!-- Figures out the scope of a refsect2 element. -->
|
---|
697 | <xsl:template name="calc-scope-refsect2">
|
---|
698 | <xsl:choose>
|
---|
699 | <xsl:when test="@id or remark[@role='help-scope']">
|
---|
700 | <xsl:call-template name="calc-scope-from-remark-or-id"/>
|
---|
701 | </xsl:when>
|
---|
702 | <xsl:otherwise>
|
---|
703 | <xsl:text>RTMSGREFENTRYSTR_SCOPE_SAME</xsl:text>
|
---|
704 | </xsl:otherwise>
|
---|
705 | </xsl:choose>
|
---|
706 | </xsl:template>
|
---|
707 |
|
---|
708 | <!-- Figures out the scope of a refsect1 element. -->
|
---|
709 | <xsl:template name="calc-scope-cmdsynopsis">
|
---|
710 | <xsl:choose>
|
---|
711 | <xsl:when test="ancestor::refsynopsisdiv">
|
---|
712 | <xsl:call-template name="calc-scope-from-remark-or-id">
|
---|
713 | <xsl:with-param name="sId" select="substring-after(@id, '-')"/>
|
---|
714 | </xsl:call-template>
|
---|
715 | </xsl:when>
|
---|
716 | <xsl:otherwise>
|
---|
717 | <xsl:text>RTMSGREFENTRYSTR_SCOPE_SAME</xsl:text>
|
---|
718 | </xsl:otherwise>
|
---|
719 | </xsl:choose>
|
---|
720 | </xsl:template>
|
---|
721 |
|
---|
722 |
|
---|
723 | <!--
|
---|
724 | Scoping worker functions.
|
---|
725 | -->
|
---|
726 |
|
---|
727 | <!-- Calculates the current scope from the scope remark or @id. -->
|
---|
728 | <xsl:template name="calc-scope-from-remark-or-id">
|
---|
729 | <xsl:param name="sId" select="@id"/>
|
---|
730 | <xsl:choose>
|
---|
731 | <xsl:when test="remark[@role='help-scope']">
|
---|
732 | <xsl:call-template name="calc-scope-consts-from-remark"/>
|
---|
733 | </xsl:when>
|
---|
734 | <xsl:when test="$sId != ''">
|
---|
735 | <xsl:call-template name="calc-scope-const-from-id">
|
---|
736 | <xsl:with-param name="sId" select="$sId"/>
|
---|
737 | </xsl:call-template>
|
---|
738 | </xsl:when>
|
---|
739 | <xsl:otherwise>
|
---|
740 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>expected remark child or id attribute.</xsl:message>
|
---|
741 | </xsl:otherwise>
|
---|
742 | </xsl:choose>
|
---|
743 | </xsl:template>
|
---|
744 |
|
---|
745 | <!-- Turns a @id into a scope constant.
|
---|
746 | Some woodoo taking place here here that chops the everything up to and
|
---|
747 | including the first refentry/@id word from all IDs before turning them into
|
---|
748 | constants (word delimiter '-'). -->
|
---|
749 | <xsl:template name="calc-scope-const-from-id">
|
---|
750 | <xsl:param name="sId" select="@id"/>
|
---|
751 | <xsl:param name="sAncestorId" select="ancestor::refentry/@id"/>
|
---|
752 | <xsl:text>HELP_SCOPE_</xsl:text>
|
---|
753 | <xsl:choose>
|
---|
754 | <xsl:when test="not($sAncestorId)"> <!-- Sanity check. -->
|
---|
755 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>calc-scope-const-from-id is invoked without an refentry ancestor with a id. <xsl:call-template name="get-node-path"/> </xsl:message>
|
---|
756 | </xsl:when>
|
---|
757 |
|
---|
758 | <xsl:when test="contains($sAncestorId, '-')"> <!-- Multi level command. -->
|
---|
759 | <xsl:variable name="sPrefix" select="concat(substring-before($sAncestorId, '-'), '-')"/>
|
---|
760 | <xsl:if test="not(contains($sId, $sPrefix))">
|
---|
761 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Expected sId (<xsl:value-of select="$sId"/>) to contain <xsl:value-of select="$sPrefix"/></xsl:message>
|
---|
762 | </xsl:if>
|
---|
763 | <xsl:call-template name="str:to-upper">
|
---|
764 | <xsl:with-param name="text" select="translate(substring-after($sId, $sPrefix), '-', '_')"/>
|
---|
765 | </xsl:call-template>
|
---|
766 | </xsl:when>
|
---|
767 |
|
---|
768 | <xsl:otherwise> <!-- Single command. -->
|
---|
769 | <xsl:call-template name="str:to-upper">
|
---|
770 | <xsl:with-param name="text" select="translate($sId, '-', '_')"/>
|
---|
771 | </xsl:call-template>
|
---|
772 | </xsl:otherwise>
|
---|
773 | </xsl:choose>
|
---|
774 | </xsl:template>
|
---|
775 |
|
---|
776 | <!-- Turns a remark into one or more scope constants. -->
|
---|
777 | <xsl:template name="calc-scope-consts-from-remark">
|
---|
778 | <xsl:param name="sCondition" select="remark/@condition"/>
|
---|
779 | <xsl:variable name="sNormalized" select="concat(normalize-space(translate($sCondition, ',;:|', ' ')), ' ')"/>
|
---|
780 | <xsl:if test="$sNormalized = ' ' or $sNormalized = ''">
|
---|
781 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Empty @condition for help-scope remark.</xsl:message>
|
---|
782 | </xsl:if>
|
---|
783 | <xsl:choose>
|
---|
784 | <xsl:when test="substring-before($sNormalized, ' ') = 'GLOBAL'">
|
---|
785 | <xsl:text>RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
|
---|
786 | </xsl:when>
|
---|
787 | <xsl:otherwise>
|
---|
788 | <xsl:text>HELP_SCOPE_</xsl:text><xsl:value-of select="substring-before($sNormalized, ' ')"/>
|
---|
789 | </xsl:otherwise>
|
---|
790 | </xsl:choose>
|
---|
791 | <xsl:call-template name="calc-scope-const-from-remark-worker">
|
---|
792 | <xsl:with-param name="sList" select="substring-after($sNormalized, ' ')"/>
|
---|
793 | </xsl:call-template>
|
---|
794 | </xsl:template>
|
---|
795 |
|
---|
796 | <xsl:template name="calc-scope-const-from-remark-worker">
|
---|
797 | <xsl:param name="sList"/>
|
---|
798 | <xsl:if test="$sList != ''">
|
---|
799 | <xsl:choose>
|
---|
800 | <xsl:when test="substring-before($sList, ' ') = 'GLOBAL'">
|
---|
801 | <xsl:text>| RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
|
---|
802 | </xsl:when>
|
---|
803 | <xsl:otherwise>
|
---|
804 | <xsl:text> | HELP_SCOPE_</xsl:text><xsl:value-of select="substring-before($sList, ' ')"/>
|
---|
805 | </xsl:otherwise>
|
---|
806 | </xsl:choose>
|
---|
807 | <xsl:call-template name="calc-scope-const-from-remark-worker">
|
---|
808 | <xsl:with-param name="sList" select="substring-after($sList, ' ')"/>
|
---|
809 | </xsl:call-template>
|
---|
810 | </xsl:if>
|
---|
811 | </xsl:template>
|
---|
812 |
|
---|
813 |
|
---|
814 | <!--
|
---|
815 | Calculates and emits indentation list markup.
|
---|
816 | -->
|
---|
817 | <xsl:template name="emit-indentation">
|
---|
818 | <xsl:variable name="iDepth" select="count(ancestor-or-self::*)"/>
|
---|
819 | <xsl:for-each select="ancestor-or-self::*">
|
---|
820 | <xsl:choose>
|
---|
821 |
|
---|
822 | <xsl:when test="self::refsect1
|
---|
823 | | self::refsect2
|
---|
824 | | self::refsect3
|
---|
825 | | self::refsynopsisdiv">
|
---|
826 | <xsl:text> </xsl:text>
|
---|
827 | </xsl:when>
|
---|
828 |
|
---|
829 | <xsl:when test="self::term">
|
---|
830 | <!-- currently no indent. -->
|
---|
831 | </xsl:when>
|
---|
832 |
|
---|
833 | <!-- Evidence here (especially with orderedlist) that doing list by for-each
|
---|
834 | listitem in the template matching the list type would be easier... -->
|
---|
835 | <xsl:when test="self::listitem and parent::itemizedlist and (position() + 1) = $iDepth">
|
---|
836 | <xsl:text> - </xsl:text>
|
---|
837 | </xsl:when>
|
---|
838 |
|
---|
839 | <xsl:when test="self::listitem and parent::orderedlist and (position() + 1) = $iDepth">
|
---|
840 | <xsl:variable name="iNumber" select="count(preceding-sibling::listitem) + 1"/>
|
---|
841 | <xsl:if test="$iNumber <= 9">
|
---|
842 | <xsl:text> </xsl:text>
|
---|
843 | </xsl:if>
|
---|
844 | <xsl:value-of select="$iNumber"/>
|
---|
845 | <xsl:text>. </xsl:text>
|
---|
846 | </xsl:when>
|
---|
847 |
|
---|
848 | <xsl:when test="self::listitem">
|
---|
849 | <xsl:text> </xsl:text>
|
---|
850 | </xsl:when>
|
---|
851 |
|
---|
852 | </xsl:choose>
|
---|
853 | </xsl:for-each>
|
---|
854 | </xsl:template>
|
---|
855 |
|
---|
856 | <!--
|
---|
857 | Captializes the given text.
|
---|
858 | -->
|
---|
859 | <xsl:template name="capitalize">
|
---|
860 | <xsl:param name="text"/>
|
---|
861 | <xsl:call-template name="str:to-upper">
|
---|
862 | <xsl:with-param name="text" select="substring($text,1,1)"/>
|
---|
863 | </xsl:call-template>
|
---|
864 | <xsl:value-of select="substring($text,2)"/>
|
---|
865 | </xsl:template>
|
---|
866 |
|
---|
867 |
|
---|
868 | <!--
|
---|
869 | Debug/Diagnostics: Return the path to the specified node (by default the current).
|
---|
870 | -->
|
---|
871 | <xsl:template name="get-node-path">
|
---|
872 | <xsl:param name="Node" select="."/>
|
---|
873 | <xsl:for-each select="$Node">
|
---|
874 | <xsl:for-each select="ancestor-or-self::node()">
|
---|
875 | <xsl:choose>
|
---|
876 | <xsl:when test="name(.) = ''">
|
---|
877 | <xsl:text>text()</xsl:text>
|
---|
878 | </xsl:when>
|
---|
879 | <xsl:otherwise>
|
---|
880 | <xsl:value-of select="concat('/', name(.))"/>
|
---|
881 | <xsl:choose>
|
---|
882 | <xsl:when test="@id">
|
---|
883 | <xsl:text>[@id=</xsl:text>
|
---|
884 | <xsl:value-of select="@id"/>
|
---|
885 | <xsl:text>]</xsl:text>
|
---|
886 | </xsl:when>
|
---|
887 | <xsl:when test="position() > 1">
|
---|
888 | <xsl:text>[</xsl:text><xsl:value-of select="position()"/><xsl:text>]</xsl:text>
|
---|
889 | </xsl:when>
|
---|
890 | </xsl:choose>
|
---|
891 | </xsl:otherwise>
|
---|
892 | </xsl:choose>
|
---|
893 | </xsl:for-each>
|
---|
894 | </xsl:for-each>
|
---|
895 | </xsl:template>
|
---|
896 |
|
---|
897 | <!--
|
---|
898 | Debug/Diagnostics: Return error message prefix.
|
---|
899 | -->
|
---|
900 | <xsl:template name="error-prefix">
|
---|
901 | <xsl:param name="Node" select="."/>
|
---|
902 | <xsl:text>error: </xsl:text>
|
---|
903 | <xsl:call-template name="get-node-path">
|
---|
904 | <xsl:with-param name="Node" select="$Node"/>
|
---|
905 | </xsl:call-template>
|
---|
906 | <xsl:text>: </xsl:text>
|
---|
907 | </xsl:template>
|
---|
908 |
|
---|
909 | <!--
|
---|
910 | Debug/Diagnostics: Print list of nodes (by default all children of current node).
|
---|
911 | -->
|
---|
912 | <xsl:template name="list-nodes">
|
---|
913 | <xsl:param name="Nodes" select="node()"/>
|
---|
914 | <xsl:for-each select="$Nodes">
|
---|
915 | <xsl:if test="position() != 1">
|
---|
916 | <xsl:text>, </xsl:text>
|
---|
917 | </xsl:if>
|
---|
918 | <xsl:choose>
|
---|
919 | <xsl:when test="name(.) = ''">
|
---|
920 | <xsl:text>text:text()</xsl:text>
|
---|
921 | </xsl:when>
|
---|
922 | <xsl:otherwise>
|
---|
923 | <xsl:value-of select="name(.)"/>
|
---|
924 | <xsl:if test="@id">
|
---|
925 | <xsl:text>[@id=</xsl:text>
|
---|
926 | <xsl:value-of select="@id"/>
|
---|
927 | <xsl:text>]</xsl:text>
|
---|
928 | </xsl:if>
|
---|
929 | </xsl:otherwise>
|
---|
930 | </xsl:choose>
|
---|
931 | </xsl:for-each>
|
---|
932 | </xsl:template>
|
---|
933 |
|
---|
934 | <xsl:template name="check-children">
|
---|
935 | <xsl:param name="Node" select="."/>
|
---|
936 | <xsl:param name="UnsupportedNodes" select="*"/>
|
---|
937 | <xsl:param name="SupportedNames" select="'none'"/>
|
---|
938 | <xsl:if test="count($UnsupportedNodes) != 0">
|
---|
939 | <xsl:message terminate="yes">
|
---|
940 | <xsl:call-template name="get-node-path">
|
---|
941 | <xsl:with-param name="Node" select="$Node"/>
|
---|
942 | </xsl:call-template>
|
---|
943 | <!-- -->: error: Only <xsl:value-of select="$SupportedNames"/> are supported as children to <!-- -->
|
---|
944 | <xsl:value-of select="name($Node)"/>
|
---|
945 | <!-- -->
|
---|
946 | Unsupported children: <!-- -->
|
---|
947 | <xsl:call-template name="list-nodes">
|
---|
948 | <xsl:with-param name="Nodes" select="$UnsupportedNodes"/>
|
---|
949 | </xsl:call-template>
|
---|
950 | </xsl:message>
|
---|
951 | </xsl:if>
|
---|
952 | </xsl:template>
|
---|
953 |
|
---|
954 | </xsl:stylesheet>
|
---|
955 |
|
---|