VirtualBox

source: vbox/trunk/doc/manual/docbook-refentry-to-manual-dita.xsl@ 99130

最後變更 在這個檔案從99130是 99130,由 vboxsync 提交於 2 年 前

manual: More work on the refentry to dita converter. bugref:10302

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 21.3 KB
 
1<?xml version="1.0"?>
2<!--
3 docbook-refentry-to-manual-sect1.xsl:
4 XSLT stylesheet for converting a refentry (manpage)
5 to dita for use in the user manual.
6-->
7<!--
8 Copyright (C) 2006-2023 Oracle and/or its affiliates.
9
10 This file is part of VirtualBox base platform packages, as
11 available from https://www.alldomusa.eu.org.
12
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License
15 as published by the Free Software Foundation, in version 3 of the
16 License.
17
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <https://www.gnu.org/licenses>.
25
26 SPDX-License-Identifier: GPL-3.0-only
27-->
28
29<xsl:stylesheet
30 version="1.0"
31 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
32 xmlns:str="http://xsltsl.org/string"
33 >
34
35 <xsl:import href="string.xsl"/>
36
37 <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
38 <xsl:strip-space elements="*"/>
39
40
41<!-- - - - - - - - - - - - - - - - - - - - - - -
42 global XSLT variables
43 - - - - - - - - - - - - - - - - - - - - - - -->
44
45
46
47<!-- - - - - - - - - - - - - - - - - - - - - - -
48 base operation is to fail on nodes w/o explicit matching.
49 - - - - - - - - - - - - - - - - - - - - - - -->
50
51<xsl:template match="*">
52 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>unhandled element</xsl:message>
53</xsl:template>
54
55
56<!-- - - - - - - - - - - - - - - - - - - - - - -
57 transformations starting with root and going deeper.
58 - - - - - - - - - - - - - - - - - - - - - - -->
59
60<!-- Rename refentry to reference.
61 Also we need to wrap the refsync and refsect1 elements in a refbody. -->
62<xsl:template match="refentry">
63 <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd"&gt;</xsl:text>
64
65 <xsl:element name="reference">
66 <xsl:if test="not(@id)">
67 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have an id attribute!</xsl:message>
68 </xsl:if>
69 <xsl:attribute name="rev">refentry</xsl:attribute>
70 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
71
72 <!-- Copy title element from refentryinfo -->
73 <xsl:if test="./refentryinfo/title">
74 <xsl:copy-of select="./refentryinfo/title"/>
75 </xsl:if>
76
77 <!-- Create a shortdesc element from the text in refnamediv/refpurpose -->
78 <xsl:if test="./refnamediv/refpurpose">
79 <xsl:element name="shortdesc">
80 <xsl:attribute name="rev">refnamediv/refpurpose</xsl:attribute>
81 <xsl:call-template name="capitalize">
82 <xsl:with-param name="text" select="normalize-space(./refnamediv/refpurpose)"/>
83 </xsl:call-template>
84 </xsl:element>
85 </xsl:if>
86
87 <!-- Put everything else side a refbody element -->
88 <xsl:element name="refbody">
89 <xsl:apply-templates />
90 </xsl:element>
91
92 </xsl:element>
93</xsl:template>
94
95<!-- Remove refentryinfo (we extracted the title element already). -->
96<xsl:template match="refentryinfo" />
97
98<!-- Remove refmeta (manpage info). -->
99<xsl:template match="refmeta"/>
100
101<!-- Remove the refnamediv (we extracted a shortdesc from it already). -->
102<xsl:template match="refnamediv"/>
103
104<!-- Morph the refsynopsisdiv part into a refsyn section. -->
105<xsl:template match="refsynopsisdiv">
106 <xsl:if test="name(*[1]) != 'cmdsynopsis'"><xsl:message terminate="yes">Expected refsynopsisdiv to start with cmdsynopsis</xsl:message></xsl:if>
107 <xsl:if test="title"><xsl:message terminate="yes">No title element supported in refsynopsisdiv</xsl:message></xsl:if>
108
109 <xsl:element name="refsyn">
110 <xsl:attribute name="rev">refsynopsisdiv</xsl:attribute>
111 <xsl:element name="title">
112 <xsl:text>Synopsis</xsl:text>
113 </xsl:element>
114 <xsl:apply-templates />
115 </xsl:element>
116
117</xsl:template>
118
119<!-- refsect1 -> section -->
120<xsl:template match="refsect1">
121 <xsl:if test="not(title)"><xsl:message terminate="yes">refsect1 requires title</xsl:message></xsl:if>
122 <xsl:element name="section">
123 <xsl:attribute name="rev">refsect1</xsl:attribute>
124 <xsl:if test="@id">
125 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
126 </xsl:if>
127 <xsl:apply-templates />
128 </xsl:element>
129</xsl:template>
130
131<!-- refsect2 -> sectiondiv. -->
132<xsl:template match="refsect2">
133 <xsl:if test="not(title)"><xsl:message terminate="yes">refsect2 requires title</xsl:message></xsl:if>
134 <xsl:element name="sectiondiv">
135 <xsl:attribute name="rev">refsect2</xsl:attribute>
136 <xsl:if test="@id">
137 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
138 </xsl:if>
139
140 <xsl:apply-templates />
141
142 </xsl:element>
143</xsl:template>
144
145<!-- refsect2/title -> b -->
146<xsl:template match="refsect2/title">
147 <xsl:element name="b">
148 <xsl:attribute name="rev">refsect2/title</xsl:attribute>
149 <xsl:apply-templates />
150 </xsl:element>
151</xsl:template>
152
153<!-- refsect1/title -> title -->
154<xsl:template match="refsect1/title">
155 <xsl:copy>
156 <xsl:apply-templates />
157 </xsl:copy>
158</xsl:template>
159
160<!-- para -> p -->
161<xsl:template match="para">
162 <xsl:element name="p">
163 <xsl:attribute name="rev">para</xsl:attribute>
164 <xsl:apply-templates />
165 </xsl:element>
166</xsl:template>
167
168<!-- note in a section -> note (no change needed) -->
169<xsl:template match="refsect1/note | refsect2/note">
170 <xsl:copy>
171 <xsl:apply-templates />
172 </xsl:copy>
173</xsl:template>
174
175<!-- variablelist -> dl -->
176<xsl:template match="variablelist">
177 <xsl:element name="dl">
178 <xsl:attribute name="rev">variablelist</xsl:attribute>
179 <xsl:apply-templates />
180 </xsl:element>
181</xsl:template>
182
183<!-- varlistentry -> dlentry -->
184<xsl:template match="varlistentry">
185 <xsl:element name="dlentry">
186 <xsl:attribute name="rev">varlistentry</xsl:attribute>
187 <xsl:apply-templates />
188 </xsl:element>
189</xsl:template>
190
191<!-- term (in varlistentry) -> dt -->
192<xsl:template match="varlistentry/term">
193 <xsl:element name="dt">
194 <xsl:attribute name="rev">term</xsl:attribute>
195 <xsl:apply-templates />
196 </xsl:element>
197</xsl:template>
198
199<!-- listitem (in varlistentry) -> dd -->
200<xsl:template match="varlistentry/listitem">
201 <xsl:element name="dd">
202 <xsl:attribute name="rev">listitem</xsl:attribute>
203 <xsl:apply-templates />
204 </xsl:element>
205</xsl:template>
206
207<!-- itemizedlist -> ul -->
208<xsl:template match="itemizedlist">
209 <xsl:element name="ul">
210 <xsl:attribute name="rev">itemizedlist</xsl:attribute>
211 <xsl:apply-templates />
212 </xsl:element>
213</xsl:template>
214
215<!-- listitem in itemizedlist -> li -->
216<xsl:template match="itemizedlist/listitem">
217 <xsl:element name="li">
218 <xsl:attribute name="rev">listitem</xsl:attribute>
219 <xsl:apply-templates />
220 </xsl:element>
221</xsl:template>
222
223<!-- orderedlist -> ol -->
224<xsl:template match="orderedlist">
225 <xsl:element name="ol">
226 <xsl:attribute name="rev">orderedlist</xsl:attribute>
227 <xsl:apply-templates />
228 </xsl:element>
229</xsl:template>
230
231<!-- listitem in orderedlist -> li -->
232<xsl:template match="orderedlist/listitem">
233 <xsl:element name="li">
234 <xsl:attribute name="rev">listitem</xsl:attribute>
235 <xsl:apply-templates />
236 </xsl:element>
237</xsl:template>
238
239<!-- cmdsynopsis -> syntaxdiagram
240 If sbr is used, this gets a bit more complicated... -->
241<xsl:template match="cmdsynopsis[not(sbr)]">
242 <xsl:element name="syntaxdiagram">
243 <xsl:attribute name="rev">cmdsynopsis</xsl:attribute>
244 <xsl:if test="@id">
245 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
246 </xsl:if>
247 <xsl:apply-templates />
248 </xsl:element>
249</xsl:template>
250
251<xsl:template match="cmdsynopsis[sbr]">
252 <xsl:element name="syntaxdiagram">
253 <xsl:attribute name="rev">cmdsynopsis</xsl:attribute>
254 <xsl:if test="@id">
255 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
256 </xsl:if>
257 <xsl:for-each select="sbr">
258 <xsl:variable name="idxSbr" select="position()"/>
259 <xsl:element name="groupcomp">
260 <xsl:attribute name="rev">sbr/<xsl:value-of select="position()"/></xsl:attribute>
261
262 <xsl:if test="$idxSbr = 1">
263 <xsl:apply-templates select="preceding-sibling::node()"/>
264 </xsl:if>
265 <xsl:if test="$idxSbr != 1">
266 <xsl:apply-templates select="preceding-sibling::node()[ count(. | ../sbr[$idxSbr - 1]/following-sibling::node())
267 = count(../sbr[$idxSbr - 1]/following-sibling::node())]"/>
268 </xsl:if>
269 <xsl:if test="$idxSbr = last()">
270 <xsl:apply-templates select="following-sibling::node()"/>
271 </xsl:if>
272 </xsl:element>
273 </xsl:for-each>
274 </xsl:element>
275</xsl:template>
276
277<!-- command with text and/or replaceable in cmdsynopsis -> groupseq + kwd -->
278<xsl:template match="cmdsynopsis/command | cmdsynopsis/*/command" >
279 <xsl:element name="groupseq">
280 <xsl:attribute name="rev">command</xsl:attribute>
281 <xsl:apply-templates />
282 </xsl:element>
283</xsl:template>
284
285<xsl:template match="cmdsynopsis/command/text() | cmdsynopsis/*/command/text()" >
286 <xsl:element name="kwd">
287 <xsl:attribute name="rev">command/text</xsl:attribute>
288 <xsl:value-of select="."/>
289 </xsl:element>
290</xsl:template>
291
292<xsl:template match="cmdsynopsis/command/replaceable | cmdsynopsis/*/command/replaceable" >
293 <xsl:call-template name="check-children"/>
294 <xsl:element name="var">
295 <xsl:attribute name="rev">command/replaceable</xsl:attribute>
296 <xsl:apply-templates />
297 </xsl:element>
298</xsl:template>
299
300<!-- command with text and/or replaceable in not cmdsynopsis -> userinput + cmdname -->
301<xsl:template match="command[not(ancestor::cmdsynopsis)]">
302 <xsl:element name="userinput">
303 <xsl:attribute name="rev">command</xsl:attribute>
304 <xsl:apply-templates />
305 </xsl:element>
306</xsl:template>
307
308<xsl:template match="command[not(ancestor::cmdsynopsis)]/text()">
309 <xsl:element name="cmdname">
310 <xsl:attribute name="rev">command/text</xsl:attribute>
311 <xsl:value-of select="."/>
312 </xsl:element>
313</xsl:template>
314
315<xsl:template match="command[not(ancestor::cmdsynopsis)]/replaceable">
316 <xsl:call-template name="check-children"/>
317 <xsl:element name="varname">
318 <xsl:attribute name="rev">command/replaceable</xsl:attribute>
319 <xsl:value-of select="."/>
320 </xsl:element>
321</xsl:template>
322
323<!-- arg -->
324<xsl:template match="arg/text()">
325 <xsl:element name="kwd">
326 <xsl:attribute name="rev">arg</xsl:attribute>
327 <xsl:value-of select="."/>
328 </xsl:element>
329</xsl:template>
330
331<xsl:template match="arg[(not(@choice) or @choice='opt') and (not(@rep) or @rep='norepeat')]" >
332 <xsl:element name="groupseq">
333 <xsl:attribute name="rev">arg[opt,norepeat]</xsl:attribute>
334 <xsl:attribute name="importance">optional</xsl:attribute>
335 <xsl:apply-templates />
336 </xsl:element>
337</xsl:template>
338
339<xsl:template match="arg[@choice='req' and (not(@rep) or @rep='norepeat')]" >
340 <xsl:element name="groupseq">
341 <xsl:attribute name="rev">arg[req,norepeat]</xsl:attribute>
342 <xsl:attribute name="importance">required</xsl:attribute>
343 <xsl:apply-templates />
344 </xsl:element>
345</xsl:template>
346
347<xsl:template match="arg[not(ancestor::group) and ancestor::cmdsynopsis and @choice='plain' and (not(@rep) or @rep='norepeat')]" >
348 <xsl:element name="kwd">
349 <xsl:attribute name="rev">arg[plain]</xsl:attribute>
350 <xsl:apply-templates />
351 </xsl:element>
352</xsl:template>
353
354<xsl:template match="group/arg[replaceable and @choice='plain' and (not(@rep) or @rep='norepeat')]" >
355 <xsl:call-template name="check-children">
356 <xsl:with-param name="UnsupportedNodes" select="*[not(self::replaceable)]"/>
357 <xsl:with-param name="SupportedNames">replaceable or text()</xsl:with-param>
358 </xsl:call-template>
359 <xsl:element name="var">
360 <xsl:attribute name="rev">arg[plain]/replaceable</xsl:attribute>
361 <xsl:value-of select="."/>
362 </xsl:element>
363</xsl:template>
364
365<xsl:template match="group/arg[@choice='plain' and (not(@rep) or @rep='norepeat') and not(replaceable)]" >
366 <xsl:call-template name="check-children" />
367 <xsl:element name="kwd">
368 <xsl:attribute name="rev">arg[plain]</xsl:attribute>
369 <xsl:value-of select="."/>
370 </xsl:element>
371</xsl:template>
372
373<xsl:template match="arg[(not(@choice) or @choice='opt') and @rep='repeat' and not(ancestor::group) and not(group)]" >
374 <xsl:element name="groupseq">
375 <xsl:attribute name="rev">arg[opt,repeat]</xsl:attribute>
376 <xsl:attribute name="importance">optional</xsl:attribute>
377 <xsl:apply-templates />
378 <xsl:element name="repsep">
379 <xsl:attribute name="rev">arg[opt,repeat]</xsl:attribute>
380 <xsl:text>...</xsl:text>
381 </xsl:element>
382 </xsl:element>
383</xsl:template>
384
385
386<!-- replaceable under arg -> var -->
387<xsl:template match="arg/replaceable" >
388 <xsl:element name="var">
389 <xsl:attribute name="rev">replaceable</xsl:attribute>
390 <xsl:apply-templates />
391 </xsl:element>
392</xsl:template>
393
394<!-- replaceable in para or term -> synph+var -->
395<xsl:template match="para/replaceable | term/replaceable | screen/replaceable" >
396 <xsl:element name="synph">
397 <xsl:attribute name="rev">replaceable</xsl:attribute>
398 <xsl:element name="var">
399 <xsl:attribute name="rev">replaceable</xsl:attribute>
400 <xsl:apply-templates />
401 </xsl:element>
402 </xsl:element>
403</xsl:template>
404
405<!-- replaceable in option -> var -->
406<xsl:template match="option/replaceable" >
407 <xsl:element name="var">
408 <xsl:attribute name="rev">option/replaceable</xsl:attribute>
409 <xsl:apply-templates />
410 </xsl:element>
411</xsl:template>
412
413<!-- replaceable in computeroutput -> varname -->
414<xsl:template match="computeroutput/replaceable" >
415 <xsl:element name="varname">
416 <xsl:attribute name="rev">computeroutput/replaceable</xsl:attribute>
417 <xsl:apply-templates />
418 </xsl:element>
419</xsl:template>
420
421<!-- group under arg and cmdsynopsis -> groupchoice -->
422<xsl:template match="arg/group[@choice='plain'] | cmdsynopsis/group[@choice='plain']">
423 <xsl:element name="groupchoice">
424 <xsl:attribute name="rev">group</xsl:attribute>
425 <xsl:apply-templates />
426 </xsl:element>
427</xsl:template>
428
429<xsl:template match="arg/group[@choice='req'] | cmdsynopsis/group[@choice='req']">
430 <xsl:element name="groupchoice">
431 <xsl:attribute name="rev">group</xsl:attribute>
432 <xsl:attribute name="importance">required</xsl:attribute>
433 <xsl:apply-templates />
434 </xsl:element>
435</xsl:template>
436
437<xsl:template match="cmdsynopsis/group[(@choice='opt' or not(@choice)) and (not(@rep) or @rep='norepeat')]" >
438 <xsl:if test="not(./arg[@choice='plain'])">
439 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Did not expect group[@choice=opt] to have children other than arg[@choice=plain]:
440 <xsl:for-each select="node()"><xsl:value-of select="concat(' ', name())"/>[@choice=<xsl:value-of select="@choice"/>]</xsl:for-each>
441 </xsl:message>
442 </xsl:if>
443 <xsl:element name="groupchoice">
444 <xsl:attribute name="rev">group[opt]</xsl:attribute>
445 <xsl:attribute name="importance">optional</xsl:attribute>
446 <xsl:value-of select="."/>
447 </xsl:element>
448</xsl:template>
449
450<!-- option -->
451<xsl:template match="option/text()" >
452 <xsl:element name="kwd">
453 <xsl:attribute name="rev">option</xsl:attribute>
454 <xsl:value-of select="."/>
455 </xsl:element>
456</xsl:template>
457
458<xsl:template match="option" >
459 <xsl:element name="synph">
460 <xsl:attribute name="rev">option</xsl:attribute>
461 <xsl:apply-templates />
462 </xsl:element>
463</xsl:template>
464
465<!-- literal w/o sub-elements -> codeph -->
466<xsl:template match="literal[not(*)]" >
467 <xsl:element name="codeph">
468 <xsl:attribute name="rev">literal</xsl:attribute>
469 <xsl:apply-templates />
470 </xsl:element>
471</xsl:template>
472
473<!-- literal with replaceable sub-elements -> synph -->
474<xsl:template match="literal[replaceable]" >
475 <xsl:element name="synph">
476 <xsl:attribute name="rev">literal/replaceable</xsl:attribute>
477 <xsl:for-each select="node()">
478 <xsl:choose>
479 <xsl:when test="self::text()">
480 <xsl:element name="kwd">
481 <xsl:value-of select="."/>
482 </xsl:element>
483 </xsl:when>
484 <xsl:when test="self::replaceable">
485 <xsl:if test="./*">
486 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Unexpected literal/replaceable child</xsl:message>
487 </xsl:if>
488 <xsl:element name="var">
489 <xsl:value-of select="."/>
490 </xsl:element>
491 </xsl:when>
492 <xsl:otherwise>
493 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Unexpected literal child:
494 <xsl:value-of select="name(.)" />
495 </xsl:message>
496 </xsl:otherwise>
497 </xsl:choose>
498 </xsl:for-each>
499 </xsl:element>
500</xsl:template>
501
502<!-- filename -> filepath -->
503<xsl:template match="filename" >
504 <xsl:element name="filepath">
505 <xsl:attribute name="rev">filename</xsl:attribute>
506 <xsl:apply-templates />
507 </xsl:element>
508</xsl:template>
509
510<!-- screen - pass thru -->
511<xsl:template match="screen" >
512 <xsl:copy>
513 <xsl:apply-templates />
514 </xsl:copy>
515</xsl:template>
516
517<!-- computeroutput -> systemoutput-->
518<xsl:template match="computeroutput">
519 <xsl:element name="systemoutput">
520 <xsl:attribute name="rev">computeroutput</xsl:attribute>
521 <xsl:apply-templates />
522 </xsl:element>
523</xsl:template>
524
525<!-- xref -> xref, but attributes differ. -->
526<xsl:template match="xref">
527 <xsl:element name="xref">
528 <xsl:attribute name="href"><xsl:value-of select="@linkend"/></xsl:attribute>
529 <xsl:if test="contains(@linkend, 'http')"><xsl:message terminate="yes">xref/linkend with http</xsl:message></xsl:if>
530 </xsl:element>
531</xsl:template>
532
533<!-- ulink -> xref -->
534<xsl:template match="ulink">
535 <xsl:element name="xref">
536 <xsl:attribute name="rev">ulink</xsl:attribute>
537 <xsl:attribute name="scope">external</xsl:attribute> <!-- Just assumes this is external. -->
538 <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
539 </xsl:element>
540</xsl:template>
541
542<!-- emphasis -> i -->
543<xsl:template match="emphasis">
544 <xsl:if test="*">
545 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Did not expect emphasis to have children!</xsl:message>
546 </xsl:if>
547 <xsl:element name="i">
548 <xsl:attribute name="rev">emphasis</xsl:attribute>
549 <xsl:apply-templates />
550 </xsl:element>
551</xsl:template>
552
553<!--
554 remark extensions:
555 -->
556<!-- Default: remove all remarks. -->
557<xsl:template match="remark"/>
558
559
560<!--
561 Captializes the given text.
562 -->
563<xsl:template name="capitalize">
564 <xsl:param name="text"/>
565 <xsl:call-template name="str:to-upper">
566 <xsl:with-param name="text" select="substring($text,1,1)"/>
567 </xsl:call-template>
568 <xsl:value-of select="substring($text,2)"/>
569</xsl:template>
570
571<!--
572 Debug/Diagnostics: Return the path to the specified node (by default the current).
573 -->
574<xsl:template name="get-node-path">
575 <xsl:param name="Node" select="."/>
576 <xsl:for-each select="$Node">
577 <xsl:for-each select="ancestor-or-self::node()">
578 <xsl:choose>
579 <xsl:when test="name(.) = ''">
580 <xsl:text>text()</xsl:text>
581 </xsl:when>
582 <xsl:otherwise>
583 <xsl:value-of select="concat('/', name(.))"/>
584 <xsl:choose>
585 <xsl:when test="@id">
586 <xsl:text>[@id=</xsl:text>
587 <xsl:value-of select="@id"/>
588 <xsl:text>]</xsl:text>
589 </xsl:when>
590 <xsl:when test="position() > 1">
591 <xsl:text>[</xsl:text><xsl:value-of select="position()"/><xsl:text>]</xsl:text>
592 </xsl:when>
593 </xsl:choose>
594 </xsl:otherwise>
595 </xsl:choose>
596 </xsl:for-each>
597 </xsl:for-each>
598</xsl:template>
599
600<!--
601 Debug/Diagnostics: Return error message prefix.
602 -->
603<xsl:template name="error-prefix">
604 <xsl:param name="Node" select="."/>
605 <xsl:text>error: </xsl:text>
606 <xsl:call-template name="get-node-path">
607 <xsl:with-param name="Node" select="$Node"/>
608 </xsl:call-template>
609 <xsl:text>: </xsl:text>
610</xsl:template>
611
612<!--
613 Debug/Diagnostics: Print list of nodes (by default all children of current node).
614 -->
615<xsl:template name="list-nodes">
616 <xsl:param name="Nodes" select="node()"/>
617 <xsl:for-each select="$Nodes">
618 <xsl:if test="position() != 1">
619 <xsl:text>, </xsl:text>
620 </xsl:if>
621 <xsl:choose>
622 <xsl:when test="name(.) = ''">
623 <xsl:text>text:text()</xsl:text>
624 </xsl:when>
625 <xsl:otherwise>
626 <xsl:value-of select="name(.)"/>
627 <xsl:if test="@id">
628 <xsl:text>[@id=</xsl:text>
629 <xsl:value-of select="@id"/>
630 <xsl:text>]</xsl:text>
631 </xsl:if>
632 </xsl:otherwise>
633 </xsl:choose>
634 </xsl:for-each>
635</xsl:template>
636
637<xsl:template name="check-children">
638 <xsl:param name="Node" select="."/>
639 <xsl:param name="UnsupportedNodes" select="*"/>
640 <xsl:param name="SupportedNames" select="'none'"/>
641 <xsl:if test="count($UnsupportedNodes) != 0">
642 <xsl:message terminate="yes">
643 <xsl:call-template name="get-node-path">
644 <xsl:with-param name="Node" select="$Node"/>
645 </xsl:call-template>
646 <!-- -->: error: Only <xsl:value-of select="$SupportedNames"/> are supported as children to <!-- -->
647 <xsl:value-of select="name($Node)"/>
648 <!-- -->
649Unsupported children: <!-- -->
650 <xsl:call-template name="list-nodes">
651 <xsl:with-param name="Nodes" select="$UnsupportedNodes"/>
652 </xsl:call-template>
653 </xsl:message>
654 </xsl:if>
655</xsl:template>
656
657</xsl:stylesheet>
658
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette