Debian Codegraph @

doc/docbook-xsl/common/refentry.xsl

raw
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4 xmlns:date="http://exslt.org/dates-and-times"
5 exclude-result-prefixes="doc date"
6 version='1.0'>
7
8 <!-- ********************************************************************
9 $Id$
10 ********************************************************************
11
12 This file is part of the XSL DocBook Stylesheet distribution.
13 See ../README or http://docbook.sf.net/release/xsl/current/ for
14 copyright and other information.
15
16 ******************************************************************** -->
17
18 <!-- ==================================================================== -->
19
20 <doc:reference xmlns="">
21 <referenceinfo>
22 <releaseinfo role="meta">
23 $Id$
24 </releaseinfo>
25 <corpauthor>The DocBook Project</corpauthor>
26 <copyright>
27 <year>2005-2007</year>
28 <holder>The DocBook Project</holder>
29 </copyright>
30 </referenceinfo>
31 <title>Refentry Metadata-Gathering Template Reference</title>
32
33 <partintro id="partintro">
34 <title>Introduction</title>
35
36 <para>This is technical reference documentation for the "refentry
37 metadata gathering" templates in the DocBook XSL Stylesheets.</para>
38
39 <para>This is not intended to be user documentation. It is provided
40 for developers writing customization layers for the
41 stylesheets.</para>
42
43 <note>
44 <para>Currently, only the manpages stylesheets make use of these
45 templates. They are, however, potentially useful elsewhere.</para>
46 </note>
47
48 </partintro>
49
50 </doc:reference>
51
52 <!-- ==================================================================== -->
53
54 <doc:template name="get.refentry.metadata" xmlns="">
55 <refpurpose>Gathers metadata from a refentry and its ancestors</refpurpose>
56
57 <refdescription>
58 <para>Reference documentation for particular commands, functions,
59 etc., is sometimes viewed in isolation from its greater "context". For
60 example, users view Unix man pages as, well, individual pages, not as
61 part of a "book" of some kind. Therefore, it is sometimes necessary to
62 embed "context" information in output for each <sgmltag>refentry</sgmltag>.</para>
63
64 <para>However, one problem is that different users mark up that
65 context information in different ways. Often (usually), the
66 context information is not actually part of the content of the
67 <sgmltag>refentry</sgmltag> itself, but instead part of the content of a
68 parent or ancestor element to the the <sgmltag>refentry</sgmltag>. And
69 even then, DocBook provides a variety of elements that users might
70 potentially use to mark up the same kind of information. One user
71 might use the <sgmltag>productnumber</sgmltag> element to mark up version
72 information about a particular product, while another might use
73 the <sgmltag>releaseinfo</sgmltag> element.</para>
74
75 <para>Taking all that in mind, the
76 <function>get.refentry.metadata</function> function tries to gather
77 metadata from a <sgmltag>refentry</sgmltag> element and its ancestor
78 elements in an intelligent and user-configurable way. The basic
79 mechanism used in the XPath expressions throughout this stylesheet
80 is to select the relevant metadata from the *info element that is
81 closest to the actual <sgmltag>refentry</sgmltag>&#160;– either on the
82 <sgmltag>refentry</sgmltag> itself, or on its nearest ancestor.</para>
83
84 <note>
85 <para>The <function>get.refentry.metadata</function> function is
86 actually just sort of a "driver" function; it calls other
87 functions that do the actual data collection, then returns the
88 data as a set.</para>
89 </note>
90
91 </refdescription>
92
93 <refparameter>
94 <variablelist>
95 <varlistentry>
96 <term>refname</term>
97 <listitem>
98 <para>The first <sgmltag>refname</sgmltag> in the refentry</para>
99 </listitem>
100 </varlistentry>
101 <varlistentry>
102 <term>info</term>
103 <listitem>
104 <para>A set of info nodes (from a <sgmltag>refentry</sgmltag>
105 element and its ancestors)</para>
106 </listitem>
107 </varlistentry>
108 <varlistentry>
109 <term>prefs</term>
110 <listitem>
111 <para>A node containing user preferences (from global
112 stylesheet parameters)</para>
113 </listitem>
114 </varlistentry>
115 </variablelist>
116 </refparameter>
117
118 <refreturn>
119 <para>Returns a node set with the following elements. The
120 descriptions are verbatim from the <literal>man(7)</literal> man
121 page.
122 <variablelist>
123 <varlistentry>
124 <term>title</term>
125 <listitem>
126 <para>the title of the man page (e.g., <literal>MAN</literal>)</para>
127 </listitem>
128 </varlistentry>
129 <varlistentry>
130 <term>section</term>
131 <listitem>
132 <para>the section number the man page should be placed in (e.g.,
133 <literal>7</literal>)</para>
134 </listitem>
135 </varlistentry>
136 <varlistentry>
137 <term>date</term>
138 <listitem>
139 <para>the date of the last revision</para>
140 </listitem>
141 </varlistentry>
142 <varlistentry>
143 <term>source</term>
144 <listitem>
145 <para>the source of the command</para>
146 </listitem>
147 </varlistentry>
148 <varlistentry>
149 <term>manual</term>
150 <listitem>
151 <para>the title of the manual (e.g., <citetitle>Linux
152 Programmer's Manual</citetitle>)</para>
153 </listitem>
154 </varlistentry>
155 </variablelist>
156 </para>
157 </refreturn>
158 </doc:template>
159
160 <xsl:template name="get.refentry.metadata">
161 <xsl:param name="refname"/>
162 <xsl:param name="info"/>
163 <xsl:param name="prefs"/>
164 <title>
165 <xsl:call-template name="get.refentry.title">
166 <xsl:with-param name="refname" select="$refname"/>
167 </xsl:call-template>
168 </title>
169 <section>
170 <xsl:call-template name="get.refentry.section">
171 <xsl:with-param name="refname" select="$refname"/>
172 </xsl:call-template>
173 </section>
174 <date>
175 <xsl:call-template name="get.refentry.date">
176 <xsl:with-param name="info" select="$info"/>
177 <xsl:with-param name="refname" select="$refname"/>
178 <xsl:with-param name="prefs" select="$prefs/DatePrefs"/>
179 </xsl:call-template>
180 </date>
181 <source>
182 <xsl:call-template name="get.refentry.source">
183 <xsl:with-param name="info" select="$info"/>
184 <xsl:with-param name="refname" select="$refname"/>
185 <xsl:with-param name="prefs" select="$prefs/SourcePrefs"/>
186 </xsl:call-template>
187 </source>
188 <manual>
189 <xsl:call-template name="get.refentry.manual">
190 <xsl:with-param name="info" select="$info"/>
191 <xsl:with-param name="refname" select="$refname"/>
192 <xsl:with-param name="prefs" select="$prefs/ManualPrefs"/>
193 </xsl:call-template>
194 </manual>
195 </xsl:template>
196
197 <!-- ====================================================================== -->
198
199 <doc:template name="get.refentry.title" xmlns="">
200 <refpurpose>Gets title metadata for a refentry</refpurpose>
201
202 <refdescription>
203 <para>The <literal>man(7)</literal> man page describes this as "the
204 title of the man page (e.g., <literal>MAN</literal>). This differs
205 from <sgmltag>refname</sgmltag> in that, if the <sgmltag>refentry</sgmltag> has a
206 <sgmltag>refentrytitle</sgmltag>, we use that as the <sgmltag>title</sgmltag>;
207 otherwise, we just use first <sgmltag>refname</sgmltag> in the first
208 <sgmltag>refnamediv</sgmltag> in the source.</para>
209 </refdescription>
210
211 <refparameter>
212 <variablelist>
213 <varlistentry>
214 <term>refname</term>
215 <listitem>
216 <para>The first <sgmltag>refname</sgmltag> in the refentry</para>
217 </listitem>
218 </varlistentry>
219 </variablelist>
220 </refparameter>
221
222 <refreturn>
223 <para>Returns a <sgmltag>title</sgmltag> node.</para></refreturn>
224 </doc:template>
225
226 <xsl:template name="get.refentry.title">
227 <xsl:param name="refname"/>
228 <xsl:choose>
229 <xsl:when test="refmeta/refentrytitle">
230 <xsl:copy>
231 <xsl:apply-templates select="refmeta/refentrytitle/node()"/>
232 </xsl:copy>
233 </xsl:when>
234 <xsl:otherwise>
235 <xsl:copy-of select="$refname"/>
236 </xsl:otherwise>
237 </xsl:choose>
238 </xsl:template>
239
240 <!-- ==================================================================== -->
241
242 <doc:template name="get.refentry.section" xmlns="">
243 <refpurpose>Gets section metadata for a refentry</refpurpose>
244
245 <refdescription>
246 <para>The <literal>man(7)</literal> man page describes this as "the
247 section number the man page should be placed in (e.g.,
248 <literal>7</literal>)". If we do not find a <sgmltag>manvolnum</sgmltag>
249 specified in the source, and we find that the <sgmltag>refentry</sgmltag> is
250 for a function, we use the section number <literal>3</literal>
251 ["Library calls (functions within program libraries)"]; otherwise, we
252 default to using <literal>1</literal> ["Executable programs or shell
253 commands"].</para>
254 </refdescription>
255
256 <refparameter>
257 <variablelist>
258 <varlistentry>
259 <term>refname</term>
260 <listitem>
261 <para>The first <sgmltag>refname</sgmltag> in the refentry</para>
262 </listitem>
263 </varlistentry>
264 <varlistentry>
265 <term>quiet</term>
266 <listitem>
267 <para>If non-zero, no "missing" message is emitted</para>
268 </listitem>
269 </varlistentry>
270 </variablelist>
271 </refparameter>
272
273 <refreturn>
274 <para>Returns a string representing a section number.</para></refreturn>
275 </doc:template>
276 <xsl:template name="get.refentry.section">
277 <xsl:param name="refname"/>
278 <xsl:param name="quiet" select="0"/>
279 <xsl:choose>
280 <xsl:when test="refmeta/manvolnum">
281 <xsl:value-of select="refmeta/manvolnum"/>
282 </xsl:when>
283 <xsl:otherwise>
284 <xsl:if test="$quiet = 0">
285 <xsl:if test="$refentry.meta.get.quietly = 0">
286 <xsl:call-template name="log.message">
287 <xsl:with-param name="level">Note</xsl:with-param>
288 <xsl:with-param name="source" select="$refname"/>
289 <xsl:with-param
290 name="message"
291 >meta manvol : No manvolnum</xsl:with-param>
292 </xsl:call-template>
293 </xsl:if>
294 </xsl:if>
295 <xsl:choose>
296 <xsl:when test=".//funcsynopsis">
297 <xsl:if test="$quiet = 0">
298 <xsl:if test="$refentry.meta.get.quietly = 0">
299 <xsl:call-template name="log.message">
300 <xsl:with-param name="level">Note</xsl:with-param>
301 <xsl:with-param name="source" select="$refname"/>
302 <xsl:with-param
303 name="message"
304 >meta manvol : Setting man section to 3</xsl:with-param>
305 </xsl:call-template>
306 </xsl:if>
307 </xsl:if>
308 <xsl:text>3</xsl:text>
309 </xsl:when>
310 <xsl:otherwise>
311 <xsl:text>1</xsl:text>
312 </xsl:otherwise>
313 </xsl:choose>
314 </xsl:otherwise>
315 </xsl:choose>
316 </xsl:template>
317
318 <!-- ==================================================================== -->
319
320 <doc:template name="get.refentry.date" xmlns="">
321 <refpurpose>Gets date metadata for a refentry</refpurpose>
322
323 <refdescription>
324 <para>The <literal>man(7)</literal> man page describes this as "the
325 date of the last revision". If we cannot find a date in the source, we
326 generate one.</para>
327 </refdescription>
328
329 <refparameter>
330 <variablelist>
331 <varlistentry>
332 <term>refname</term>
333 <listitem>
334 <para>The first <sgmltag>refname</sgmltag> in the refentry</para>
335 </listitem>
336 </varlistentry>
337 <varlistentry>
338 <term>info</term>
339 <listitem>
340 <para>A set of info nodes (from a <sgmltag>refentry</sgmltag>
341 element and its ancestors)</para>
342 </listitem>
343 </varlistentry>
344 <varlistentry>
345 <term>prefs</term>
346 <listitem>
347 <para>A node containing users preferences (from global stylesheet parameters)</para>
348 </listitem>
349 </varlistentry>
350 </variablelist>
351 </refparameter>
352
353 <refreturn><para>Returns a <sgmltag>date</sgmltag> node.</para></refreturn>
354 </doc:template>
355
356 <xsl:template name="get.refentry.date">
357 <xsl:param name="refname"/>
358 <xsl:param name="info"/>
359 <xsl:param name="prefs"/>
360 <xsl:variable name="Date">
361 <xsl:choose>
362 <!-- * if profiling is enabled for date, and the date -->
363 <!-- * profile is non-empty, use it -->
364 <xsl:when test="not($prefs/@profileEnabled = 0) and
365 not($prefs/@profile = '')">
366 <xsl:call-template name="evaluate.info.profile">
367 <xsl:with-param name="profile" select="$prefs/@profile"/>
368 <xsl:with-param name="info" select="$info"/>
369 </xsl:call-template>
370 </xsl:when>
371 <xsl:otherwise>
372 <!-- * either profiling is not enabled for date, or the-->
373 <!-- * date profile is empty, so we need to look for date -->
374 <!-- * in *info -->
375 <xsl:choose>
376 <!-- * look for date or pubdate in *info -->
377 <xsl:when test="$info/date/node()
378 |$info/pubdate/node()">
379 <xsl:apply-templates
380 select="(($info[date])[last()]/date)[1]|
381 (($info[pubdate])[last()]/pubdate)[1]"/>
382 </xsl:when>
383 <xsl:otherwise>
384 <!-- * found no Date or Pubdate -->
385 </xsl:otherwise>
386 </xsl:choose>
387 </xsl:otherwise>
388 </xsl:choose>
389 </xsl:variable>
390 <xsl:choose>
391 <xsl:when test="not($Date = '')">
392 <xsl:value-of select="$Date"/>
393 </xsl:when>
394 <!-- * We couldn't find a date, so we generate a date. -->
395 <!-- * And we make it an appropriately localized date. -->
396 <xsl:otherwise>
397 <xsl:if test="$refentry.meta.get.quietly = 0">
398 <xsl:call-template name="log.message">
399 <xsl:with-param name="level">Note</xsl:with-param>
400 <xsl:with-param name="source" select="$refname"/>
401 <xsl:with-param
402 name="message"
403 >meta date : No date. Using generated date</xsl:with-param>
404 </xsl:call-template>
405 </xsl:if>
406 <xsl:call-template name="datetime.format">
407 <xsl:with-param name="date">
408 <xsl:choose>
409 <xsl:when test="function-available('date:date-time')">
410 <xsl:value-of select="date:date-time()"/>
411 </xsl:when>
412 <xsl:when test="function-available('date:dateTime')">
413 <!-- Xalan quirk -->
414 <xsl:value-of select="date:dateTime()"/>
415 </xsl:when>
416 </xsl:choose>
417 </xsl:with-param>
418 <xsl:with-param name="format">
419 <xsl:call-template name="gentext.template">
420 <xsl:with-param name="context" select="'datetime'"/>
421 <xsl:with-param name="name" select="'format'"/>
422 </xsl:call-template>
423 </xsl:with-param>
424 </xsl:call-template>
425 </xsl:otherwise>
426 </xsl:choose>
427 </xsl:template>
428
429 <!-- ==================================================================== -->
430
431 <doc:template name="get.refentry.source" xmlns="">
432 <refpurpose>Gets source metadata for a refentry</refpurpose>
433
434 <refdescription>
435 <para>The <literal>man(7)</literal> man page describes this as "the
436 source of the command", and provides the following examples:
437 <itemizedlist>
438 <listitem>
439 <para>For binaries, use something like: GNU, NET-2, SLS
440 Distribution, MCC Distribution.</para>
441 </listitem>
442 <listitem>
443 <para>For system calls, use the version of the kernel that you are
444 currently looking at: Linux 0.99.11.</para>
445 </listitem>
446 <listitem>
447 <para>For library calls, use the source of the function: GNU, BSD
448 4.3, Linux DLL 4.4.1.</para>
449 </listitem>
450 </itemizedlist>
451 </para>
452
453 <para>The <literal>solbook(5)</literal> man page describes
454 something very much like what <literal>man(7)</literal> calls
455 "source", except that <literal>solbook(5)</literal> names it
456 "software" and describes it like this:
457 <blockquote>
458 <para>This is the name of the software product that the topic
459 discussed on the reference page belongs to. For example UNIX
460 commands are part of the <literal>SunOS x.x</literal>
461 release.</para>
462 </blockquote>
463 </para>
464
465 <para>In practice, there are many pages that simply have a version
466 number in the "source" field. So, it looks like what we have is a
467 two-part field,
468 <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>,
469 where:
470 <variablelist>
471 <varlistentry>
472 <term>Name</term>
473 <listitem>
474 <para>product name (e.g., BSD) or org. name (e.g., GNU)</para>
475 </listitem>
476 </varlistentry>
477 <varlistentry>
478 <term>Version</term>
479 <listitem>
480 <para>version name</para>
481 </listitem>
482 </varlistentry>
483 </variablelist>
484 Each part is optional. If the <replaceable>Name</replaceable> is a
485 product name, then the <replaceable>Version</replaceable> is probably
486 the version of the product. Or there may be no
487 <replaceable>Name</replaceable>, in which case, if there is a
488 <replaceable>Version</replaceable>, it is probably the version of the
489 item itself, not the product it is part of. Or, if the
490 <replaceable>Name</replaceable> is an organization name, then there
491 probably will be no <replaceable>Version</replaceable>.
492 </para>
493 </refdescription>
494
495 <refparameter>
496 <variablelist>
497 <varlistentry>
498 <term>refname</term>
499 <listitem>
500 <para>The first <sgmltag>refname</sgmltag> in the refentry</para>
501 </listitem>
502 </varlistentry>
503 <varlistentry>
504 <term>info</term>
505 <listitem>
506 <para>A set of info nodes (from a <sgmltag>refentry</sgmltag>
507 element and its ancestors)</para>
508 </listitem>
509 </varlistentry>
510 <varlistentry>
511 <term>prefs</term>
512 <listitem>
513 <para>A node containing users preferences (from global
514 stylesheet parameters)</para>
515 </listitem>
516 </varlistentry>
517 </variablelist>
518 </refparameter>
519
520 <refreturn><para>Returns a <sgmltag>source</sgmltag> node.</para></refreturn>
521 </doc:template>
522
523 <xsl:template name="get.refentry.source">
524 <xsl:param name="refname"/>
525 <xsl:param name="info"/>
526 <xsl:param name="prefs"/>
527 <xsl:variable name="Name">
528 <xsl:if test="$prefs/Name/@suppress = 0">
529 <xsl:call-template name="get.refentry.source.name">
530 <xsl:with-param name="info" select="$info"/>
531 <xsl:with-param name="refname" select="$refname"/>
532 <xsl:with-param name="prefs" select="$prefs/Name"/>
533 </xsl:call-template>
534 </xsl:if>
535 </xsl:variable>
536 <xsl:variable name="Version">
537 <xsl:if test="$prefs/Version/@suppress = 0">
538 <xsl:call-template name="get.refentry.version">
539 <xsl:with-param name="info" select="$info"/>
540 <xsl:with-param name="refname" select="$refname"/>
541 <xsl:with-param name="prefs" select="$prefs/Version"/>
542 </xsl:call-template>
543 </xsl:if>
544 </xsl:variable>
545 <xsl:choose>
546 <!-- * if we have a Name and/or Version, use either or both -->
547 <!-- * of those, in the form "Name Version" or just "Name" -->
548 <!-- * or just "Version" -->
549 <xsl:when test="not($Name = '') or not($Version = '')">
550 <xsl:choose>
551 <xsl:when test="not($Name = '') and not($Version = '')">
552 <xsl:copy-of select="$Name"/>
553 <xsl:text> </xsl:text>
554 </xsl:when>
555 <xsl:otherwise>
556 <xsl:copy-of select="$Name"/>
557 </xsl:otherwise>
558 </xsl:choose>
559 <xsl:copy-of select="$Version"/>
560 </xsl:when>
561 <!-- * if no Name and no Version, use fallback (if any) -->
562 <xsl:when test="not($prefs/@fallback = '')">
563 <xsl:variable name="source.fallback">
564 <xsl:call-template name="evaluate.info.profile">
565 <xsl:with-param name="profile" select="$prefs/@fallback"/>
566 <xsl:with-param name="info" select="$info"/>
567 </xsl:call-template>
568 </xsl:variable>
569 <xsl:choose>
570 <xsl:when test="not($source.fallback = '')">
571 <xsl:value-of select="$source.fallback"/>
572 </xsl:when>
573 <xsl:otherwise>
574 <xsl:if test="$refentry.meta.get.quietly = 0">
575 <xsl:call-template name="log.message">
576 <xsl:with-param name="level">Warn</xsl:with-param>
577 <xsl:with-param name="source" select="$refname"/>
578 <xsl:with-param
579 name="message"
580 >meta source : No valid fallback. Leaving empty</xsl:with-param>
581 </xsl:call-template>
582 </xsl:if>
583 </xsl:otherwise>
584 </xsl:choose>
585 </xsl:when>
586 <xsl:otherwise>
587 <xsl:if test="$refentry.meta.get.quietly = 0">
588 <xsl:call-template name="log.message">
589 <xsl:with-param name="level">Warn</xsl:with-param>
590 <xsl:with-param name="source" select="$refname"/>
591 <xsl:with-param
592 name="message"
593 >meta source : No fallback specified; leaving empty.</xsl:with-param>
594 </xsl:call-template>
595 </xsl:if>
596 </xsl:otherwise>
597 </xsl:choose>
598 </xsl:template>
599
600 <!-- ==================================================================== -->
601
602 <doc:template name="get.refentry.source.name" xmlns="">
603 <refpurpose>Gets source-name metadata for a refentry</refpurpose>
604
605 <refdescription>
606 <para>A "source name" is one part of a (potentially) two-part
607 <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>
608 source field. For more details, see the documentation for the
609 <function>get.refentry.source</function> template.</para>
610 </refdescription>
611
612 <refparameter>
613 <variablelist>
614 <varlistentry>
615 <term>refname</term>
616 <listitem>
617 <para>The first <sgmltag>refname</sgmltag> in the refentry</para>
618 </listitem>
619 </varlistentry>
620 <varlistentry>
621 <term>info</term>
622 <listitem>
623 <para>A set of info nodes (from a <sgmltag>refentry</sgmltag>
624 element and its ancestors)</para>
625 </listitem>
626 </varlistentry>
627 <varlistentry>
628 <term>prefs</term>
629 <listitem>
630 <para>A node containing users preferences (from global
631 stylesheet parameters)</para>
632 </listitem>
633 </varlistentry>
634 </variablelist>
635 </refparameter>
636
637 <refreturn><para>Depending on what output method is used for the
638 current stylesheet, either returns a text node or possibly an element
639 node, containing "source name" data.</para></refreturn>
640 </doc:template>
641
642 <xsl:template name="get.refentry.source.name">
643 <xsl:param name="refname"/>
644 <xsl:param name="info"/>
645 <xsl:param name="prefs"/>
646 <xsl:choose>
647 <!-- * if profiling is enabled for source.name, and the -->
648 <!-- * source.name profile is non-empty, use it -->
649 <xsl:when test="not($prefs/@profileEnabled = 0) and
650 not($prefs/@profile = '')">
651 <xsl:call-template name="evaluate.info.profile">
652 <xsl:with-param name="profile" select="$prefs/@profile"/>
653 <xsl:with-param name="info" select="$info"/>
654 </xsl:call-template>
655 </xsl:when>
656 <xsl:otherwise>
657 <!-- * either profiling for source.name is not enabled, or-->
658 <!-- * the source.name profile is empty; so we need to look -->
659 <!-- * for a name to use -->
660 <xsl:choose>
661 <xsl:when test="refmeta/refmiscinfo[@class = 'source' or @class = 'software']">
662 <xsl:apply-templates
663 select="refmeta/refmiscinfo[@class = 'source' or @class='software'][1]/node()"/>
664 </xsl:when>
665 <xsl:otherwise>
666 <xsl:choose>
667 <xsl:when test="$info/productname">
668 <xsl:call-template name="set.refentry.metadata">
669 <xsl:with-param name="refname" select="$refname"/>
670 <xsl:with-param
671 name="info"
672 select="($info[productname])[last()]"/>
673 <xsl:with-param
674 name="contents"
675 select="(($info[productname])[last()]/productname)[1]"/>
676 <xsl:with-param name="context">source</xsl:with-param>
677 </xsl:call-template>
678 </xsl:when>
679 <xsl:when test="$info/corpname">
680 <xsl:call-template name="set.refentry.metadata">
681 <xsl:with-param name="refname" select="$refname"/>
682 <xsl:with-param
683 name="info"
684 select="($info[corpname])[last()]"/>
685 <xsl:with-param
686 name="contents"
687 select="(($info[corpname])[last()]/corpname)[1]"/>
688 <xsl:with-param name="context">source</xsl:with-param>
689 <xsl:with-param name="preferred">productname</xsl:with-param>
690 </xsl:call-template>
691 </xsl:when>
692 <xsl:when test="$info/corpcredit">
693 <xsl:call-template name="set.refentry.metadata">
694 <xsl:with-param name="refname" select="$refname"/>
695 <xsl:with-param
696 name="info"
697 select="($info[corpcredit])[last()]"/>
698 <xsl:with-param
699 name="contents"
700 select="(($info[corpcredit])[last()]/corpcredit)[1]"/>
701 <xsl:with-param name="context">source</xsl:with-param>
702 <xsl:with-param name="preferred">productname</xsl:with-param>
703 </xsl:call-template>
704 </xsl:when>
705 <xsl:when test="$info/corpauthor">
706 <xsl:call-template name="set.refentry.metadata">
707 <xsl:with-param name="refname" select="$refname"/>
708 <xsl:with-param
709 name="info"
710 select="($info[corpauthor])[last()]"/>
711 <xsl:with-param
712 name="contents"
713 select="(($info[corpauthor])[last()]/corpauthor)[1]"/>
714 <xsl:with-param name="context">source</xsl:with-param>
715 <xsl:with-param name="preferred">productname</xsl:with-param>
716 </xsl:call-template>
717 </xsl:when>
718 <xsl:when test="$info//orgname">
719 <xsl:call-template name="set.refentry.metadata">
720 <xsl:with-param name="refname" select="$refname"/>
721 <xsl:with-param
722 name="info"
723 select="($info[//orgname])[last()]"/>
724 <xsl:with-param
725 name="contents"
726 select="(($info[//orgname])[last()]//orgname)[1]"/>
727 <xsl:with-param name="context">source</xsl:with-param>
728 <xsl:with-param name="preferred">productname</xsl:with-param>
729 </xsl:call-template>
730 </xsl:when>
731 <xsl:when test="$info//publishername">
732 <xsl:call-template name="set.refentry.metadata">
733 <xsl:with-param name="refname" select="$refname"/>
734 <xsl:with-param
735 name="info"
736 select="($info[//publishername])[last()]"/>
737 <xsl:with-param
738 name="contents"
739 select="(($info[//publishername])[last()]//publishername)[1]"/>
740 <xsl:with-param name="context">source</xsl:with-param>
741 <xsl:with-param name="preferred">productname</xsl:with-param>
742 </xsl:call-template>
743 </xsl:when>
744 <xsl:otherwise>
745 <xsl:if test="$refentry.meta.get.quietly = 0">
746 <xsl:call-template name="log.message">
747 <xsl:with-param name="level">Note</xsl:with-param>
748 <xsl:with-param name="source" select="$refname"/>
749 <xsl:with-param
750 name="message"
751 >meta source : No productname or alternative</xsl:with-param>
752 </xsl:call-template>
753 <xsl:call-template name="log.message">
754 <xsl:with-param name="level">Note</xsl:with-param>
755 <xsl:with-param name="source" select="$refname"/>
756 <xsl:with-param
757 name="message"
758 >meta source : No refmiscinfo@class=source</xsl:with-param>
759 </xsl:call-template>
760 </xsl:if>
761 </xsl:otherwise>
762 </xsl:choose>
763 </xsl:otherwise>
764 </xsl:choose>
765 </xsl:otherwise>
766 </xsl:choose>
767 </xsl:template>
768
769 <!-- ==================================================================== -->
770
771 <doc:template name="get.refentry.version" xmlns="">
772 <refpurpose>Gets version metadata for a refentry</refpurpose>
773
774 <refdescription>
775 <para>A "version" is one part of a (potentially) two-part
776 <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>
777 source field. For more details, see the documentation for the
778 <function>get.refentry.source</function> template.</para>
779 </refdescription>
780
781 <refparameter>
782 <variablelist>
783 <varlistentry>
784 <term>refname</term>
785 <listitem>
786 <para>The first <sgmltag>refname</sgmltag> in the refentry</para>
787 </listitem>
788 </varlistentry>
789 <varlistentry>
790 <term>info</term>
791 <listitem>
792 <para>A set of info nodes (from a <sgmltag>refentry</sgmltag>
793 element and its ancestors)</para>
794 </listitem>
795 </varlistentry>
796 <varlistentry>
797 <term>prefs</term>
798 <listitem>
799 <para>A node containing users preferences (from global
800 stylesheet parameters)</para>
801 </listitem>
802 </varlistentry>
803 </variablelist>
804 </refparameter>
805
806 <refreturn><para>Depending on what output method is used for the
807 current stylesheet, either returns a text node or possibly an element
808 node, containing "version" data.</para></refreturn>
809 </doc:template>
810
811 <xsl:template name="get.refentry.version">
812 <xsl:param name="refname"/>
813 <xsl:param name="info"/>
814 <xsl:param name="prefs"/>
815 <xsl:choose>
816 <!-- * if profiling is enabled for version, and the -->
817 <!-- * version profile is non-empty, use it -->
818 <xsl:when test="not($prefs/@profileEnabled = 0) and
819 not($prefs/@profile = '')">
820 <xsl:call-template name="evaluate.info.profile">
821 <xsl:with-param name="profile" select="$prefs/@profile"/>
822 <xsl:with-param name="info" select="$info"/>
823 </xsl:call-template>
824 </xsl:when>
825 <xsl:otherwise>
826 <!-- * either profiling for source.name is not enabled, or-->
827 <!-- * the source.name profile is empty; so we need to look -->
828 <!-- * for a name to use -->
829 <xsl:choose>
830 <xsl:when test="refmeta/refmiscinfo[@class = 'version']">
831 <xsl:apply-templates
832 select="refmeta/refmiscinfo[@class = 'version'][1]/node()"/>
833 </xsl:when>
834 <xsl:otherwise>
835 <xsl:choose>
836 <xsl:when test="$info/productnumber">
837 <xsl:call-template name="set.refentry.metadata">
838 <xsl:with-param name="refname" select="$refname"/>
839 <xsl:with-param
840 name="info"
841 select="($info[productnumber])[last()]"/>
842 <xsl:with-param
843 name="contents"
844 select="(($info[productnumber])[last()]/productnumber)[1]"/>
845 <xsl:with-param name="context">version</xsl:with-param>
846 </xsl:call-template>
847 </xsl:when>
848 <xsl:when test="$info/edition">
849 <xsl:call-template name="set.refentry.metadata">
850 <xsl:with-param name="refname" select="$refname"/>
851 <xsl:with-param
852 name="info"
853 select="($info[edition])[last()]"/>
854 <xsl:with-param
855 name="contents"
856 select="(($info[edition])[last()]/edition)[1]"/>
857 <xsl:with-param name="context">version</xsl:with-param>
858 <xsl:with-param name="preferred">productnumber</xsl:with-param>
859 </xsl:call-template>
860 </xsl:when>
861 <xsl:when test="$info/releaseinfo">
862 <xsl:call-template name="set.refentry.metadata">
863 <xsl:with-param name="refname" select="$refname"/>
864 <xsl:with-param
865 name="info"
866 select="($info[releaseinfo])[last()]"/>
867 <xsl:with-param
868 name="contents"
869 select="(($info[releaseinfo])[last()]/releaseinfo)[1]"/>
870 <xsl:with-param name="context">version</xsl:with-param>
871 <xsl:with-param name="preferred">productnumber</xsl:with-param>
872 </xsl:call-template>
873 </xsl:when>
874 <xsl:otherwise>
875 <xsl:if test="$refentry.meta.get.quietly = 0">
876 <xsl:call-template name="log.message">
877 <xsl:with-param name="level">Note</xsl:with-param>
878 <xsl:with-param name="source" select="$refname"/>
879 <xsl:with-param
880 name="message"
881 >meta version: No productnumber or alternative</xsl:with-param>
882 </xsl:call-template>
883 <xsl:call-template name="log.message">
884 <xsl:with-param name="level">Note</xsl:with-param>
885 <xsl:with-param name="source" select="$refname"/>
886 <xsl:with-param
887 name="message"
888 >meta version: No refmiscinfo@class=version</xsl:with-param>
889 </xsl:call-template>
890 </xsl:if>
891 </xsl:otherwise>
892 </xsl:choose>
893 </xsl:otherwise>
894 </xsl:choose>
895 </xsl:otherwise>
896 </xsl:choose>
897 </xsl:template>
898
899 <!-- ==================================================================== -->
900
901 <doc:template name="get.refentry.manual" xmlns="">
902 <refpurpose>Gets source metadata for a refentry</refpurpose>
903
904 <refdescription>
905 <para>The <literal>man(7)</literal> man page describes this as "the
906 title of the manual (e.g., <citetitle>Linux Programmer's
907 Manual</citetitle>)". Here are some examples from existing man pages:
908 <itemizedlist>
909 <listitem>
910 <para><citetitle>dpkg utilities</citetitle>
911 (<command>dpkg-name</command>)</para>
912 </listitem>
913 <listitem>
914 <para><citetitle>User Contributed Perl Documentation</citetitle>
915 (<command>GET</command>)</para>
916 </listitem>
917 <listitem>
918 <para><citetitle>GNU Development Tools</citetitle>
919 (<command>ld</command>)</para>
920 </listitem>
921 <listitem>
922 <para><citetitle>Emperor Norton Utilities</citetitle>
923 (<command>ddate</command>)</para>
924 </listitem>
925 <listitem>
926 <para><citetitle>Debian GNU/Linux manual</citetitle>
927 (<command>faked</command>)</para>
928 </listitem>
929 <listitem>
930 <para><citetitle>GIMP Manual Pages</citetitle>
931 (<command>gimp</command>)</para>
932 </listitem>
933 <listitem>
934 <para><citetitle>KDOC Documentation System</citetitle>
935 (<command>qt2kdoc</command>)</para>
936 </listitem>
937 </itemizedlist>
938 </para>
939
940 <para>The <literal>solbook(5)</literal> man page describes
941 something very much like what <literal>man(7)</literal> calls
942 "manual", except that <literal>solbook(5)</literal> names it
943 "sectdesc" and describes it like this:
944 <blockquote>
945 <para>This is the section title of the reference page; for
946 example <literal>User Commands</literal>.</para>
947 </blockquote>
948 </para>
949
950 </refdescription>
951
952 <refparameter>
953 <variablelist>
954 <varlistentry>
955 <term>refname</term>
956 <listitem>
957 <para>The first <sgmltag>refname</sgmltag> in the refentry</para>
958 </listitem>
959 </varlistentry>
960 <varlistentry>
961 <term>info</term>
962 <listitem>
963 <para>A set of info nodes (from a <sgmltag>refentry</sgmltag>
964 element and its ancestors)</para>
965 </listitem>
966 </varlistentry>
967 <varlistentry>
968 <term>prefs</term>
969 <listitem>
970 <para>A node containing users preferences (from global
971 stylesheet parameters)</para>
972 </listitem>
973 </varlistentry>
974 </variablelist>
975 </refparameter>
976
977 <refreturn><para>Returns a <sgmltag>manual</sgmltag> node.</para></refreturn>
978 </doc:template>
979 <xsl:template name="get.refentry.manual">
980 <xsl:param name="refname"/>
981 <xsl:param name="info"/>
982 <xsl:param name="prefs"/>
983 <xsl:variable name="Manual">
984 <xsl:choose>
985 <!-- * if profiling is enabled for manual, and the manual -->
986 <!-- * profile is non-empty, use it -->
987 <xsl:when test="not($prefs/@profileEnabled = 0) and
988 not($prefs/@profile = '')">
989 <xsl:call-template name="evaluate.info.profile">
990 <xsl:with-param name="profile" select="$prefs/@profile"/>
991 <xsl:with-param name="info" select="$info"/>
992 </xsl:call-template>
993 </xsl:when>
994 <xsl:otherwise>
995 <xsl:choose>
996 <xsl:when test="refmeta/refmiscinfo[@class = 'manual' or @class = 'sectdesc']">
997 <xsl:apply-templates
998 select="refmeta/refmiscinfo[@class = 'manual' or @class = 'sectdesc'][1]/node()"/>
999 </xsl:when>
1000 <xsl:otherwise>
1001 <!-- * only in the case of choosing appropriate -->
1002 <!-- * "manual" content do we select the furthest -->
1003 <!-- * (first) matching element instead of the -->
1004 <!-- * closest (last) matching one -->
1005 <xsl:choose>
1006 <xsl:when test="ancestor::*/title">
1007 <xsl:call-template name="set.refentry.metadata">
1008 <xsl:with-param name="refname" select="$refname"/>
1009 <xsl:with-param
1010 name="info"
1011 select="(ancestor::*[title])[1]"/>
1012 <xsl:with-param
1013 name="contents"
1014 select="(ancestor::*[title])[1]/title"/>
1015 <xsl:with-param name="context">manual</xsl:with-param>
1016 </xsl:call-template>
1017 </xsl:when>
1018 <xsl:when test="$info/title">
1019 <xsl:call-template name="set.refentry.metadata">
1020 <xsl:with-param name="refname" select="$refname"/>
1021 <xsl:with-param
1022 name="info"
1023 select="($info[title])[1]"/>
1024 <xsl:with-param
1025 name="contents"
1026 select="(($info[title])[1]/title)[1]"/>
1027 <xsl:with-param name="context">manual</xsl:with-param>
1028 </xsl:call-template>
1029 </xsl:when>
1030 <xsl:otherwise>
1031 <xsl:if test="$refentry.meta.get.quietly = 0">
1032 <xsl:call-template name="log.message">
1033 <xsl:with-param name="level">Note</xsl:with-param>
1034 <xsl:with-param name="source" select="$refname"/>
1035 <xsl:with-param
1036 name="message"
1037 >meta manual : No ancestor with title</xsl:with-param>
1038 </xsl:call-template>
1039 <xsl:call-template name="log.message">
1040 <xsl:with-param name="level">Note</xsl:with-param>
1041 <xsl:with-param name="source" select="$refname"/>
1042 <xsl:with-param
1043 name="message"
1044 >meta manual : No refmiscinfo@class=manual</xsl:with-param>
1045 </xsl:call-template>
1046 </xsl:if>
1047 </xsl:otherwise>
1048 </xsl:choose>
1049 </xsl:otherwise>
1050 </xsl:choose>
1051 </xsl:otherwise>
1052 </xsl:choose>
1053 </xsl:variable>
1054 <xsl:choose>
1055 <xsl:when test="not($Manual = '')">
1056 <xsl:copy-of select="$Manual"/>
1057 </xsl:when>
1058 <!-- * if no Manual, use contents of specified Fallback (if any) -->
1059 <xsl:when test="not($prefs/@fallback = '')">
1060 <xsl:variable name="manual.fallback">
1061 <xsl:call-template name="evaluate.info.profile">
1062 <xsl:with-param name="profile" select="$prefs/@fallback"/>
1063 <xsl:with-param name="info" select="$info"/>
1064 </xsl:call-template>
1065 </xsl:variable>
1066 <xsl:choose>
1067 <xsl:when test="not($manual.fallback = '')">
1068 <xsl:value-of select="$manual.fallback"/>
1069 </xsl:when>
1070 <xsl:otherwise>
1071 <xsl:if test="$refentry.meta.get.quietly = 0">
1072 <xsl:call-template name="log.message">
1073 <xsl:with-param name="level">Warn</xsl:with-param>
1074 <xsl:with-param name="source" select="$refname"/>
1075 <xsl:with-param
1076 name="message"
1077 >meta manual : No valid fallback. Leaving empty</xsl:with-param>
1078 </xsl:call-template>
1079 </xsl:if>
1080 </xsl:otherwise>
1081 </xsl:choose>
1082
1083 </xsl:when>
1084 <xsl:otherwise>
1085 <xsl:if test="$refentry.meta.get.quietly = 0">
1086 <xsl:call-template name="log.message">
1087 <xsl:with-param name="level">Warn</xsl:with-param>
1088 <xsl:with-param name="source" select="$refname"/>
1089 <xsl:with-param
1090 name="message"
1091 >meta manual : No fallback specified; leaving empty.</xsl:with-param>
1092 </xsl:call-template>
1093 </xsl:if>
1094 </xsl:otherwise>
1095 </xsl:choose>
1096 </xsl:template>
1097
1098 <!-- ====================================================================== -->
1099
1100 <doc:template name="get.refentry.metadata.prefs" xmlns="">
1101 <refpurpose>Gets user preferences for refentry metadata gathering</refpurpose>
1102
1103 <refdescription>
1104 <para>The DocBook XSL stylesheets include several user-configurable
1105 global stylesheet parameters for controlling <sgmltag>refentry</sgmltag>
1106 metadata gathering. Those parameters are not read directly by the
1107 other <sgmltag>refentry</sgmltag> metadata-gathering functions. Instead, they
1108 are read only by the <function>get.refentry.metadata.prefs</function>
1109 function, which assembles them into a structure that is then passed to
1110 the other <sgmltag>refentry</sgmltag> metadata-gathering functions.</para>
1111
1112 <para>So the, <function>get.refentry.metadata.prefs</function>
1113 function is the only interface to collecting stylesheet parameters for
1114 controlling <sgmltag>refentry</sgmltag> metadata gathering.</para>
1115 </refdescription>
1116
1117 <refparameter>
1118 <para>There are no local parameters for this function; however, it
1119 does rely on a number of global parameters.</para>
1120 </refparameter>
1121
1122 <refreturn><para>Returns a <sgmltag>manual</sgmltag> node.</para></refreturn>
1123 </doc:template>
1124
1125 <xsl:template name="get.refentry.metadata.prefs">
1126 <DatePrefs>
1127 <xsl:attribute name="profile">
1128 <xsl:value-of select="$refentry.date.profile"/>
1129 </xsl:attribute>
1130 <xsl:attribute name="profileEnabled">
1131 <xsl:value-of select="$refentry.date.profile.enabled"/>
1132 </xsl:attribute>
1133 </DatePrefs>
1134 <SourcePrefs>
1135 <xsl:attribute name="fallback">
1136 <xsl:value-of select="$refentry.source.fallback.profile"/>
1137 </xsl:attribute>
1138 <Name>
1139 <xsl:attribute name="profile">
1140 <xsl:value-of select="$refentry.source.name.profile"/>
1141 </xsl:attribute>
1142 <xsl:attribute name="profileEnabled">
1143 <xsl:value-of select="$refentry.source.name.profile.enabled"/>
1144 </xsl:attribute>
1145 <xsl:attribute name="suppress">
1146 <xsl:value-of select="$refentry.source.name.suppress"/>
1147 </xsl:attribute>
1148 </Name>
1149 <Version>
1150 <xsl:attribute name="profile">
1151 <xsl:value-of select="$refentry.version.profile"/>
1152 </xsl:attribute>
1153 <xsl:attribute name="profileEnabled">
1154 <xsl:value-of select="$refentry.version.profile.enabled"/>
1155 </xsl:attribute>
1156 <xsl:attribute name="suppress">
1157 <xsl:value-of select="$refentry.version.suppress"/>
1158 </xsl:attribute>
1159 </Version>
1160 </SourcePrefs>
1161 <ManualPrefs>
1162 <xsl:attribute name="fallback">
1163 <xsl:value-of select="$refentry.manual.fallback.profile"/>
1164 </xsl:attribute>
1165 <xsl:attribute name="profile">
1166 <xsl:value-of select="$refentry.manual.profile"/>
1167 </xsl:attribute>
1168 <xsl:attribute name="profileEnabled">
1169 <xsl:value-of select="$refentry.manual.profile.enabled"/>
1170 </xsl:attribute>
1171 </ManualPrefs>
1172 </xsl:template>
1173
1174 <!-- ====================================================================== -->
1175
1176 <doc:template name="set.refentry.metadata" xmlns="">
1177 <refpurpose>Sets content of a refentry metadata item</refpurpose>
1178
1179 <refdescription>
1180 <para>The <function>set.refentry.metadata</function> function is
1181 called each time a suitable source element is found for a certain
1182 metadata field.</para>
1183 </refdescription>
1184
1185 <refparameter>
1186 <variablelist>
1187 <varlistentry>
1188 <term>refname</term>
1189 <listitem>
1190 <para>The first <sgmltag>refname</sgmltag> in the refentry</para>
1191 </listitem>
1192 </varlistentry>
1193 <varlistentry>
1194 <term>info</term>
1195 <listitem>
1196 <para>A single *info node that contains the selected source element.</para>
1197 </listitem>
1198 </varlistentry>
1199 <varlistentry>
1200 <term>contents</term>
1201 <listitem>
1202 <para>A node containing the selected source element.</para>
1203 </listitem>
1204 </varlistentry>
1205 <varlistentry>
1206 <term>context</term>
1207 <listitem>
1208 <para>A string describing the metadata context in which the
1209 <function>set.refentry.metadata</function> function was
1210 called: either "date", "source", "version", or "manual".</para>
1211 </listitem>
1212 </varlistentry>
1213 </variablelist>
1214 </refparameter>
1215 <refreturn>
1216 <para>Returns formatted contents of a selected source element.</para></refreturn>
1217 </doc:template>
1218
1219 <xsl:template name="set.refentry.metadata">
1220 <xsl:param name="refname"/>
1221 <xsl:param name="info"/>
1222 <xsl:param name="contents"/>
1223 <xsl:param name="context"/>
1224 <xsl:param name="preferred"/>
1225 <xsl:if test="not($preferred = '')">
1226 <xsl:if test="$refentry.meta.get.quietly = 0">
1227 <xsl:call-template name="log.message">
1228 <xsl:with-param name="level">Note</xsl:with-param>
1229 <xsl:with-param name="source" select="$refname"/>
1230 <xsl:with-param
1231 name="message"
1232 >meta <xsl:value-of
1233 select="$context"/><xsl:call-template
1234 name="copy-string">
1235 <xsl:with-param name="string" select="'&#x20;'"/>
1236 <xsl:with-param
1237 name="count"
1238 select="7 - string-length($context)"/>
1239 </xsl:call-template>: No <xsl:value-of select="$preferred"
1240 /></xsl:with-param>
1241 </xsl:call-template>
1242 <xsl:call-template name="log.message">
1243 <xsl:with-param name="level">Note</xsl:with-param>
1244 <xsl:with-param name="source" select="$refname"/>
1245 <xsl:with-param
1246 name="message"
1247 >meta <xsl:value-of
1248 select="$context"/><xsl:call-template
1249 name="copy-string">
1250 <xsl:with-param name="string" select="'&#x20;'"/>
1251 <xsl:with-param
1252 name="count"
1253 select="7 - string-length($context)"/>
1254 </xsl:call-template>: No refmiscinfo@class=<xsl:value-of
1255 select="$context"/></xsl:with-param>
1256 </xsl:call-template>
1257 <xsl:call-template name="log.message">
1258 <xsl:with-param name="level">Note</xsl:with-param>
1259 <xsl:with-param name="source" select="$refname"/>
1260 <xsl:with-param
1261 name="message"
1262 >meta <xsl:value-of
1263 select="$context"/><xsl:call-template
1264 name="copy-string">
1265 <xsl:with-param name="string" select="'&#x20;'"/>
1266 <xsl:with-param
1267 name="count"
1268 select="7 - string-length($context)"/>
1269 </xsl:call-template>: Using <xsl:value-of
1270 select="local-name($contents)"/></xsl:with-param>
1271 </xsl:call-template>
1272 </xsl:if>
1273 </xsl:if>
1274 <xsl:value-of select="$contents"/>
1275 </xsl:template>
1276
1277 </xsl:stylesheet>