VirtualBox

source: vbox/trunk/doc/manual/docbook-refentry-to-C-help.xsl

Last change on this file was 99513, checked in by vboxsync, 12 months ago

manual,VBoxManage,isomaker/viso: Require all refsect1 and refsect2 elements to have @id attributes in manpages (refentry) to make these predictable and the split up topic files easier to handle for the docs team. Also requires these @id values to start with the refentry @id + '-'. Corrected a few bogus ones. Because 'controlvm' has too many sub-commands, HELP_SCOPE_ IDs will not be generated for 'See Also' and 'Examples' sections. bugref:10302

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /branches/VBox-3.0/doc/manual/docbook-refentry-to-manual-overview.xsl58652,​70973
    /branches/VBox-3.2/doc/manual/docbook-refentry-to-manual-overview.xsl66309,​66318
    /branches/VBox-4.0/doc/manual/docbook-refentry-to-manual-overview.xsl70873
    /branches/VBox-4.1/doc/manual/docbook-refentry-to-manual-overview.xsl74233,​78414,​78691,​82579,​85941,​85944-85947,​85949-85950,​85953,​86701,​86728,​87009
    /branches/VBox-4.2/doc/manual/docbook-refentry-to-manual-overview.xsl82653,​86229-86230,​86234,​86529,​91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/doc/manual/docbook-refentry-to-manual-overview.xsl91223,​94066,​94839,​94897,​95154,​95164,​95167,​95295,​95338,​95353-95354,​95356,​95367,​95451,​95475,​95477,​95480,​95507,​95640,​95659,​95661,​95663,​98913-98915,​99358
    /branches/VBox-4.3/trunk/doc/manual/docbook-refentry-to-manual-overview.xsl91223
    /branches/andy/draganddrop/doc/manual/docbook-refentry-to-manual-overview.xsl90781-91268
    /branches/andy/guestctrl20/doc/manual/docbook-refentry-to-manual-overview.xsl78916,​78930
    /branches/andy/pdmaudio/doc/manual/docbook-refentry-to-manual-overview.xsl94582,​94641,​94654,​94688,​94778,​94783,​94816,​95197,​95215-95216,​95250,​95279,​95505-95506,​95543,​95694,​96323,​96470-96471,​96582,​96587,​96802-96803,​96817,​96904,​96967,​96999,​97020-97021,​97025,​97050,​97099
    /branches/bird/hardenedwindows/doc/manual/docbook-refentry-to-manual-overview.xsl92692-94610
    /branches/dsen/gui/doc/manual/docbook-refentry-to-manual-overview.xsl79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/doc/manual/docbook-refentry-to-manual-overview.xsl79224,​79228,​79233,​79235,​79258,​79262-79263,​79273,​79341,​79345,​79354,​79357,​79387-79388,​79559-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/doc/manual/docbook-refentry-to-manual-overview.xsl79645-79692
    /trunk/src/doc/manual/docbook-refentry-to-manual-overview.xsl92342
File size: 39.8 KB
Line 
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<!--
9 Copyright (C) 2006-2023 Oracle and/or its affiliates.
10
11 This file is part of VirtualBox base platform packages, as
12 available from https://www.virtualbox.org.
13
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License
16 as published by the Free Software Foundation, in version 3 of the
17 License.
18
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, see <https://www.gnu.org/licenses>.
26
27 SPDX-License-Identifier: GPL-3.0-only
28-->
29
30<xsl:stylesheet
31 version="1.0"
32 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
33 xmlns:str="http://xsltsl.org/string"
34 >
35
36 <xsl:import href="string.xsl"/>
37 <xsl:import href="common-formatcfg.xsl"/>
38
39 <xsl:output method="text" version="1.0" encoding="utf-8" indent="yes"/>
40 <xsl:strip-space elements="*"/>
41
42 <xsl:param name="g_fDebugText" select="0"/>
43
44 <xsl:variable name="g_sUnderlineRefSect1">
45 <xsl:text>===================================================================================================================</xsl:text>
46 </xsl:variable>
47 <xsl:variable name="g_sUnderlineRefSect2">
48 <xsl:text>-------------------------------------------------------------------------------------------------------------------</xsl:text>
49 </xsl:variable>
50 <xsl:variable name="g_sNewLine"><xsl:value-of select="'&#10;'" /></xsl:variable>
51
52 <!-- Sub-command style command (true) or single command (false). -->
53 <xsl:variable name="g_fSubCommands" select="not(not(//refsect2[@id]))" />
54
55 <!-- Translatable strings -->
56 <xsl:variable name="sUsage" select="'Usage'"/>
57 <xsl:variable name="sUsageUnderscore" select="'====='"/>
58
59
60 <!-- Default action, do nothing. -->
61 <xsl:template match="node()|@*"/>
62
63 <!--
64 main() - because we need to order the output in a specific manner
65 that is contrary to the data flow in the refentry, this is
66 going to look a bit more like a C program than a stylesheet.
67 -->
68 <xsl:template match="refentry">
69 <!-- Assert refetry expectations. -->
70 <xsl:if test="not(./refsynopsisdiv)">
71 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refsynopsisdiv</xsl:message>
72 </xsl:if>
73 <xsl:if test="not(./refentryinfo/title)">
74 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refentryinfo with title</xsl:message>
75 </xsl:if>
76 <xsl:if test="not(./refmeta/refentrytitle)">
77 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refentryinfo with title</xsl:message>
78 </xsl:if>
79 <xsl:if test="./refmeta/refentrytitle != ./refnamediv/refname">
80 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The refmeta/refentrytitle and the refnamediv/refname must be identical</xsl:message>
81 </xsl:if>
82 <xsl:if test="not(./refsect1/title)">
83 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refsect1 with title</xsl:message>
84 </xsl:if>
85 <xsl:if test="not(@id) or @id = ''">
86 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have an id attribute</xsl:message>
87 </xsl:if>
88
89 <!-- variables -->
90 <xsl:variable name="sBaseId" select="@id"/>
91 <xsl:variable name="sDataBaseSym" select="concat('g_', translate(@id, '-', '_'))"/>
92
93
94 <!--
95 Convert the refsynopsisdiv into REFENTRY::Synopsis data.
96 -->
97 <xsl:text>
98
99static const RTMSGREFENTRYSTR </xsl:text><xsl:value-of select="$sDataBaseSym"/><xsl:text>_synopsis[] =
100{</xsl:text>
101 <xsl:for-each select="./refsynopsisdiv/cmdsynopsis">
102 <!-- Assert synopsis expectations -->
103 <xsl:if test="not(@id) or substring-before(@id, '-') != 'synopsis'">
104 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The refsynopsisdiv/cmdsynopsis elements must have an id starting with 'synopsis-'.</xsl:message>
105 </xsl:if>
106 <xsl:if test="not(starts-with(substring-after(@id, '-'), $sBaseId))">
107 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The refsynopsisdiv/cmdsynopsis elements @id is expected to include the refentry @id.</xsl:message>
108 </xsl:if>
109 <xsl:if test="not(../../refsect1/refsect2[@id=./@id]) and $g_fSubCommands">
110 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>No refsect2 with id="<xsl:value-of select="@id"/>" found.</xsl:message>
111 </xsl:if>
112
113 <!-- Do the work. -->
114 <xsl:apply-templates select="."/>
115
116 </xsl:for-each>
117 <xsl:text>
118};</xsl:text>
119
120
121 <!--
122 Convert the whole manpage to help text.
123 -->
124 <xsl:text>
125static const RTMSGREFENTRYSTR </xsl:text><xsl:value-of select="$sDataBaseSym"/><xsl:text>_full_help[] =
126{</xsl:text>
127 <!-- We start by combining the refentry title and the refpurpose into a short description. -->
128 <xsl:text>
129 { </xsl:text><xsl:call-template name="calc-scope-for-refentry"/><xsl:text>,
130 "</xsl:text>
131 <xsl:apply-templates select="./refentryinfo/title/node()"/>
132 <xsl:text> -- </xsl:text>
133 <xsl:call-template name="capitalize">
134 <xsl:with-param name="text">
135 <xsl:apply-templates select="./refnamediv/refpurpose/node()"/>
136 </xsl:with-param>
137 </xsl:call-template>
138 <xsl:text>." },
139 { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
140
141 <!-- The follows the usage (synopsis) section. -->
142 <xsl:text>
143 { RTMSGREFENTRYSTR_SCOPE_GLOBAL,
144 "</xsl:text><xsl:value-of select="$sUsage"/><xsl:text>" },
145 { RTMSGREFENTRYSTR_SCOPE_SAME,
146 "</xsl:text><xsl:value-of select="$sUsageUnderscore"/><xsl:text>" },</xsl:text>
147 <xsl:apply-templates select="./refsynopsisdiv/node()"/>
148
149 <!-- Then comes the description and other refsect1 -->
150 <xsl:for-each select="./refsect1">
151 <!-- assertions -->
152 <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>
153 <xsl:if test="text()"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>No text supported in refsect1.</xsl:message></xsl:if>
154 <xsl:if test="not(@id)"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refsect1 must have an @id attribute.</xsl:message></xsl:if>
155 <xsl:if test="not(starts-with(@id, concat(../@id, '-')))"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Wrong @id refsect1 prefix: '<xsl:value-of select="@id"/>', expected it to start with '<xsl:value-of select="../@id"/>-'</xsl:message></xsl:if>
156
157 <!-- .... -->
158 <xsl:if test="not(./remark[@role='help-skip'])">
159 <xsl:variable name="sTitle">
160 <xsl:apply-templates select="./title/node()"/>
161 </xsl:variable>
162 <xsl:text>
163 { </xsl:text><xsl:call-template name="calc-scope-refsect1"/><xsl:text>, "" },
164 { RTMSGREFENTRYSTR_SCOPE_SAME,
165 "</xsl:text><xsl:value-of select="$sTitle"/><xsl:text>" },
166 { RTMSGREFENTRYSTR_SCOPE_SAME,
167 "</xsl:text>
168 <xsl:value-of select="substring($g_sUnderlineRefSect1, 1, string-length($sTitle))"/>
169 <xsl:text>" },</xsl:text>
170
171 <xsl:apply-templates select="./*[name() != 'title']"/>
172
173 <xsl:text>
174 { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
175 </xsl:if>
176 </xsl:for-each>
177
178 <xsl:text>
179};</xsl:text>
180
181 <!--
182 Generate the refentry structure.
183 -->
184 <xsl:text>
185static const RTMSGREFENTRY </xsl:text><xsl:value-of select="$sDataBaseSym"/><xsl:text> =
186{
187 /* .idInternal = */ HELP_CMD_</xsl:text>
188 <xsl:choose>
189 <xsl:when test="contains(@id, '-')">
190 <xsl:call-template name="str:to-upper"> <!-- Multi level command. -->
191 <xsl:with-param name="text" select="translate(substring-after(@id, '-'), '-', '_')"/>
192 </xsl:call-template>
193 </xsl:when>
194 <xsl:otherwise>
195 <xsl:call-template name="str:to-upper"> <!-- Simple command. -->
196 <xsl:with-param name="text" select="@id"/>
197 </xsl:call-template>
198 </xsl:otherwise>
199 </xsl:choose>
200 <xsl:text>,
201 /* .Synopsis = */ { RT_ELEMENTS(</xsl:text>
202 <xsl:value-of select="$sDataBaseSym"/><xsl:text>_synopsis), 0, </xsl:text>
203 <xsl:value-of select="$sDataBaseSym"/><xsl:text>_synopsis },
204 /* .Help = */ { RT_ELEMENTS(</xsl:text>
205 <xsl:value-of select="$sDataBaseSym"/><xsl:text>_full_help), 0, </xsl:text>
206 <xsl:value-of select="$sDataBaseSym"/><xsl:text>_full_help },
207 /* pszBrief = */ "</xsl:text>
208 <xsl:apply-templates select="./refnamediv/refpurpose/node()"/>
209 <!-- TODO: Add the command name too. -->
210 <xsl:text>"
211};
212</xsl:text>
213 </xsl:template>
214
215
216 <!--
217 Convert command synopsis to text.
218 -->
219 <xsl:template match="cmdsynopsis">
220 <xsl:if test="text()"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>cmdsynopsis with text is not supported.</xsl:message></xsl:if>
221 <xsl:if test="position() = 1">
222 <xsl:text>
223 { </xsl:text><xsl:call-template name="calc-scope-cmdsynopsis"/><xsl:text> | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS, "" },</xsl:text>
224 </xsl:if>
225 <xsl:text>
226 { </xsl:text><xsl:call-template name="calc-scope-cmdsynopsis"/><xsl:text> | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS,
227 "</xsl:text><xsl:call-template name="emit-indentation"/><xsl:apply-templates select="*|@*"/><xsl:text>" },</xsl:text>
228 </xsl:template>
229
230 <xsl:template match="sbr">
231 <xsl:text>" },
232 { RTMSGREFENTRYSTR_SCOPE_SAME | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS,
233 " </xsl:text><xsl:call-template name="emit-indentation"/> <!-- hardcoded in VBoxManageHelp.cpp too -->
234 </xsl:template>
235
236 <xsl:template match="cmdsynopsis/command">
237 <xsl:text>" },
238 { RTMSGREFENTRYSTR_SCOPE_SAME | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS,
239 "</xsl:text><xsl:call-template name="emit-indentation"/>
240 <xsl:apply-templates select="node()|@*"/>
241 </xsl:template>
242
243 <xsl:template match="cmdsynopsis/command[1]" priority="2">
244 <xsl:apply-templates select="node()|@*"/>
245 </xsl:template>
246
247 <xsl:template match="command|option|computeroutput|literal|emphasis|filename|citetitle|note">
248 <xsl:apply-templates select="node()|@*"/>
249 </xsl:template>
250
251 <xsl:template match="ulink">
252 <xsl:value-of select="@url"/>
253 </xsl:template>
254
255 <xsl:template match="replaceable">
256 <xsl:choose>
257 <xsl:when test="ancestor::arg">
258 <xsl:apply-templates />
259 </xsl:when>
260 <xsl:otherwise>
261 <xsl:text>&lt;</xsl:text>
262 <xsl:apply-templates />
263 <xsl:text>&gt;</xsl:text>
264 </xsl:otherwise>
265 </xsl:choose>
266 </xsl:template>
267
268 <!-- duplicated in docbook2latex.xsl -->
269 <xsl:template match="arg|group">
270 <!-- separator char if we're not the first child -->
271 <xsl:if test="position() > 1">
272 <!--<xsl:value-of select="concat('*',name(),'=', position(),'#')"/>-->
273 <xsl:choose>
274 <xsl:when test="parent::group and ancestor::*[@role='compact']"><xsl:value-of select="$arg.or.sep.compact"/></xsl:when>
275 <xsl:when test="parent::group"><xsl:value-of select="$arg.or.sep"/></xsl:when>
276 <xsl:when test="ancestor::*[@role='compact']"></xsl:when>
277 <xsl:when test="ancestor::*/@sepchar"><xsl:value-of select="ancestor::*/@sepchar"/></xsl:when>
278 <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
279 </xsl:choose>
280 </xsl:if>
281
282 <!-- open wrapping -->
283 <xsl:variable name="fWrappers" select="not(ancestor::group)"/>
284 <xsl:if test="$fWrappers">
285 <xsl:choose>
286 <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.open.str"/></xsl:when>
287 <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.open.str"/></xsl:when>
288 <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.open.str"/></xsl:when>
289 <xsl:when test="@choice = 'plain'"/>
290 <xsl:otherwise><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Invalid arg choice: "<xsl:value-of select="@choice"/>"</xsl:message></xsl:otherwise>
291 </xsl:choose>
292 </xsl:if>
293
294 <!-- render the arg (TODO: may need to do more work here) -->
295 <xsl:apply-templates />
296
297 <!-- repeat wrapping -->
298 <xsl:choose>
299 <xsl:when test="@rep = 'norepeat' or not(@rep) or @rep = ''"/>
300 <xsl:when test="@rep = 'repeat'"> <xsl:value-of select="$arg.rep.repeat.str"/></xsl:when>
301 <xsl:otherwise><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Invalid rep choice: "<xsl:value-of select="@rep"/>"</xsl:message></xsl:otherwise>
302 </xsl:choose>
303
304 <!-- close wrapping -->
305 <xsl:if test="$fWrappers">
306 <xsl:choose>
307 <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.close.str"/></xsl:when>
308 <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.close.str"/></xsl:when>
309 <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.close.str"/></xsl:when>
310 </xsl:choose>
311 <!-- Add a space padding if we're the last element in a repeating arg or group -->
312 <!-- 2023-03-22 bird: This is incorrectly written. Fix as needed...
313 <xsl:if test="(parent::arg or parent::group) and not(following-sibiling) and not(ancestor::*[@role='compact'])">
314 <xsl:text> </xsl:text>
315 </xsl:if>
316 -->
317 </xsl:if>
318 </xsl:template>
319
320
321 <!--
322 refsect2
323 -->
324 <xsl:template match="refsect2">
325 <!-- assertions -->
326 <xsl:if test="text()"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refsect2 shouldn't contain text</xsl:message></xsl:if>
327 <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>
328 <xsl:if test="not(@id)"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refsect2 must have an @id attribute.</xsl:message></xsl:if>
329 <xsl:if test="not(starts-with(@id, concat(../../@id, '-')))"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Wrong @id refsect2 prefix: '<xsl:value-of select="@id"/>', expected it to start with '<xsl:value-of select="../../@id"/>-'</xsl:message></xsl:if>
330
331 <!-- title / command synopsis - sets the scope. -->
332 <xsl:variable name="sTitle">
333 <xsl:apply-templates select="./title/text()"/>
334 </xsl:variable>
335 <xsl:text>
336 { </xsl:text><xsl:call-template name="calc-scope-refsect2"/><xsl:text>, "" },
337 { RTMSGREFENTRYSTR_SCOPE_SAME,
338 "</xsl:text><xsl:call-template name="emit-indentation"/>
339 <xsl:value-of select="$sTitle"/>
340 <xsl:text>" },
341 { RTMSGREFENTRYSTR_SCOPE_SAME,
342 "</xsl:text><xsl:call-template name="emit-indentation"/>
343 <xsl:value-of select="substring($g_sUnderlineRefSect2, 1, string-length($sTitle))"/>
344 <xsl:text>" },</xsl:text>
345
346<!-- <xsl:if test="./*[name() != 'title']/following::
347 { RTMSGREFENTRYSTR_SCOPE_SAME, "y" },</xsl:text> cmdsynopsis -->
348
349 <!-- Format the text in the section -->
350 <xsl:for-each select="./*[name() != 'title']">
351 <xsl:apply-templates select="."/>
352 </xsl:for-each>
353
354 <!-- Add two blank lines, unless we're the last element in this refsect1. -->
355 <xsl:if test="position() != last()">
356 <xsl:text>
357 { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
358 </xsl:if>
359 </xsl:template>
360
361
362 <!--
363 para
364 -->
365 <xsl:template match="para">
366 <xsl:if test="position() != 1 or not(parent::listitem)">
367 <xsl:text>
368 { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
369 </xsl:if>
370 <xsl:call-template name="process-mixed"/>
371 </xsl:template>
372
373
374 <!--
375 variablelist
376 -->
377 <xsl:template match="variablelist">
378 <xsl:if test="*[not(self::varlistentry)]|text()">
379 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Only varlistentry elements are supported in variablelist </xsl:message>
380 </xsl:if>
381 <xsl:for-each select="./varlistentry">
382 <xsl:if test="not(term) or not(listitem) or count(listitem) > 1">
383 <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>
384 </xsl:if>
385 <xsl:if test="(not(@spacing) or @spacing != 'compact') and (position() > 1 or (count(../preceding-sibling::*) - count(../preceding-sibling::title) > 0))">
386 <xsl:text>
387 { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
388 </xsl:if>
389 <xsl:apply-templates select="*"/>
390 </xsl:for-each>
391 </xsl:template>
392
393 <xsl:template match="varlistentry/term">
394 <xsl:call-template name="process-mixed"/>
395 </xsl:template>
396
397 <xsl:template match="varlistentry/listitem">
398 <xsl:call-template name="check-children">
399 <xsl:with-param name="UnsupportedNodes" select="*[not(self::para or self::itemizedlist or self::orderedlist or self::variablelist or self::note)]|text()"/>
400 <xsl:with-param name="SupportedNames">para, itemizedlist, orderedlist and note</xsl:with-param>
401 </xsl:call-template>
402
403 <xsl:apply-templates select="*"/>
404 </xsl:template>
405
406
407 <!--
408 itemizedlist and orderedlist
409 -->
410 <xsl:template match="itemizedlist|orderedlist">
411 <xsl:if test="*[not(self::listitem)]|text()">
412 <xsl:message terminate="yes">
413 <xsl:call-template name="error-prefix"/>Only listitem elements are supported in <xsl:value-of select="name()"/>:
414 <xsl:call-template name="list-nodes">
415 <xsl:with-param name="Nodes" select="*[not(self::listitem)]|text()"/>
416 </xsl:call-template>
417 </xsl:message>
418 </xsl:if>
419 <xsl:if test="parent::para">
420 <xsl:message terminate="yes"><xsl:value-of select="name()"/> inside a para is current not supported. <!-- no newline
421 -->Close the para before the list, it makes no difference to html and latex/pdf output.</xsl:message>
422 </xsl:if>
423 <xsl:if test="position() != 1 and (not(@spacing) or @spacing != 'compact')">
424 <xsl:text>
425 { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
426 </xsl:if>
427 <xsl:for-each select="./listitem">
428 <xsl:apply-templates select="*"/>
429 </xsl:for-each>
430 </xsl:template>
431
432 <xsl:template match="itemizedlist/listitem|orderedlist/listitem">
433 <xsl:if test="*[not(self::para)]|text()">
434 <xsl:message terminate="yes">
435 <xsl:call-template name="error-prefix"/>Expected <xsl:value-of select="name()"/>/listitem to only contain para elements:
436 <xsl:call-template name="list-nodes">
437 <xsl:with-param name="Nodes" select="*[not(self::para)]|text()"/>
438 </xsl:call-template>
439 </xsl:message>
440 </xsl:if>
441
442 <xsl:if test="position() != 1 and @spaceing != 'compact'">
443 <xsl:text>
444 { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
445 </xsl:if>
446 <xsl:apply-templates select="*"/>
447 </xsl:template>
448
449
450 <!--
451 Screen
452 -->
453 <xsl:template match="screen">
454 <xsl:if test="ancestor::para">
455 <xsl:text>" },</xsl:text>
456 </xsl:if>
457
458 <xsl:text>
459 { RTMSGREFENTRYSTR_SCOPE_SAME,
460 "</xsl:text>
461
462 <xsl:for-each select="node()">
463 <xsl:choose>
464 <xsl:when test="name() = ''">
465 <xsl:call-template name="screen_text_line">
466 <xsl:with-param name="sText" select="."/>
467 </xsl:call-template>
468 </xsl:when>
469 <xsl:otherwise>
470 <xsl:if test="*">
471 <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>
472 </xsl:if>
473 </xsl:otherwise>
474 </xsl:choose>
475 </xsl:for-each>
476
477 <xsl:if test="not(ancestor::para)">
478 <xsl:text>" },</xsl:text>
479 </xsl:if>
480 </xsl:template>
481
482 <xsl:template name="screen_text_line">
483 <xsl:param name="sText"/>
484
485 <xsl:choose>
486 <xsl:when test="contains($sText, '&#x0a;')">
487 <xsl:call-template name="escape_fixed_text">
488 <xsl:with-param name="sText" select="substring-before($sText,'&#x0a;')"/>
489 </xsl:call-template>
490
491 <xsl:if test="substring-after($sText,'&#x0a;')">
492 <xsl:text>" },
493 { RTMSGREFENTRYSTR_SCOPE_SAME,
494 "</xsl:text>
495 <xsl:call-template name="screen_text_line">
496 <xsl:with-param name="sText" select="substring-after($sText,'&#x0a;')"/>
497 </xsl:call-template>
498 </xsl:if>
499 </xsl:when>
500
501 <xsl:otherwise> <!-- no newline, so use the whole string -->
502 <xsl:call-template name="escape_fixed_text">
503 <xsl:with-param name="sText" select="$sText"/>
504 </xsl:call-template>
505 </xsl:otherwise>
506 </xsl:choose>
507 </xsl:template>
508
509 <!-- Normalizes the current text node taking tailing and leading spaces
510 into account (unlike normalize-space which strips them mercilessly). -->
511 <xsl:template name="my-normalize-space-current">
512 <!-- <xsl:message>dbg0: position=<xsl:value-of select="position()"/> last=<xsl:value-of select="last()"/> .=|<xsl:value-of select="."/>|</xsl:message> -->
513 <xsl:if test="(starts-with(.,' ') or starts-with(., $g_sNewLine)) and position() != 1">
514 <xsl:value-of select="' '"/>
515 </xsl:if>
516 <xsl:value-of select="normalize-space(.)"/>
517 <xsl:if test="((substring(.,string-length(.)) = ' ') or (substring(.,string-length(.)) = $g_sNewLine)) and position() != last()">
518 <xsl:value-of select="' '"/>
519 </xsl:if>
520 </xsl:template>
521
522 <!--
523 Text escaping for C.
524 -->
525 <xsl:template match="text()" name="escape_text">
526 <!-- Leading whitespace hack! -->
527 <xsl:if test="(starts-with(.,' ') or starts-with(.,$g_sNewLine)) and position() != 1">
528 <xsl:text> </xsl:text>
529 <xsl:if test="boolean($g_fDebugText)">
530 <xsl:message>text: add lead space</xsl:message>
531 </xsl:if>
532 </xsl:if>
533
534 <!-- Body of text -->
535 <xsl:choose>
536
537 <xsl:when test="contains(., '\') or contains(., '&quot;')">
538 <xsl:variable name="sTmp">
539 <xsl:call-template name="str:subst">
540 <xsl:with-param name="text" select="normalize-space(.)"/>
541 <xsl:with-param name="replace" select="'\'"/>
542 <xsl:with-param name="with" select="'\\'"/>
543 <xsl:with-param name="disable-output-escaping" select="yes"/>
544 </xsl:call-template>
545 </xsl:variable>
546 <xsl:variable name="sTmp2">
547 <xsl:call-template name="str:subst">
548 <xsl:with-param name="text" select="$sTmp"/>
549 <xsl:with-param name="replace" select="'&quot;'"/>
550 <xsl:with-param name="with" select="'\&quot;'"/>
551 <xsl:with-param name="disable-output-escaping" select="yes"/>
552 </xsl:call-template>
553 </xsl:variable>
554 <xsl:value-of select="$sTmp2"/>
555 <xsl:if test="boolean($g_fDebugText)">
556 <xsl:message>text: |<xsl:value-of select="$sTmp2"/>|(1)</xsl:message>
557 </xsl:if>
558 </xsl:when>
559
560 <xsl:otherwise>
561 <xsl:value-of select="normalize-space(.)"/>
562 <xsl:if test="boolean($g_fDebugText)">
563 <xsl:message>text: |<xsl:value-of select="normalize-space(.)"/>|(2)</xsl:message>
564 </xsl:if>
565 </xsl:otherwise>
566 </xsl:choose>
567
568 <!-- Trailing whitespace hack! -->
569 <xsl:if test="(substring(.,string-length(.)) = ' ' or substring(.,string-length(.)) = $g_sNewLine) and position() != last() and string-length(.) != 1">
570 <xsl:text> </xsl:text>
571 <xsl:if test="boolean($g_fDebugText)">
572 <xsl:message>text: add tail space</xsl:message>
573 </xsl:if>
574 </xsl:if>
575
576 </xsl:template>
577
578 <!-- Elements producing non-breaking strings (single line). -->
579 <xsl:template match="command/text()|option/text()|computeroutput/text()|arg/text()|filename/text()" name="escape_fixed_text">
580 <xsl:param name="sText"><xsl:call-template name="my-normalize-space-current"/></xsl:param>
581 <xsl:choose>
582
583 <xsl:when test="contains($sText, '\') or contains($sText, '&quot;')">
584 <xsl:variable name="sTmp1">
585 <xsl:call-template name="str:subst">
586 <xsl:with-param name="text" select="$sText"/>
587 <xsl:with-param name="replace" select="'\'"/>
588 <xsl:with-param name="with" select="'\\'"/>
589 <xsl:with-param name="disable-output-escaping" select="yes"/>
590 </xsl:call-template>
591 </xsl:variable>
592 <xsl:variable name="sTmp2">
593 <xsl:call-template name="str:subst">
594 <xsl:with-param name="text" select="$sTmp1"/>
595 <xsl:with-param name="replace" select="'&quot;'"/>
596 <xsl:with-param name="with" select="'\&quot;'"/>
597 <xsl:with-param name="disable-output-escaping" select="yes"/>
598 </xsl:call-template>
599 </xsl:variable>
600 <xsl:variable name="sTmp3">
601 <xsl:call-template name="str:subst">
602 <xsl:with-param name="text" select="$sTmp2"/>
603 <xsl:with-param name="replace" select="' '"/>
604 <xsl:with-param name="with" select="'\b'"/>
605 <xsl:with-param name="disable-output-escaping" select="yes"/>
606 </xsl:call-template>
607 </xsl:variable>
608 <xsl:value-of select="$sTmp3"/>
609 <xsl:if test="boolean($g_fDebugText)">
610 <xsl:message>text! |<xsl:value-of select="$sTmp3"/>|</xsl:message>
611 </xsl:if>
612 </xsl:when>
613
614 <xsl:when test="contains($sText, ' ')">
615 <xsl:variable name="sTmp">
616 <xsl:call-template name="str:subst">
617 <xsl:with-param name="text" select="$sText"/>
618 <xsl:with-param name="replace" select="' '"/>
619 <xsl:with-param name="with" select="'\b'"/>
620 <xsl:with-param name="disable-output-escaping" select="yes"/>
621 </xsl:call-template>
622 </xsl:variable>
623 <xsl:value-of select="$sTmp"/>
624 <xsl:if test="boolean($g_fDebugText)">
625 <xsl:message>text! |<xsl:value-of select="$sTmp"/>|</xsl:message>
626 </xsl:if>
627 </xsl:when>
628
629 <xsl:otherwise>
630 <xsl:value-of select="$sText"/>
631 <xsl:if test="boolean($g_fDebugText)">
632 <xsl:message>text! |<xsl:value-of select="$sText"/>|</xsl:message>
633 </xsl:if>
634 </xsl:otherwise>
635 </xsl:choose>
636 </xsl:template>
637
638
639 <!--
640 Unsupported elements and elements handled directly.
641 -->
642 <xsl:template match="synopfragment|synopfragmentref|title|refsect1">
643 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The <xsl:value-of select="name()"/> element is not supported</xsl:message>
644 </xsl:template>
645
646 <xsl:template match="xref">
647 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The <xsl:value-of select="name()"/> element is not supported, most likely the linkend is not defined or incorrectly processed by docbook-refentry-link-replacement-xsl-gen.xsl</xsl:message>
648 </xsl:template>
649
650 <!--
651 Fail on misplaced scoping remarks.
652 -->
653 <xsl:template match="remark[@role = 'help-scope']">
654 <xsl:choose>
655 <xsl:when test="parent::refsect1"/>
656 <xsl:when test="parent::refsect2"/>
657 <xsl:when test="parent::cmdsynopsis and ancestor::refsynopsisdiv"/>
658 <xsl:otherwise>
659 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Misplaced remark/@role=help-scope element.
660Only supported on: refsect1, refsect2, refsynopsisdiv/cmdsynopsis</xsl:message>
661 </xsl:otherwise>
662 </xsl:choose>
663 </xsl:template>
664
665 <!--
666 Execute synopsis copy remark (avoids duplication for complicated xml).
667 -->
668 <xsl:template match="remark[@role = 'help-copy-synopsis']">
669 <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>
670 </xsl:template>
671
672 <!--
673 Warn about unhandled elements
674 -->
675 <xsl:template match="*">
676 <xsl:message terminate="no">Warning: Unhandled element: <!-- no newline -->
677 <xsl:for-each select="ancestor-or-self::*">
678 <xsl:text>/</xsl:text>
679 <xsl:value-of select="name(.)"/>
680 <xsl:if test="@id">
681 <xsl:value-of select="concat('[id=', @id ,']')"/>
682 </xsl:if>
683 </xsl:for-each>
684 </xsl:message>
685 </xsl:template>
686
687
688 <!--
689 Functions
690 Functions
691 Functions
692 -->
693
694 <!--
695 Processes mixed children, i.e. both text and regular elements.
696 Normalizes whitespace. -->
697 <xsl:template name="process-mixed">
698 <xsl:text>
699 { RTMSGREFENTRYSTR_SCOPE_SAME,
700 "</xsl:text><xsl:call-template name="emit-indentation"/>
701
702 <xsl:for-each select="node()[not(self::remark)]">
703 <xsl:choose>
704 <xsl:when test="name() = ''">
705 <xsl:call-template name="escape_text"/>
706 </xsl:when>
707 <xsl:otherwise>
708 <xsl:apply-templates select="."/>
709 </xsl:otherwise>
710 </xsl:choose>
711 </xsl:for-each>
712
713 <xsl:text>" },</xsl:text>
714 </xsl:template>
715
716
717 <!--
718 Element specific scoping.
719 -->
720
721 <xsl:template name="calc-scope-for-refentry">
722 <xsl:text>HELP_SCOPE_</xsl:text>
723 <xsl:choose>
724 <xsl:when test="contains(@id, '-')"> <!-- Multi level command. -->
725 <xsl:call-template name="str:to-upper">
726 <xsl:with-param name="text" select="translate(substring-after(@id, '-'), '-', '_')"/>
727 </xsl:call-template>
728 </xsl:when>
729 <xsl:otherwise> <!-- Single command. -->
730 <xsl:call-template name="str:to-upper">
731 <xsl:with-param name="text" select="@id"/>
732 </xsl:call-template>
733 </xsl:otherwise>
734 </xsl:choose>
735 </xsl:template>
736
737 <!-- Figures out the scope of a refsect1 element. -->
738 <xsl:template name="calc-scope-refsect1">
739 <xsl:choose>
740 <xsl:when test="contains(@id, '-description') or title[text() = 'Description']">
741 <xsl:text>RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
742 </xsl:when>
743 <xsl:when test="(@id and not(contains(@id, '-see-also')) and not(contains(@id, '-examples'))) or remark[@role='help-scope']">
744 <xsl:call-template name="calc-scope-from-remark-or-id"/>
745 </xsl:when>
746 <xsl:otherwise>
747 <xsl:text>RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
748 </xsl:otherwise>
749 </xsl:choose>
750 </xsl:template>
751
752 <!-- Figures out the scope of a refsect2 element. -->
753 <xsl:template name="calc-scope-refsect2">
754 <xsl:choose>
755 <xsl:when test="(@id and not(contains(@id, '-see-also')) and not(contains(@id, '-examples'))) or remark[@role='help-scope']">
756 <xsl:call-template name="calc-scope-from-remark-or-id"/>
757 </xsl:when>
758 <xsl:otherwise>
759 <xsl:text>RTMSGREFENTRYSTR_SCOPE_SAME</xsl:text>
760 </xsl:otherwise>
761 </xsl:choose>
762 </xsl:template>
763
764 <!-- Figures out the scope of a refsect1 element. -->
765 <xsl:template name="calc-scope-cmdsynopsis">
766 <xsl:choose>
767 <xsl:when test="ancestor::refsynopsisdiv">
768 <xsl:call-template name="calc-scope-from-remark-or-id">
769 <xsl:with-param name="sId" select="substring-after(@id, '-')"/>
770 </xsl:call-template>
771 </xsl:when>
772 <xsl:otherwise>
773 <xsl:text>RTMSGREFENTRYSTR_SCOPE_SAME</xsl:text>
774 </xsl:otherwise>
775 </xsl:choose>
776 </xsl:template>
777
778
779 <!--
780 Scoping worker functions.
781 -->
782
783 <!-- Calculates the current scope from the scope remark or @id. -->
784 <xsl:template name="calc-scope-from-remark-or-id">
785 <xsl:param name="sId" select="@id"/>
786 <xsl:choose>
787 <xsl:when test="remark[@role='help-scope']">
788 <xsl:call-template name="calc-scope-consts-from-remark"/>
789 </xsl:when>
790 <xsl:when test="$sId != ''">
791 <xsl:call-template name="calc-scope-const-from-id">
792 <xsl:with-param name="sId" select="$sId"/>
793 </xsl:call-template>
794 </xsl:when>
795 <xsl:otherwise>
796 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>expected remark child or id attribute.</xsl:message>
797 </xsl:otherwise>
798 </xsl:choose>
799 </xsl:template>
800
801 <!-- Turns a @id into a scope constant.
802 Some woodoo taking place here here that chops the everything up to and
803 including the first refentry/@id word from all IDs before turning them into
804 constants (word delimiter '-'). -->
805 <xsl:template name="calc-scope-const-from-id">
806 <xsl:param name="sId" select="@id"/>
807 <xsl:param name="sAncestorId" select="ancestor::refentry/@id"/>
808 <xsl:text>HELP_SCOPE_</xsl:text>
809 <xsl:choose>
810 <xsl:when test="not($sAncestorId)"> <!-- Sanity check. -->
811 <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>
812 </xsl:when>
813
814 <xsl:when test="contains($sAncestorId, '-')"> <!-- Multi level command. -->
815 <xsl:variable name="sPrefix" select="concat(substring-before($sAncestorId, '-'), '-')"/>
816 <xsl:if test="not(contains($sId, $sPrefix))">
817 <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>
818 </xsl:if>
819 <xsl:call-template name="str:to-upper">
820 <xsl:with-param name="text" select="translate(substring-after($sId, $sPrefix), '-', '_')"/>
821 </xsl:call-template>
822 </xsl:when>
823
824 <xsl:otherwise> <!-- Single command. -->
825 <xsl:call-template name="str:to-upper">
826 <xsl:with-param name="text" select="translate($sId, '-', '_')"/>
827 </xsl:call-template>
828 </xsl:otherwise>
829 </xsl:choose>
830 </xsl:template>
831
832 <!-- Turns a remark into one or more scope constants. -->
833 <xsl:template name="calc-scope-consts-from-remark">
834 <xsl:param name="sCondition" select="remark/@condition"/>
835 <xsl:variable name="sNormalized" select="concat(normalize-space(translate($sCondition, ',;:|', ' ')), ' ')"/>
836 <xsl:if test="$sNormalized = ' ' or $sNormalized = ''">
837 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Empty @condition for help-scope remark.</xsl:message>
838 </xsl:if>
839 <xsl:choose>
840 <xsl:when test="substring-before($sNormalized, ' ') = 'GLOBAL'">
841 <xsl:text>RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
842 </xsl:when>
843 <xsl:otherwise>
844 <xsl:text>HELP_SCOPE_</xsl:text><xsl:value-of select="substring-before($sNormalized, ' ')"/>
845 </xsl:otherwise>
846 </xsl:choose>
847 <xsl:call-template name="calc-scope-const-from-remark-worker">
848 <xsl:with-param name="sList" select="substring-after($sNormalized, ' ')"/>
849 </xsl:call-template>
850 </xsl:template>
851
852 <xsl:template name="calc-scope-const-from-remark-worker">
853 <xsl:param name="sList"/>
854 <xsl:if test="$sList != ''">
855 <xsl:choose>
856 <xsl:when test="substring-before($sList, ' ') = 'GLOBAL'">
857 <xsl:text>| RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
858 </xsl:when>
859 <xsl:otherwise>
860 <xsl:text> | HELP_SCOPE_</xsl:text><xsl:value-of select="substring-before($sList, ' ')"/>
861 </xsl:otherwise>
862 </xsl:choose>
863 <xsl:call-template name="calc-scope-const-from-remark-worker">
864 <xsl:with-param name="sList" select="substring-after($sList, ' ')"/>
865 </xsl:call-template>
866 </xsl:if>
867 </xsl:template>
868
869
870 <!--
871 Calculates and emits indentation list markup.
872 -->
873 <xsl:template name="emit-indentation">
874 <xsl:variable name="iDepth" select="count(ancestor-or-self::*)"/>
875 <xsl:for-each select="ancestor-or-self::*">
876 <xsl:choose>
877
878 <xsl:when test="self::refsect1
879 | self::refsect2
880 | self::refsect3
881 | self::refsynopsisdiv">
882 <xsl:text> </xsl:text>
883 </xsl:when>
884
885 <xsl:when test="self::term">
886 <!-- currently no indent. -->
887 </xsl:when>
888
889 <!-- Evidence here (especially with orderedlist) that doing list by for-each
890 listitem in the template matching the list type would be easier... -->
891 <xsl:when test="self::listitem and parent::itemizedlist and (position() + 1) = $iDepth">
892 <xsl:text> - </xsl:text>
893 </xsl:when>
894
895 <xsl:when test="self::listitem and parent::orderedlist and (position() + 1) = $iDepth">
896 <xsl:variable name="iNumber" select="count(preceding-sibling::listitem) + 1"/>
897 <xsl:if test="$iNumber &lt;= 9">
898 <xsl:text> </xsl:text>
899 </xsl:if>
900 <xsl:value-of select="$iNumber"/>
901 <xsl:text>. </xsl:text>
902 </xsl:when>
903
904 <xsl:when test="self::listitem">
905 <xsl:text> </xsl:text>
906 </xsl:when>
907
908 </xsl:choose>
909 </xsl:for-each>
910 </xsl:template>
911
912 <!--
913 Captializes the given text.
914 -->
915 <xsl:template name="capitalize">
916 <xsl:param name="text"/>
917 <xsl:call-template name="str:to-upper">
918 <xsl:with-param name="text" select="substring($text,1,1)"/>
919 </xsl:call-template>
920 <xsl:value-of select="substring($text,2)"/>
921 </xsl:template>
922
923
924 <!--
925 Debug/Diagnostics: Return the path to the specified node (by default the current).
926 -->
927 <xsl:template name="get-node-path">
928 <xsl:param name="Node" select="."/>
929 <xsl:for-each select="$Node">
930 <xsl:for-each select="ancestor-or-self::node()">
931 <xsl:choose>
932 <xsl:when test="name(.) = ''">
933 <xsl:text>text()</xsl:text>
934 </xsl:when>
935 <xsl:otherwise>
936 <xsl:value-of select="concat('/', name(.))"/>
937 <xsl:choose>
938 <xsl:when test="@id">
939 <xsl:text>[@id=</xsl:text>
940 <xsl:value-of select="@id"/>
941 <xsl:text>]</xsl:text>
942 </xsl:when>
943 <xsl:when test="position() > 1">
944 <xsl:text>[</xsl:text><xsl:value-of select="position()"/><xsl:text>]</xsl:text>
945 </xsl:when>
946 </xsl:choose>
947 </xsl:otherwise>
948 </xsl:choose>
949 </xsl:for-each>
950 </xsl:for-each>
951 </xsl:template>
952
953 <!--
954 Debug/Diagnostics: Return error message prefix.
955 -->
956 <xsl:template name="error-prefix">
957 <xsl:param name="Node" select="."/>
958 <xsl:text>error: </xsl:text>
959 <xsl:call-template name="get-node-path">
960 <xsl:with-param name="Node" select="$Node"/>
961 </xsl:call-template>
962 <xsl:text>: </xsl:text>
963 </xsl:template>
964
965 <!--
966 Debug/Diagnostics: Print list of nodes (by default all children of current node).
967 -->
968 <xsl:template name="list-nodes">
969 <xsl:param name="Nodes" select="node()"/>
970 <xsl:for-each select="$Nodes">
971 <xsl:if test="position() != 1">
972 <xsl:text>, </xsl:text>
973 </xsl:if>
974 <xsl:choose>
975 <xsl:when test="name(.) = ''">
976 <xsl:text>text:text()</xsl:text>
977 </xsl:when>
978 <xsl:otherwise>
979 <xsl:value-of select="name(.)"/>
980 <xsl:if test="@id">
981 <xsl:text>[@id=</xsl:text>
982 <xsl:value-of select="@id"/>
983 <xsl:text>]</xsl:text>
984 </xsl:if>
985 </xsl:otherwise>
986 </xsl:choose>
987 </xsl:for-each>
988 </xsl:template>
989
990 <xsl:template name="check-children">
991 <xsl:param name="Node" select="."/>
992 <xsl:param name="UnsupportedNodes" select="*"/>
993 <xsl:param name="SupportedNames" select="'none'"/>
994 <xsl:if test="count($UnsupportedNodes) != 0">
995 <xsl:message terminate="yes">
996 <xsl:call-template name="get-node-path">
997 <xsl:with-param name="Node" select="$Node"/>
998 </xsl:call-template>
999 <!-- -->: error: Only <xsl:value-of select="$SupportedNames"/> are supported as children to <!-- -->
1000 <xsl:value-of select="name($Node)"/>
1001 <!-- -->
1002Unsupported children: <!-- -->
1003 <xsl:call-template name="list-nodes">
1004 <xsl:with-param name="Nodes" select="$UnsupportedNodes"/>
1005 </xsl:call-template>
1006 </xsl:message>
1007 </xsl:if>
1008 </xsl:template>
1009
1010</xsl:stylesheet>
1011
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use