~ubuntu-branches/ubuntu/quantal/freeguide/quantal

« back to all changes in this revision

Viewing changes to doc/docbook-xsl-1.69.1/common/refentry.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Shaun Jackman
  • Date: 2006-09-30 10:14:18 UTC
  • mfrom: (1.2.3 upstream) (3.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060930101418-pkilk36yy22nbt3r
Tags: 0.10.4-2
Update the watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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: refentry.xsl 1179 2005-11-22 08:26:49Z axis3x3 $
 
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: refentry.xsl 1179 2005-11-22 08:26:49Z axis3x3 $
 
24
    </releaseinfo>
 
25
    <author><orgname>The DocBook Project</orgname></author>
 
26
    <copyright><year>2005</year>
 
27
    <holder>The DocBook Project</holder>
 
28
    </copyright>
 
29
  </referenceinfo>
 
30
  <title>Refentry Metadata-Gathering Template Reference</title>
 
31
 
 
32
  <partintro>
 
33
    <section><title>Introduction</title>
 
34
 
 
35
    <para>This is technical reference documentation for the "refentry
 
36
    metadata gathering" templates in the DocBook XSL Stylesheets.</para>
 
37
 
 
38
    <para>This is not intended to be user documentation. It is provided
 
39
    for developers writing customization layers for the
 
40
    stylesheets.</para>
 
41
 
 
42
    <note>
 
43
      <para>Currently, only the manpages stylesheets make use of these
 
44
      templates. They are, however, potentially useful elsewhere.</para>
 
45
    </note>
 
46
 
 
47
    </section>
 
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 parent</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 <tag>refentry</tag>.</para>
 
63
 
 
64
    <para>However, one problem is that mark up that context information in
 
65
    different ways. Often (usually), it is not actually part fo the
 
66
    content of the <tag>refentry</tag> itself, but instead part of its
 
67
    parent element's content. And even then, DocBook provides a variety of
 
68
    elements that users might potentially use to mark up the same kind of
 
69
    information. One user might use the <tag>productnumber</tag> element
 
70
    to mark up version information about a particular product, while
 
71
    another might use the <tag>releaseinfo</tag> element.</para>
 
72
 
 
73
    <para>Taking all that in mind, the
 
74
    <function>get.refentry.info</function> function tries to gather data
 
75
    from a <tag>refentry</tag> element and its parent element in an
 
76
    intelligent and user-configurable way.</para>
 
77
 
 
78
    <note>
 
79
      <para>The <function>get.refentry.info</function> is actually just
 
80
      sort of a "driver" function; it calls other function that do that
 
81
      actual data collection, the returns the data as a set.</para>
 
82
    </note>
 
83
 
 
84
    <para>The manpages stylesheets are an application of these APIs.</para>
 
85
  </refdescription>
 
86
 
 
87
  <refparameter>
 
88
    <variablelist>
 
89
      <varlistentry>
 
90
        <term>refname</term>
 
91
        <listitem>
 
92
          <para>The first <tag>refname</tag> in the refentry</para>
 
93
        </listitem>
 
94
      </varlistentry>
 
95
      <varlistentry>
 
96
        <term>info</term>
 
97
        <listitem>
 
98
          <para>An info node (from a <tag>refentry</tag> element)</para>
 
99
        </listitem>
 
100
      </varlistentry>
 
101
      <varlistentry>
 
102
        <term>parentinfo</term>
 
103
        <listitem>
 
104
          <para>An info node (from a parent of a <tag>refentry</tag>
 
105
          element)</para>
 
106
        </listitem>
 
107
      </varlistentry>
 
108
      <varlistentry>
 
109
        <term>prefs</term>
 
110
        <listitem>
 
111
          <para>A node containing users 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="parentinfo"/>
 
164
  <xsl:param name="prefs"/>
 
165
  <title>
 
166
    <xsl:call-template name="get.refentry.title">
 
167
      <xsl:with-param name="refname" select="$refname"/>
 
168
    </xsl:call-template>
 
169
  </title>
 
170
  <section>
 
171
    <xsl:call-template name="get.refentry.section"/>
 
172
  </section>
 
173
  <date>
 
174
    <xsl:call-template name="get.refentry.date">
 
175
      <xsl:with-param name="info" select="$info"/>
 
176
      <xsl:with-param name="parentinfo" select="$parentinfo"/>
 
177
      <xsl:with-param name="prefs" select="$prefs/DatePrefs"/>
 
178
    </xsl:call-template>
 
179
  </date>
 
180
  <source>
 
181
    <xsl:call-template name="get.refentry.source">
 
182
      <xsl:with-param name="info" select="$info"/>
 
183
      <xsl:with-param name="parentinfo" select="$parentinfo"/>
 
184
      <xsl:with-param name="prefs" select="$prefs/SourcePrefs"/>
 
185
    </xsl:call-template>
 
186
  </source>
 
187
  <manual>
 
188
    <xsl:call-template name="get.refentry.manual">
 
189
      <xsl:with-param name="info" select="$info"/>
 
190
      <xsl:with-param name="parentinfo" select="$parentinfo"/>
 
191
      <xsl:with-param name="prefs" select="$prefs/ManualPrefs"/>
 
192
    </xsl:call-template>
 
193
  </manual>
 
194
</xsl:template>
 
195
 
 
196
<!-- ====================================================================== -->
 
197
 
 
198
<doc:template name="get.refentry.title" xmlns="">
 
199
  <refpurpose>Gets title metadata for a refentry</refpurpose>
 
200
 
 
201
  <refdescription>
 
202
    <para>The <literal>man(7)</literal> man page describes this as "the
 
203
    title of the man page (e.g., <literal>MAN</literal>). This differs
 
204
    from <tag>refname</tag> in that, if the <tag>refentry</tag> has a
 
205
    <tag>refentrytitle</tag>, we use that as the <tag>title</tag>;
 
206
    otherwise, we just use first <tag>refname</tag> in the first
 
207
    <tag>refnamediv</tag> in the source.</para>
 
208
  </refdescription>
 
209
 
 
210
  <refparameter>
 
211
    <variablelist>
 
212
      <varlistentry>
 
213
        <term>refname</term>
 
214
        <listitem>
 
215
          <para>The first <tag>refname</tag> in the refentry</para>
 
216
        </listitem>
 
217
      </varlistentry>
 
218
    </variablelist>
 
219
  </refparameter>
 
220
 
 
221
  <refreturn>
 
222
  <para>Returns a <tag>title</tag> node.</para></refreturn>
 
223
</doc:template>
 
224
 
 
225
<xsl:template name="get.refentry.title">
 
226
  <xsl:param name="refname"/>
 
227
  <xsl:choose>
 
228
    <xsl:when test="refmeta/refentrytitle">
 
229
      <xsl:copy>
 
230
        <xsl:apply-templates select="refmeta/refentrytitle/node()"/>
 
231
      </xsl:copy>
 
232
    </xsl:when>
 
233
    <xsl:otherwise>
 
234
      <xsl:copy-of select="$refname"/>
 
235
    </xsl:otherwise>
 
236
  </xsl:choose>
 
237
</xsl:template>
 
238
 
 
239
<!-- ==================================================================== -->
 
240
 
 
241
<doc:template name="get.refentry.section" xmlns="">
 
242
  <refpurpose>Gets section metadata for a refentry</refpurpose>
 
243
 
 
244
  <refdescription>
 
245
    <para>The <literal>man(7)</literal> man page describes this as "the
 
246
    section number the man page should be placed in (e.g.,
 
247
    <literal>7</literal>)". If we do not find a <tag>manvolnum</tag>
 
248
    specified in the source, and we find that the <tag>refentry</tag> is
 
249
    for a function, we use the section number <literal>3</literal>
 
250
    ["Library calls (functions within program libraries)"]; otherwise, we
 
251
    default to using <literal>1</literal> ["Executable programs or shell
 
252
    commands"].</para>
 
253
  </refdescription>
 
254
 
 
255
  <refparameter><para>[none]</para></refparameter>
 
256
 
 
257
  <refreturn>
 
258
  <para>Returns a <tag>section</tag> node.</para></refreturn>
 
259
</doc:template>
 
260
<xsl:template name="get.refentry.section">
 
261
  <xsl:choose>
 
262
    <xsl:when test="refmeta/manvolnum">
 
263
      <xsl:value-of select="refmeta/manvolnum"/>
 
264
    </xsl:when>
 
265
    <xsl:when test=".//funcsynopsis">3</xsl:when>
 
266
    <xsl:otherwise>1</xsl:otherwise>
 
267
  </xsl:choose>
 
268
</xsl:template>
 
269
 
 
270
<!-- ==================================================================== -->
 
271
 
 
272
<doc:template name="get.refentry.date" xmlns="">
 
273
  <refpurpose>Gets date metadata for a refentry</refpurpose>
 
274
 
 
275
  <refdescription>
 
276
    <para>The <literal>man(7)</literal> man page describes this as "the
 
277
    date of the last revision". If we cannot find a date in the source, we
 
278
    generate one.</para>
 
279
  </refdescription>
 
280
 
 
281
  <refparameter>
 
282
    <variablelist>
 
283
      <varlistentry>
 
284
        <term>info</term>
 
285
        <listitem>
 
286
          <para>An info node (from a <tag>refentry</tag> element)</para>
 
287
        </listitem>
 
288
      </varlistentry>
 
289
      <varlistentry>
 
290
        <term>parentinfo</term>
 
291
        <listitem>
 
292
          <para>An info node (from a parent of a <tag>refentry</tag> element)</para>
 
293
        </listitem>
 
294
      </varlistentry>
 
295
      <varlistentry>
 
296
        <term>prefs</term>
 
297
        <listitem>
 
298
          <para>A node containing users preferences (from global stylesheet parameters)</para>
 
299
        </listitem>
 
300
      </varlistentry>
 
301
    </variablelist>
 
302
  </refparameter>
 
303
 
 
304
  <refreturn><para>Returns a <tag>date</tag> node.</para></refreturn>
 
305
</doc:template>
 
306
 
 
307
<xsl:template name="get.refentry.date">
 
308
  <xsl:param name="info"/>
 
309
  <xsl:param name="parentinfo"/>
 
310
  <xsl:param name="prefs"/>
 
311
  <xsl:variable name="Date">
 
312
    <xsl:choose>
 
313
      <!-- * if profiling is enabled for date, and the date -->
 
314
      <!-- * profile is non-empty, use it -->
 
315
      <xsl:when test="$prefs/@profileEnabled != '0' and
 
316
                      $prefs/@profile != ''">
 
317
        <xsl:call-template name="evaluate.info.profile">
 
318
          <xsl:with-param name="profile" select="$prefs/@profile"/>
 
319
          <xsl:with-param name="info" select="$info"/>
 
320
          <xsl:with-param name="parentinfo" select="$parentinfo"/>
 
321
        </xsl:call-template>
 
322
      </xsl:when>
 
323
      <xsl:otherwise>
 
324
        <!-- * either profiling is not enabled for date, or the-->
 
325
        <!-- * date profile is empty, so we need to look for date -->
 
326
        <!-- * first in *info, then in parentinfo -->
 
327
        <xsl:choose>
 
328
          <!-- * look for date or pubdate in *info -->
 
329
          <xsl:when test="$info/date
 
330
                          |$info/pubdate">
 
331
            <xsl:copy>
 
332
              <xsl:apply-templates
 
333
                  select="($info/date
 
334
                          |$info/pubdate)[1]/node()"/>
 
335
            </xsl:copy>
 
336
          </xsl:when>
 
337
          <!-- * look for date or pubdate in parentinfo -->
 
338
          <xsl:otherwise>
 
339
            <xsl:copy>
 
340
              <xsl:apply-templates
 
341
                  select="($parentinfo/date
 
342
                          |$parentinfo/pubdate)[1]/node()"/>
 
343
            </xsl:copy>
 
344
          </xsl:otherwise>
 
345
        </xsl:choose>
 
346
      </xsl:otherwise>
 
347
    </xsl:choose>
 
348
  </xsl:variable>
 
349
  <xsl:choose>
 
350
    <xsl:when test="$Date != ''">
 
351
      <xsl:value-of select="$Date"/>
 
352
    </xsl:when>
 
353
    <!-- * We couldn't find a date, so we generate a date. -->
 
354
    <!-- * And we make it an appropriately localized date. -->
 
355
    <xsl:otherwise>
 
356
      <xsl:call-template name="datetime.format">
 
357
        <xsl:with-param name="date">
 
358
          <xsl:choose>
 
359
            <xsl:when test="function-available('date:date-time')">
 
360
              <xsl:value-of select="date:date-time()"/>
 
361
            </xsl:when>
 
362
            <xsl:when test="function-available('date:dateTime')">
 
363
              <!-- Xalan quirk -->
 
364
              <xsl:value-of select="date:dateTime()"/>
 
365
            </xsl:when>
 
366
          </xsl:choose>
 
367
        </xsl:with-param>
 
368
        <xsl:with-param name="format">
 
369
          <xsl:call-template name="gentext.template">
 
370
            <xsl:with-param name="context" select="'datetime'"/>
 
