3 <reference xml:id="refentry">
5 <title>Common » Refentry Metadata Template Reference</title>
6 <releaseinfo role="meta">
7 $Id: refentry.xsl 7867 2008-03-07 09:54:25Z xmldoc $
11 <partintro xml:id="partintro">
12 <title>Introduction</title>
14 <para>This is technical reference documentation for the “refentry
15 metadata” templates in the DocBook XSL Stylesheets.</para>
18 <para>This is not intended to be user documentation. It is provided
19 for developers writing customization layers for the stylesheets.</para>
23 <para>Currently, only the manpages stylesheets make use of these
24 templates. They are, however, potentially useful elsewhere.</para>
29 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.get.refentry.metadata">
31 <refname>get.refentry.metadata</refname>
32 <refpurpose>Gathers metadata from a refentry and its ancestors</refpurpose>
35 <synopsis><xsl:template name="get.refentry.metadata">
36 <xsl:param name="refname"/>
37 <xsl:param name="info"/>
38 <xsl:param name="prefs"/>
40 </xsl:template></synopsis>
42 <refsect1><title>Description</title>
44 <para>Reference documentation for particular commands, functions,
45 etc., is sometimes viewed in isolation from its greater "context". For
46 example, users view Unix man pages as, well, individual pages, not as
47 part of a "book" of some kind. Therefore, it is sometimes necessary to
48 embed "context" information in output for each <tag>refentry</tag>.</para>
52 <para>However, one problem is that different users mark up that
53 context information in different ways. Often (usually), the
54 context information is not actually part of the content of the
55 <tag>refentry</tag> itself, but instead part of the content of a
56 parent or ancestor element to the <tag>refentry</tag>. And
57 even then, DocBook provides a variety of elements that users might
58 potentially use to mark up the same kind of information. One user
59 might use the <tag>productnumber</tag> element to mark up version
60 information about a particular product, while another might use
61 the <tag>releaseinfo</tag> element.</para>
65 <para>Taking all that in mind, the
66 <function>get.refentry.metadata</function> template tries to gather
67 metadata from a <tag>refentry</tag> element and its ancestor
68 elements in an intelligent and user-configurable way. The basic
69 mechanism used in the XPath expressions throughout this stylesheet
70 is to select the relevant metadata from the *info element that is
71 closest to the actual <tag>refentry</tag> – either on the
72 <tag>refentry</tag> itself, or on its nearest ancestor.</para>
77 <para>The <function>get.refentry.metadata</function>
78 template is actually just sort of a "driver" template; it
79 calls other templates that do the actual data collection,
80 then returns the data as a set.</para>
84 </refsect1><refsect1><title>Parameters</title>
91 <para>The first <tag>refname</tag> in the refentry</para>
99 <para>A set of info nodes (from a <tag>refentry</tag>
100 element and its ancestors)</para>
108 <para>A node containing user preferences (from global
109 stylesheet parameters)</para>
115 </refsect1><refsect1><title>Returns</title>
117 <para>Returns a node set with the following elements. The
118 descriptions are verbatim from the <literal>man(7)</literal> man
126 <para>the title of the man page (e.g., <literal>MAN</literal>)</para>
134 <para>the section number the man page should be placed in (e.g.,
135 <literal>7</literal>)</para>
143 <para>the date of the last revision</para>
151 <para>the source of the command</para>
159 <para>the title of the manual (e.g., <citetitle>Linux
160 Programmer's Manual</citetitle>)</para>
168 </refsect1></refentry>
170 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.get.refentry.title">
172 <refname>get.refentry.title</refname>
173 <refpurpose>Gets title metadata for a refentry</refpurpose>
176 <synopsis><xsl:template name="get.refentry.title">
177 <xsl:param name="refname"/>
179 </xsl:template></synopsis>
181 <refsect1><title>Description</title>
183 <para>The <literal>man(7)</literal> man page describes this as "the
184 title of the man page (e.g., <literal>MAN</literal>). This differs
185 from <tag>refname</tag> in that, if the <tag>refentry</tag> has a
186 <tag>refentrytitle</tag>, we use that as the <tag>title</tag>;
187 otherwise, we just use first <tag>refname</tag> in the first
188 <tag>refnamediv</tag> in the source.</para>
190 </refsect1><refsect1><title>Parameters</title>
197 <para>The first <tag>refname</tag> in the refentry</para>
203 </refsect1><refsect1><title>Returns</title>
205 <para>Returns a <tag>title</tag> node.</para>
206 </refsect1></refentry>
208 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.get.refentry.section">
210 <refname>get.refentry.section</refname>
211 <refpurpose>Gets section metadata for a refentry</refpurpose>
214 <synopsis><xsl:template name="get.refentry.section">
215 <xsl:param name="refname"/>
216 <xsl:param name="quiet" select="0"/>
218 </xsl:template></synopsis>
220 <refsect1><title>Description</title>
222 <para>The <literal>man(7)</literal> man page describes this as "the
223 section number the man page should be placed in (e.g.,
224 <literal>7</literal>)". If we do not find a <tag>manvolnum</tag>
225 specified in the source, and we find that the <tag>refentry</tag> is
226 for a function, we use the section number <literal>3</literal>
227 ["Library calls (functions within program libraries)"]; otherwise, we
228 default to using <literal>1</literal> ["Executable programs or shell
231 </refsect1><refsect1><title>Parameters</title>
238 <para>The first <tag>refname</tag> in the refentry</para>
246 <para>If non-zero, no "missing" message is emitted</para>
252 </refsect1><refsect1><title>Returns</title>
254 <para>Returns a string representing a section number.</para>
255 </refsect1></refentry>
257 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.get.refentry.date">
259 <refname>get.refentry.date</refname>
260 <refpurpose>Gets date metadata for a refentry</refpurpose>
263 <synopsis><xsl:template name="get.refentry.date">
264 <xsl:param name="refname"/>
265 <xsl:param name="info"/>
266 <xsl:param name="prefs"/>
268 </xsl:template></synopsis>
270 <refsect1><title>Description</title>
272 <para>The <literal>man(7)</literal> man page describes this as "the
273 date of the last revision". If we cannot find a date in the source, we
276 </refsect1><refsect1><title>Parameters</title>
283 <para>The first <tag>refname</tag> in the refentry</para>
291 <para>A set of info nodes (from a <tag>refentry</tag>
292 element and its ancestors)</para>
300 <para>A node containing users preferences (from global stylesheet parameters)</para>
306 </refsect1><refsect1><title>Returns</title>
308 <para>Returns a <tag>date</tag> node.</para>
310 </refsect1></refentry>
312 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.get.refentry.source">
314 <refname>get.refentry.source</refname>
315 <refpurpose>Gets source metadata for a refentry</refpurpose>
318 <synopsis><xsl:template name="get.refentry.source">
319 <xsl:param name="refname"/>
320 <xsl:param name="info"/>
321 <xsl:param name="prefs"/>
323 </xsl:template></synopsis>
325 <refsect1><title>Description</title>
327 <para>The <literal>man(7)</literal> man page describes this as "the
328 source of the command", and provides the following examples:
333 <para>For binaries, use something like: GNU, NET-2, SLS
334 Distribution, MCC Distribution.</para>
339 <para>For system calls, use the version of the kernel that you are
340 currently looking at: Linux 0.99.11.</para>
345 <para>For library calls, use the source of the function: GNU, BSD
346 4.3, Linux DLL 4.4.1.</para>
355 <para>The <literal>solbook(5)</literal> man page describes
356 something very much like what <literal>man(7)</literal> calls
357 "source", except that <literal>solbook(5)</literal> names it
358 "software" and describes it like this:
361 <para>This is the name of the software product that the topic
362 discussed on the reference page belongs to. For example UNIX
363 commands are part of the <literal>SunOS x.x</literal>
371 <para>In practice, there are many pages that simply have a version
372 number in the "source" field. So, it looks like what we have is a
374 <replaceable>Name</replaceable> <replaceable>Version</replaceable>,
382 <para>product name (e.g., BSD) or org. name (e.g., GNU)</para>
390 <para>version name</para>
396 Each part is optional. If the <replaceable>Name</replaceable> is a
397 product name, then the <replaceable>Version</replaceable> is probably
398 the version of the product. Or there may be no
399 <replaceable>Name</replaceable>, in which case, if there is a
400 <replaceable>Version</replaceable>, it is probably the version of the
401 item itself, not the product it is part of. Or, if the
402 <replaceable>Name</replaceable> is an organization name, then there
403 probably will be no <replaceable>Version</replaceable>.
406 </refsect1><refsect1><title>Parameters</title>
413 <para>The first <tag>refname</tag> in the refentry</para>
421 <para>A set of info nodes (from a <tag>refentry</tag>
422 element and its ancestors)</para>
430 <para>A node containing users preferences (from global
431 stylesheet parameters)</para>
437 </refsect1><refsect1><title>Returns</title>
439 <para>Returns a <tag>source</tag> node.</para>
441 </refsect1></refentry>
443 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.get.refentry.source.name">
445 <refname>get.refentry.source.name</refname>
446 <refpurpose>Gets source-name metadata for a refentry</refpurpose>
449 <synopsis><xsl:template name="get.refentry.source.name">
450 <xsl:param name="refname"/>
451 <xsl:param name="info"/>
452 <xsl:param name="prefs"/>
454 </xsl:template></synopsis>
456 <refsect1><title>Description</title>
458 <para>A "source name" is one part of a (potentially) two-part
459 <replaceable>Name</replaceable> <replaceable>Version</replaceable>
460 source field. For more details, see the documentation for the
461 <function>get.refentry.source</function> template.</para>
463 </refsect1><refsect1><title>Parameters</title>
470 <para>The first <tag>refname</tag> in the refentry</para>
478 <para>A set of info nodes (from a <tag>refentry</tag>
479 element and its ancestors)</para>
487 <para>A node containing users preferences (from global
488 stylesheet parameters)</para>
494 </refsect1><refsect1><title>Returns</title>
496 <para>Depending on what output method is used for the
497 current stylesheet, either returns a text node or possibly an element
498 node, containing "source name" data.</para>
500 </refsect1></refentry>
502 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.get.refentry.version">
504 <refname>get.refentry.version</refname>
505 <refpurpose>Gets version metadata for a refentry</refpurpose>
508 <synopsis><xsl:template name="get.refentry.version">
509 <xsl:param name="refname"/>
510 <xsl:param name="info"/>
511 <xsl:param name="prefs"/>
513 </xsl:template></synopsis>
515 <refsect1><title>Description</title>
517 <para>A "version" is one part of a (potentially) two-part
518 <replaceable>Name</replaceable> <replaceable>Version</replaceable>
519 source field. For more details, see the documentation for the
520 <function>get.refentry.source</function> template.</para>
522 </refsect1><refsect1><title>Parameters</title>
529 <para>The first <tag>refname</tag> in the refentry</para>
537 <para>A set of info nodes (from a <tag>refentry</tag>
538 element and its ancestors)</para>
546 <para>A node containing users preferences (from global
547 stylesheet parameters)</para>
553 </refsect1><refsect1><title>Returns</title>
555 <para>Depending on what output method is used for the
556 current stylesheet, either returns a text node or possibly an element
557 node, containing "version" data.</para>
559 </refsect1></refentry>
561 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.get.refentry.manual">
563 <refname>get.refentry.manual</refname>
564 <refpurpose>Gets source metadata for a refentry</refpurpose>
567 <synopsis><xsl:template name="get.refentry.manual">
568 <xsl:param name="refname"/>
569 <xsl:param name="info"/>
570 <xsl:param name="prefs"/>
572 </xsl:template></synopsis>
574 <refsect1><title>Description</title>
576 <para>The <literal>man(7)</literal> man page describes this as "the
577 title of the manual (e.g., <citetitle>Linux Programmer's
578 Manual</citetitle>)". Here are some examples from existing man pages:
583 <para><citetitle>dpkg utilities</citetitle>
584 (<command>dpkg-name</command>)</para>
589 <para><citetitle>User Contributed Perl Documentation</citetitle>
590 (<command>GET</command>)</para>
595 <para><citetitle>GNU Development Tools</citetitle>
596 (<command>ld</command>)</para>
601 <para><citetitle>Emperor Norton Utilities</citetitle>
602 (<command>ddate</command>)</para>
607 <para><citetitle>Debian GNU/Linux manual</citetitle>
608 (<command>faked</command>)</para>
613 <para><citetitle>GIMP Manual Pages</citetitle>
614 (<command>gimp</command>)</para>
619 <para><citetitle>KDOC Documentation System</citetitle>
620 (<command>qt2kdoc</command>)</para>
629 <para>The <literal>solbook(5)</literal> man page describes
630 something very much like what <literal>man(7)</literal> calls
631 "manual", except that <literal>solbook(5)</literal> names it
632 "sectdesc" and describes it like this:
635 <para>This is the section title of the reference page; for
636 example <literal>User Commands</literal>.</para>
642 </refsect1><refsect1><title>Parameters</title>
649 <para>The first <tag>refname</tag> in the refentry</para>
657 <para>A set of info nodes (from a <tag>refentry</tag>
658 element and its ancestors)</para>
666 <para>A node containing users preferences (from global
667 stylesheet parameters)</para>
673 </refsect1><refsect1><title>Returns</title>
675 <para>Returns a <tag>manual</tag> node.</para>
677 </refsect1></refentry>
679 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.get.refentry.metadata.prefs">
681 <refname>get.refentry.metadata.prefs</refname>
682 <refpurpose>Gets user preferences for refentry metadata gathering</refpurpose>
685 <synopsis><xsl:template name="get.refentry.metadata.prefs"/></synopsis>
687 <refsect1><title>Description</title>
689 <para>The DocBook XSL stylesheets include several user-configurable
690 global stylesheet parameters for controlling <tag>refentry</tag>
691 metadata gathering. Those parameters are not read directly by the
692 other <tag>refentry</tag> metadata-gathering
693 templates. Instead, they are read only by the
694 <function>get.refentry.metadata.prefs</function> template,
695 which assembles them into a structure that is then passed to
696 the other <tag>refentry</tag> metadata-gathering
701 <para>So the, <function>get.refentry.metadata.prefs</function>
702 template is the only interface to collecting stylesheet parameters for
703 controlling <tag>refentry</tag> metadata gathering.</para>
705 </refsect1><refsect1><title>Parameters</title>
707 <para>There are no local parameters for this template; however, it
708 does rely on a number of global parameters.</para>
710 </refsect1><refsect1><title>Returns</title>
712 <para>Returns a <tag>manual</tag> node.</para>
714 </refsect1></refentry>
716 <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="template.set.refentry.metadata">
718 <refname>set.refentry.metadata</refname>
719 <refpurpose>Sets content of a refentry metadata item</refpurpose>
722 <synopsis><xsl:template name="set.refentry.metadata">
723 <xsl:param name="refname"/>
724 <xsl:param name="info"/>
725 <xsl:param name="contents"/>
726 <xsl:param name="context"/>
727 <xsl:param name="preferred"/>
729 </xsl:template></synopsis>
731 <refsect1><title>Description</title>
733 <para>The <function>set.refentry.metadata</function> template is
734 called each time a suitable source element is found for a certain
735 metadata field.</para>
737 </refsect1><refsect1><title>Parameters</title>
744 <para>The first <tag>refname</tag> in the refentry</para>
752 <para>A single *info node that contains the selected source element.</para>
757 <term>contents</term>
760 <para>A node containing the selected source element.</para>
768 <para>A string describing the metadata context in which the
769 <function>set.refentry.metadata</function> template was
770 called: either "date", "source", "version", or "manual".</para>
776 </refsect1><refsect1><title>Returns</title>
778 <para>Returns formatted contents of a selected source element.</para>
779 </refsect1></refentry>