371
            <xsl:with-param name="name" select="'format'"/>
 
372
          </xsl:call-template>
 
373
        </xsl:with-param>
 
374
      </xsl:call-template>
 
375
    </xsl:otherwise>
 
376
  </xsl:choose>
 
377
</xsl:template>
 
378
 
 
379
<!-- ==================================================================== -->
 
380
 
 
381
<doc:template name="get.refentry.source" xmlns="">
 
382
  <refpurpose>Gets source metadata for a refentry</refpurpose>
 
383
 
 
384
  <refdescription>
 
385
    <para>The <literal>man(7)</literal> man page describes this as "the
 
386
    source of the command", and provides the following examples:
 
387
    <itemizedlist>
 
388
      <listitem>
 
389
        <para>For binaries, use something like: GNU, NET-2, SLS
 
390
        Distribution, MCC Distribution.</para>
 
391
      </listitem>
 
392
      <listitem>
 
393
        <para>For system calls, use the version of the kernel that you are
 
394
        currently looking at: Linux 0.99.11.</para>
 
395
      </listitem>
 
396
      <listitem>
 
397
        <para>For library calls, use the source of the function: GNU, BSD
 
398
        4.3, Linux DLL 4.4.1.</para>
 
399
      </listitem>
 
400
    </itemizedlist>
 
401
    </para>
 
402
 
 
403
    <para>In practice, there are many pages that simply have a version
 
404
    number in the "source" field. So, it looks like what we have is a
 
405
    two-part field,
 
406
    <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>,
 
407
    where:
 
408
    <variablelist>
 
409
      <varlistentry>
 
410
        <term>Name</term>
 
411
        <listitem>
 
412
          <para>product name (e.g., BSD) or org. name (e.g., GNU)</para>
 
413
        </listitem>
 
414
      </varlistentry>
 
415
      <varlistentry>
 
416
        <term>Version</term>
 
417
        <listitem>
 
418
          <para>version name</para>
 
419
        </listitem>
 
420
      </varlistentry>
 
421
    </variablelist>
 
422
    Each part is optional. If the <replaceable>Name</replaceable> is a
 
423
    product name, then the <replaceable>Version</replaceable> is probably
 
424
    the version of the product. Or there may be no
 
425
    <replaceable>Name</replaceable>, in which case, if there is a
 
426
    <replaceable>Version</replaceable>, it is probably the version of the
 
427
    item itself, not the product it is part of. Or, if the
 
428
    <replaceable>Name</replaceable> is an organization name, then there
 
429
    probably will be no <replaceable>Version</replaceable>.
 
430
    </para>
 
431
  </refdescription>
 
432
 
 
433
  <refparameter>
 
434
    <variablelist>
 
435
      <varlistentry>
 
436
        <term>info</term>
 
437
        <listitem>
 
438
          <para>An info node (from a <tag>refentry</tag> element)</para>
 
439
        </listitem>
 
440
      </varlistentry>
 
441
      <varlistentry>
 
442
        <term>parentinfo</term>
 
443
        <listitem>
 
444
          <para>An info node (from a parent of a <tag>refentry</tag> element)</para>
 
445
        </listitem>
 
446
      </varlistentry>
 
447
      <varlistentry>
 
448
        <term>prefs</term>
 
449
        <listitem>
 
450
          <para>A node containing users preferences (from global
 
451
          stylesheet parameters)</para>
 
452
        </listitem>
 
453
      </varlistentry>
 
454
    </variablelist>
 
455
  </refparameter>
 
456
 
 
457
  <refreturn><para>Returns a <tag>source</tag> node.</para></refreturn>
 
458
</doc:template>
 
459
 
 
460
<xsl:template name="get.refentry.source">
 
461
  <xsl:param name="info"/>
 
462
  <xsl:param name="parentinfo"/>
 
463
  <xsl:param name="prefs"/>
 
464
  <xsl:variable name="Name">
 
465
    <xsl:if test="$prefs/Name/@suppress = '0'">
 
466
      <xsl:call-template name="get.refentry.source.name">
 
467
        <xsl:with-param name="info" select="$info"/>
 
468
        <xsl:with-param name="parentinfo" select="$parentinfo"/>
 
469
        <xsl:with-param name="prefs" select="$prefs/Name"/>
 
470
      </xsl:call-template>
 
471
    </xsl:if>
 
472
  </xsl:variable>
 
473
  <xsl:variable name="Version">
 
474
    <xsl:if test="$prefs/Version/@suppress = '0'">
 
475
      <xsl:call-template name="get.refentry.version">
 
476
        <xsl:with-param name="info" select="$info"/>
 
477
        <xsl:with-param name="parentinfo" select="$parentinfo"/>
 
478
        <xsl:with-param name="prefs" select="$prefs/Version"/>
 
479
      </xsl:call-template>
 
480
    </xsl:if>
 
481
  </xsl:variable>
 
482
  <xsl:choose>
 
483
    <!-- * if we have a Name and/or Version, use either or both -->
 
484
    <!-- * of those, in the form "Name Version" or just "Name" -->
 
485
    <!-- * or just "Version" -->
 
486
    <xsl:when test="$Name != '' or $Version != ''">
 
487
      <xsl:choose>
 
488
        <xsl:when test="$Name != '' and $Version != ''">
 
489
          <xsl:copy-of select="$Name"/>
 
490
          <xsl:text> </xsl:text>
 
491
        </xsl:when>
 
492
        <xsl:otherwise>
 
493
          <xsl:copy-of select="$Name"/>
 
494
        </xsl:otherwise>
 
495
      </xsl:choose>
 
496
      <xsl:copy-of select="$Version"/>
 
497
    </xsl:when>
 
498
    <!-- * if no Name and no Version, use fallback (if any) -->
 
499
    <xsl:when test="$prefs/@fallback != ''">
 
500
      <xsl:call-template name="evaluate.info.profile">
 
501
        <xsl:with-param name="profile" select="$prefs/@fallback"/>
 
502
        <xsl:with-param name="info" select="$info"/>
 
503
        <xsl:with-param name="parentinfo" select="$parentinfo"/>
 
504
      </xsl:call-template>
 
505
    </xsl:when>
 
506
    <xsl:otherwise>
 
507
      <!-- * found nothing, so leave <source> empty -->
 
508
    </xsl:otherwise>
 
509
  </xsl:choose>
 
510
</xsl:template>
 
511
 
 
512
<!-- ==================================================================== -->
 
513
 
 
514
<doc:template name="get.refentry.source.name" xmlns="">
 
515
  <refpurpose>Gets source-name metadata for a refentry</refpurpose>
 
516
 
 
517
  <refdescription>
 
518
    <para>A "source name" is one part of a (potentially) two-part
 
519
    <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>
 
520
    source field. For more details, see the documentation for the
 
521
    <function>get.refentry.source</function> template.</para>
 
522
  </refdescription>
 
523
 
 
524
  <refparameter>
 
525
    <variablelist>
 
526
      <varlistentry>
 
527
        <term>info</term>
 
528
        <listitem>
 
529
          <para>An info node (from a <tag>refentry</tag> element)</para>
 
530
        </listitem>
 
531
      </varlistentry>
 
532
      <varlistentry>
 
533
        <term>parentinfo</term>
 
534
        <listitem>
 
535
          <para>An info node (from a parent of a <tag>refentry</tag> element)</para>
 
536
        </listitem>
 
537
      </varlistentry>
 
538
      <varlistentry>
 
539
        <term>prefs</term>
 
540
        <listitem>
 
541
          <para>A node containing users preferences (from global
 
542
          stylesheet parameters)</para>
 
543
        </listitem>
 
544
      </varlistentry>
 
545
    </variablelist>
 
546
  </refparameter>
 
547
 
 
548
  <refreturn><para>Depending on what output method is used for the
 
549
  current stylesheet, either returns a text node or possibly an element
 
550
  node, containing "source name" data.</para></refreturn>
 
551
</doc:template>
 
552
 
 
553
<xsl:template name="get.refentry.source.name">
 
554
  <xsl:param name="info"/>
 
555
  <xsl:param name="parentinfo"/>
 
556
  <xsl:param name="prefs"/>
 
557
  <xsl:choose>
 
558
    <!-- * if profiling is enabled for source.name, and the -->
 
559
    <!-- * source.name profile is non-empty, use it -->
 
560
    <xsl:when test="$prefs/@profileEnabled != '0' and
 
561
                    $prefs/@profile != ''">
 
562
      <xsl:message>using source.name profile</xsl:message>
 
563
      <xsl:call-template name="evaluate.info.profile">
 
564
        <xsl:with-param name="profile" select="$prefs/@profile"/>
 
565
        <xsl:with-param name="info" select="$info"/>
 
566
        <xsl:with-param name="parentinfo" select="$parentinfo"/>
 
567
      </xsl:call-template>
 
568
    </xsl:when>
 
569
    <xsl:otherwise>
 
570
      <!-- * either profiling for source.name is not enabled, or-->
 
571
      <!-- * the source.name profile is empty; so we need to look -->
 
572
      <!-- * for a name to use -->
 
573
      <xsl:choose>
 
574
        <xsl:when test="refmeta/refmiscinfo[@class = 'source']">
 
575
          <xsl:apply-templates 
 
576
              select="refmeta/refmiscinfo[@class = 'source'][1]/node()"/>
 
577
        </xsl:when>
 
578
        <!-- * no <refmisc class="source"/> found, so we need to -->
 
579
        <!-- * check *info and parentinfo -->
 
580
        <xsl:when test="$info/productname">
 
581
          <xsl:apply-templates select="$info/productname/node()"/>
 
582
        </xsl:when>
 
583
        <xsl:when test="$info/orgname">
 
584
          <xsl:apply-templates select="$info/orgname/node()"/>
 
585
        </xsl:when>
 
586
        <xsl:when test="$info/corpname">
 
587
          <xsl:apply-templates select="$info/corpname/node()"/>
 
588
        </xsl:when>
 
589
        <xsl:when test="$info/corpcredit">
 
590
          <xsl:apply-templates select="$info/corpcredit/node()"/>
 
591
        </xsl:when>
 
592
        <xsl:when test="$info/corpauthor">
 
593
          <xsl:apply-templates select="$info/corpauthor/node()"/>
 
594
        </xsl:when>
 
595
        <xsl:when test="$info/author/orgname">
 
596
          <xsl:apply-templates select="$info/author/orgname/node()"/>
 
597
        </xsl:when>
 
598
        <xsl:when test="$info/author/publishername">
 
599
          <xsl:apply-templates select="$info/author/publishername/node()"/>
 
600
        </xsl:when>
 
601
        <!-- * then check parentinfo -->
 
602
        <xsl:when test="$parentinfo/productname">
 
603
          <xsl:apply-templates select="$parentinfo/productname/node()"/>
 
604
        </xsl:when>
 
605
        <xsl:when test="$parentinfo/orgname">
 
606
          <xsl:apply-templates select="$parentinfo/orgname/node()"/>
 
607
        </xsl:when>
 
608
        <xsl:when test="$parentinfo/corpname">
 
609
          <xsl:apply-templates select="$parentinfo/corpname/node()"/>
 
610
        </xsl:when>
 
611
        <xsl:when test="$parentinfo/corpcredit">
 
612
          <xsl:apply-templates select="$parentinfo/corpcredit/node()"/>
 
613
        </xsl:when>
 
614
        <xsl:when test="$parentinfo/corpauthor">
 
615
          <xsl:apply-templates select="$parentinfo/corpauthor/node()"/>
 
616
        </xsl:when>
 
617
        <xsl:when test="$parentinfo/author/orgname">
 
618
          <xsl:apply-templates select="$parentinfo/author/orgname/node()"/>
 
619
        </xsl:when>
 
620
        <xsl:when test="$parentinfo/author/publishername">
 
621
          <xsl:apply-templates select="$parentinfo/author/publishername/node()"/>
 
622
        </xsl:when>
 
623
        <xsl:otherwise>
 
624
          <!-- * found nothing, so return nothing -->
 
625
        </xsl:otherwise>
 
626
      </xsl:choose>
 
627
    </xsl:otherwise>
 
628
  </xsl:choose>
 
629
</xsl:template>
 
630
 
 
631
<!-- ==================================================================== -->
 
632
 
 
633
<doc:template name="get.refentry.version" xmlns="">
 
634
  <refpurpose>Gets version metadata for a refentry</refpurpose>
 
635
 
 
636
  <refdescription>
 
637
    <para>A "version" is one part of a (potentially) two-part
 
638
    <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>
 
639
    source field. For more details, see the documentation for the
 
640
    <function>get.refentry.source</function> template.</para>
 
641
  </refdescription>
 
642
 
 
643
  <refparameter>
 
644
    <variablelist>
 
645
      <varlistentry>
 
646
        <term>info</term>
 
647
        <listitem>
 
648
          <para>An info node (from a <tag>refentry</tag> element)</para>
 
649
        </listitem>
 
650
      </varlistentry>
 
651
      <varlistentry>
 
652
        <term>parentinfo</term>
 
653
        <listitem>
 
654
          <para>An info node (from a parent of a <tag>refentry</tag> element)</para>
 
655
        </listitem>
 
656
      </varlistentry>
 
657
      <varlistentry>
 
658
        <term>prefs</term>
 
659
        <listitem>
 
660
          <para>A node containing users preferences (from global
 
661
          stylesheet parameters)</para>
 
662
        </listitem>
 
663
      </varlistentry>
 
664
    </variablelist>
 
665
  </refparameter>
 
666
 
 
667
  <refreturn><para>Depending on what output method is used for the
 
668
  current stylesheet, either returns a text node or possibly an element
 
669
  node, containing "version" data.</para></refreturn>
 
670
</doc:template>
 
671
 
 
672
<xsl:template name="get.refentry.version">
 
673
  <xsl:param name="info"/>
 
674
  <xsl:param name="parentinfo"/>
 
675
  <xsl:param name="prefs"/>
 
676
  <xsl:choose>
 
677
    <!-- * if profiling is enabled for version, and the -->
 
678
    <!-- * version profile is non-empty, use it -->
 
679
    <xsl:when test="$prefs/@profileEnabled != '0' and
 
680
                    $prefs/@profile != ''">
 
681
      <xsl:message>using version profile</xsl:message>
 
682
      <xsl:call-template name="evaluate.info.profile">
 
683
        <xsl:with-param name="profile" select="$prefs/@profile"/>
 
684
        <xsl:with-param name="info" select="$info"/>
 
685
        <xsl:with-param name="parentinfo" select="$parentinfo"/>
 
686
      </xsl:call-template>
 
687
    </xsl:when>
 
688
    <xsl:otherwise>
 
689
      <!-- * either profiling for source.name is not enabled, or-->
 
690
      <!-- * the source.name profile is empty; so we need to look -->
 
691
      <!-- * for a name to use -->
 
692
      <xsl:choose>
 
693
        <xsl:when test="refmeta/refmiscinfo[@class = 'version']">
 
694
          <xsl:apply-templates 
 
695
              select="refmeta/refmiscinfo[@class = 'version'][1]/node()"/>
 
696
        </xsl:when>
 
697
        <!-- * no <refmisc class="version"/> found, so we need to -->
 
698
        <!-- * check *info and parentinfo -->
 
699
        <xsl:when test="$info/productnumber">
 
700
          <xsl:apply-templates select="$info/productnumber/node()"/>
 
701
        </xsl:when>
 
702
        <xsl:when test="$info/edition">
 
703
          <xsl:apply-templates select="$info/edition/node()"/>
 
704
        </xsl:when>
 
705
        <xsl:when test="$info/releaseinfo">
 
706
          <xsl:apply-templates select="$info/releaseinfo/node()"/>
 
707
        </xsl:when>
 
708
        <!-- * then check parentinfo -->
 
709
        <xsl:when test="$parentinfo/productnumber">
 
710
          <xsl:apply-templates select="$parentinfo/productnumber/node()"/>
 
711
        </xsl:when>
 
712
        <xsl:when test="$parentinfo/edition">
 
713
          <xsl:apply-templates select="$parentinfo/edition/node()"/>
 
714
        </xsl:when>
 
715
        <xsl:when test="$parentinfo/releaseinfo">
 
716
          <xsl:apply-templates select="$parentinfo/releaseinfo/node()"/>
 
717
        </xsl:when>
 
718
        <xsl:otherwise>
 
719
          <!-- *found nothing, so return nothing -->
 
720
        </xsl:otherwise>
 
721
      </xsl:choose>
 
722
    </xsl:otherwise>
 
723
  </xsl:choose>
 
724
</xsl:template>
 
725
 
 
726
<!-- ==================================================================== -->
 
727
 
 
728
<doc:template name="get.refentry.manual" xmlns="">
 
729
  <refpurpose>Gets source metadata for a refentry</refpurpose>
 
730
 
 
731
  <refdescription>
 
732
    <para>The <literal>man(7)</literal> man page describes this as "the
 
733
    title of the manual (e.g., <citetitle>Linux Programmer's
 
734
    Manual</citetitle>)". Here are some examples from existing man pages:
 
735
    <itemizedlist>
 
736
      <listitem>
 
737
        <para><citetitle>dpkg utilities</citetitle>
 
738
        (<command>dpkg-name</command>)</para>
 
739
      </listitem>
 
740
      <listitem>
 
741
        <para><citetitle>User Contributed Perl Documentation</citetitle>
 
742
        (<command>GET</command>)</para>
 
743
      </listitem>
 
744
      <listitem>
 
745
        <para><citetitle>GNU Development Tools</citetitle>
 
746
        (<command>ld</command>)</para>
 
747
      </listitem>
 
748
      <listitem>
 
749
        <para><citetitle>Emperor Norton Utilities</citetitle>
 
750
        (<command>ddate</command>)</para>
 
751
      </listitem>
 
752
      <listitem>
 
753
        <para><citetitle>Debian GNU/Linux manual</citetitle>
 
754
        (<command>faked</command>)</para>
 
755
      </listitem>
 
756
      <listitem>
 
757
        <para><citetitle>GIMP Manual Pages</citetitle>
 
758
        (<command>gimp</command>)</para>
 
759
      </listitem>
 
760
      <listitem>
 
761
        <para><citetitle>KDOC Documentation System</citetitle>
 
762
        (<command>qt2kdoc</command>)</para>
 
763
      </listitem>
 
764
    </itemizedlist>
 
765
    </para>
 
766
  </refdescription>
 
767
 
 
768
  <refparameter>
 
769
    <variablelist>
 
770
      <varlistentry>
 
771
        <term>info</term>
 
772
        <listitem>
 
773
          <para>An info node (from a <tag>refentry</tag> element)</para>
 
774
        </listitem>
 
775
      </varlistentry>
 
776
      <varlistentry>
 
777
        <term>parentinfo</term>
 
778
        <listitem>
 
779
          <para>An info node (from a parent of a <tag>refentry</tag> element)</para>
 
780
        </listitem>
 
781
      </varlistentry>
 
782
      <varlistentry>
 
783
        <term>prefs</term>
 
784
        <listitem>
 
785
          <para>A node containing users preferences (from global
 
786
          stylesheet parameters)</para>
 
787
        </listitem>
 
788
      </varlistentry>
 
789
    </variablelist>
 
790
  </refparameter>
 
791
 
 
792
  <refreturn><para>Returns a <tag>manual</tag> node.</para></refreturn>
 
793
</doc:template>
 
794
<xsl:template name="get.refentry.manual">
 
795
  <xsl:param name="info"/>
 
796
  <xsl:param name="parentinfo"/>
 
797
  <xsl:param name="prefs"/>
 
798
  <xsl:variable name="Manual">
 
799
    <xsl:choose>
 
800
      <!-- * if profiling is enabled for manual, and the manual -->
 
801
      <!-- * profile is non-empty, use it -->
 
802
      <xsl:when test="$prefs/@profileEnabled != '0' and
 
803
                      $prefs/@profile != ''">
 
804
        <xsl:message>using manual profile</xsl:message>
 
805
        <xsl:call-template name="evaluate.info.profile">
 
806
          <xsl:with-param name="profile" select="$prefs/@profile"/>
 
807
          <xsl:with-param name="info" select="$info"/>
 
808
          <xsl:with-param name="parentinfo" select="$parentinfo"/>
 
809
        </xsl:call-template>
 
810
      </xsl:when>
 
811
      <xsl:otherwise>
 
812
        <!-- * either profiling for source.name is not enabled, or-->
 
813
        <!-- * the source.name profile is empty; so we need to look -->
 
814
        <!-- * for a name to use -->
 
815
        <xsl:choose>
 
816
          <xsl:when test="refmeta/refmiscinfo[@class = 'manual']">
 
817
            <xsl:apply-templates 
 
818
                select="refmeta/refmiscinfo[@class = 'manual'][1]/node()"/>
 
819
          </xsl:when>
 
820
          <!-- * no <refmisc class="manual"/> found, so we need to -->
 
821
          <!-- * check title in parentinfo and parent title -->
 
822
          <xsl:when test="$parentinfo/title">
 
823
            <xsl:apply-templates select="$parentinfo/title/node()"/>
 
824
          </xsl:when>
 
825
          <xsl:when test="../title">
 
826
            <xsl:apply-templates select="../title/node()"/>
 
827
          </xsl:when>
 
828
          <xsl:otherwise>
 
829
            <!-- * found nothing, so return nothing -->
 
830
          </xsl:otherwise>
 
831
        </xsl:choose>
 
832
      </xsl:otherwise>
 
833
    </xsl:choose>
 
834
  </xsl:variable>
 
835
  <xsl:choose>
 
836
    <xsl:when test="$Manual != ''">
 
837
      <xsl:copy-of select="$Manual"/>
 
838
    </xsl:when>
 
839
    <!-- * if no Manual, use contents of specified -->
 
840
    <!-- * Fallback (if any) -->
 
841
    <xsl:when test="$prefs/@fallback != ''">
 
842
      <xsl:call-template name="evaluate.info.profile">
 
843
        <xsl:with-param name="profile" select="$prefs/@fallback"/>
 
844
        <xsl:with-param name="info" select="$info"/>
 
845
        <xsl:with-param name="parentinfo" select="$parentinfo"/>
 
846
      </xsl:call-template>
 
847
    </xsl:when>
 
848
    <xsl:otherwise>
 
849
      <!-- * found nothing, so leave it empty -->
 
850
    </xsl:otherwise>
 
851
  </xsl:choose>
 
852
</xsl:template>
 
853
 
 
854
<!-- ====================================================================== -->
 
855
 
 
856
<doc:template name="get.refentry.metadata.prefs" xmlns="">
 
857
  <refpurpose>Gets user preferences for refentry metadata gathering</refpurpose>
 
858
 
 
859
  <refdescription>
 
860
    <para>The DocBook XSL stylesheets include several user-configurable
 
861
    global stylesheet parameters for controlling <tag>refentry</tag>
 
862
    metadata gathering. Those parameters are not read directly by the
 
863
    other <tag>refentry</tag> metadata-gathering functions. Instead, they
 
864
    are read only by the <function>get.refentry.metadata.prefs</function>
 
865
    function, which assembles them into a structure that is then passed to
 
866
    the other <tag>refentry</tag> metadata-gathering functions.</para>
 
867
 
 
868
    <para>So the, <function>get.refentry.metadata.prefs</function>
 
869
    function is the only interface to collecting stylesheet parameters for
 
870
    controlling <tag>refentry</tag> metadata gathering.</para>
 
871
  </refdescription>
 
872
 
 
873
  <refparameter>
 
874
    <para>There are no local parameters for this function; however, it
 
875
    does rely on a number of global parameters.</para>
 
876
  </refparameter>
 
877
 
 
878
  <refreturn><para>Returns a <tag>manual</tag> node.</para></refreturn>
 
879
</doc:template>
 
880
 
 
881
<xsl:template name="get.refentry.metadata.prefs">
 
882
  <DatePrefs>
 
883
    <xsl:attribute name="profile">
 
884
      <xsl:value-of select="$refentry.date.profile"/>
 
885
    </xsl:attribute>
 
886
    <xsl:attribute name="profileEnabled">
 
887
      <xsl:value-of select="$refentry.date.profile.enabled"/>
 
888
    </xsl:attribute>
 
889
  </DatePrefs>
 
890
  <SourcePrefs>
 
891
    <xsl:attribute name="fallback">
 
892
      <xsl:value-of select="$refentry.source.fallback.profile"/>
 
893
    </xsl:attribute>
 
894
    <Name>
 
895
      <xsl:attribute name="profile">
 
896
        <xsl:value-of select="$refentry.source.name.profile"/>
 
897
      </xsl:attribute>
 
898
      <xsl:attribute name="profileEnabled">
 
899
        <xsl:value-of select="$refentry.source.name.profile.enabled"/>
 
900
      </xsl:attribute>
 
901
      <xsl:attribute name="suppress">
 
902
        <xsl:value-of select="$refentry.source.name.suppress"/>
 
903
      </xsl:attribute>
 
904
    </Name>
 
905
    <Version>
 
906
      <xsl:attribute name="profile">
 
907
        <xsl:value-of select="$refentry.version.profile"/>
 
908
      </xsl:attribute>
 
909
      <xsl:attribute name="profileEnabled">
 
910
        <xsl:value-of select="$refentry.version.profile.enabled"/>
 
911
      </xsl:attribute>
 
912
      <xsl:attribute name="suppress">
 
913
        <xsl:value-of select="$refentry.version.suppress"/>
 
914
      </xsl:attribute>
 
915
    </Version>
 
916
  </SourcePrefs>
 
917
  <ManualPrefs>
 
918
    <xsl:attribute name="fallback">
 
919
      <xsl:value-of select="$refentry.manual.fallback.profile"/>
 
920
    </xsl:attribute>
 
921
    <xsl:attribute name="profile">
 
922
      <xsl:value-of select="$refentry.manual.profile"/>
 
923
    </xsl:attribute>
 
924
    <xsl:attribute name="profileEnabled">
 
925
      <xsl:value-of select="$refentry.manual.profile.enabled"/>
 
926
    </xsl:attribute>
 
927
  </ManualPrefs>
 
928
</xsl:template>
 
929
 
 
930
</xsl:stylesheet>