1 <?xml version="1.0" encoding="UTF-8"?>
2 <reference xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="refentry">
4 <title>Common » Refentry Metadata Template Reference</title>
5 <releaseinfo role="meta">
9 <partintro xml:id="partintro">
10 <title>Introduction</title>
12 <para>This is technical reference documentation for the “refentry
13 metadata” templates in the DocBook XSL Stylesheets.</para>
16 <para>This is not intended to be user documentation. It is provided
17 for developers writing customization layers for the stylesheets.</para>
21 <para>Currently, only the manpages stylesheets make use of these
22 templates. They are, however, potentially useful elsewhere.</para>
27 <refentry xml:id="template.get.refentry.metadata">
29 <refname>get.refentry.metadata</refname>
30 <refpurpose>Gathers metadata from a refentry and its ancestors</refpurpose>
33 <synopsis><xsl:template name="get.refentry.metadata">
34 <xsl:param name="refname"/>
35 <xsl:param name="info"/>
36 <xsl:param name="prefs"/>
38 </xsl:template></synopsis>
40 <refsect1><title>Description</title>
42 <para>Reference documentation for particular commands, functions,
43 etc., is sometimes viewed in isolation from its greater "context". For
44 example, users view Unix man pages as, well, individual pages, not as
45 part of a "book" of some kind. Therefore, it is sometimes necessary to
46 embed "context" information in output for each <tag>refentry</tag>.</para>
50 <para>However, one problem is that different users mark up that
51 context information in different ways. Often (usually), the
52 context information is not actually part of the content of the
53 <tag>refentry</tag> itself, but instead part of the content of a
54 parent or ancestor element to the <tag>refentry</tag>. And
55 even then, DocBook provides a variety of elements that users might
56 potentially use to mark up the same kind of information. One user
57 might use the <tag>productnumber</tag> element to mark up version
58 information about a particular product, while another might use
59 the <tag>releaseinfo</tag> element.</para>
63 <para>Taking all that in mind, the
64 <function>get.refentry.metadata</function> template tries to gather
65 metadata from a <tag>refentry</tag> element and its ancestor
66 elements in an intelligent and user-configurable way. The basic
67 mechanism used in the XPath expressions throughout this stylesheet
68 is to select the relevant metadata from the *info element that is
69 closest to the actual <tag>refentry</tag> – either on the
70 <tag>refentry</tag> itself, or on its nearest ancestor.</para>
75 <para>The <function>get.refentry.metadata</function>
76 template is actually just sort of a "driver" template; it
77 calls other templates that do the actual data collection,
78 then returns the data as a set.</para>
82 </refsect1><refsect1><title>Parameters</title>
89 <para>The first <tag>refname</tag> in the refentry</para>
97 <para>A set of info nodes (from a <tag>refentry</tag>
98 element and its ancestors)</para>
106 <para>A node containing user preferences (from global
107 stylesheet parameters)</para>
113 </refsect1><refsect1><title>Returns</title>
115 <para>Returns a node set with the following elements. The
116 descriptions are verbatim from the <literal>man(7)</literal> man
124 <para>the title of the man page (e.g., <literal>MAN</literal>)</para>
132 <para>the section number the man page should be placed in (e.g.,
133 <literal>7</literal>)</para>
141 <para>the date of the last revision</para>
149 <para>the source of the command</para>
157 <para>the title of the manual (e.g., <citetitle>Linux
158 Programmer's Manual</citetitle>)</para>
166 </refsect1></refentry>
168 <refentry xml:id="template.get.refentry.title">
170 <refname>get.refentry.title</refname>
171 <refpurpose>Gets title metadata for a refentry</refpurpose>
174 <synopsis><xsl:template name="get.refentry.title">
175 <xsl:param name="refname"/>
177 </xsl:template></synopsis>
179 <refsect1><title>Description</title>
181 <para>The <literal>man(7)</literal> man page describes this as "the
182 title of the man page (e.g., <literal>MAN</literal>). This differs
183 from <tag>refname</tag> in that, if the <tag>refentry</tag> has a
184 <tag>refentrytitle</tag>, we use that as the <tag>title</tag>;
185 otherwise, we just use first <tag>refname</tag> in the first
186 <tag>refnamediv</tag> in the source.</para>
188 </refsect1><refsect1><title>Parameters</title>
195 <para>The first <tag>refname</tag> in the refentry</para>
201 </refsect1><refsect1><title>Returns</title>
203 <para>Returns a <tag>title</tag> node.</para>
204 </refsect1></refentry>
206 <refentry xml:id="template.get.refentry.section">
208 <refname>get.refentry.section</refname>
209 <refpurpose>Gets section metadata for a refentry</refpurpose>
212 <synopsis><xsl:template name="get.refentry.section">
213 <xsl:param name="refname"/>
214 <xsl:param name="quiet" select="0"/>
216 </xsl:template></synopsis>
218 <refsect1><title>Description</title>
220 <para>The <literal>man(7)</literal> man page describes this as "the
221 section number the man page should be placed in (e.g.,
222 <literal>7</literal>)". If we do not find a <tag>manvolnum</tag>
223 specified in the source, and we find that the <tag>refentry</tag> is
224 for a function, we use the section number <literal>3</literal>
225 ["Library calls (functions within program libraries)"]; otherwise, we
226 default to using <literal>1</literal> ["Executable programs or shell
229 </refsect1><refsect1><title>Parameters</title>
236 <para>The first <tag>refname</tag> in the refentry</para>
244 <para>If non-zero, no "missing" message is emitted</para>
250 </refsect1><refsect1><title>Returns</title>
252 <para>Returns a string representing a section number.</para>
253 </refsect1></refentry>
255 <refentry xml:id="template.get.refentry.date">
257 <refname>get.refentry.date</refname>
258 <refpurpose>Gets date metadata for a refentry</refpurpose>
261 <synopsis><xsl:template name="get.refentry.date">
262 <xsl:param name="refname"/>
263 <xsl:param name="info"/>
264 <xsl:param name="prefs"/>
266 </xsl:template></synopsis>
268 <refsect1><title>Description</title>
270 <para>The <literal>man(7)</literal> man page describes this as "the
271 date of the last revision". If we cannot find a date in the source, we
274 </refsect1><refsect1><title>Parameters</title>
281 <para>The first <tag>refname</tag> in the refentry</para>
289 <para>A set of info nodes (from a <tag>refentry</tag>
290 element and its ancestors)</para>
298 <para>A node containing users preferences (from global stylesheet parameters)</para>
304 </refsect1><refsect1><title>Returns</title>
306 <para>Returns a <tag>date</tag> node.</para>
308 </refsect1></refentry>
310 <refentry xml:id="template.get.refentry.source">
312 <refname>get.refentry.source</refname>
313 <refpurpose>Gets source metadata for a refentry</refpurpose>
316 <synopsis><xsl:template name="get.refentry.source">
317 <xsl:param name="refname"/>
318 <xsl:param name="info"/>
319 <xsl:param name="prefs"/>
321 </xsl:template></synopsis>
323 <refsect1><title>Description</title>
325 <para>The <literal>man(7)</literal> man page describes this as "the
326 source of the command", and provides the following examples:
331 <para>For binaries, use something like: GNU, NET-2, SLS
332 Distribution, MCC Distribution.</para>
337 <para>For system calls, use the version of the kernel that you are
338 currently looking at: Linux 0.99.11.</para>
343 <para>For library calls, use the source of the function: GNU, BSD
344 4.3, Linux DLL 4.4.1.</para>
353 <para>The <literal>solbook(5)</literal> man page describes
354 something very much like what <literal>man(7)</literal> calls
355 "source", except that <literal>solbook(5)</literal> names it
356 "software" and describes it like this:
359 <para>This is the name of the software product that the topic
360 discussed on the reference page belongs to. For example UNIX
361 commands are part of the <literal>SunOS x.x</literal>
369 <para>In practice, there are many pages that simply have a version
370 number in the "source" field. So, it looks like what we have is a
372 <replaceable>Name</replaceable> <replaceable>Version</replaceable>,
380 <para>product name (e.g., BSD) or org. name (e.g., GNU)</para>
388 <para>version name</para>
394 Each part is optional. If the <replaceable>Name</replaceable> is a
395 product name, then the <replaceable>Version</replaceable> is probably
396 the version of the product. Or there may be no
397 <replaceable>Name</replaceable>, in which case, if there is a
398 <replaceable>Version</replaceable>, it is probably the version of the
399 item itself, not the product it is part of. Or, if the
400 <replaceable>Name</replaceable> is an organization name, then there
401 probably will be no <replaceable>Version</replaceable>.
404 </refsect1><refsect1><title>Parameters</title>
411 <para>The first <tag>refname</tag> in the refentry</para>
419 <para>A set of info nodes (from a <tag>refentry</tag>
420 element and its ancestors)</para>
428 <para>A node containing users preferences (from global
429 stylesheet parameters)</para>
435 </refsect1><refsect1><title>Returns</title>
437 <para>Returns a <tag>source</tag> node.</para>
439 </refsect1></refentry>
441 <refentry xml:id="template.get.refentry.source.name">
443 <refname>get.refentry.source.name</refname>
444 <refpurpose>Gets source-name metadata for a refentry</refpurpose>
447 <synopsis><xsl:template name="get.refentry.source.name">
448 <xsl:param name="refname"/>
449 <xsl:param name="info"/>
450 <xsl:param name="prefs"/>
452 </xsl:template></synopsis>
454 <refsect1><title>Description</title>
456 <para>A "source name" is one part of a (potentially) two-part
457 <replaceable>Name</replaceable> <replaceable>Version</replaceable>
458 source field. For more details, see the documentation for the
459 <function>get.refentry.source</function> template.</para>
461 </refsect1><refsect1><title>Parameters</title>
468 <para>The first <tag>refname</tag> in the refentry</para>
476 <para>A set of info nodes (from a <tag>refentry</tag>
477 element and its ancestors)</para>
485 <para>A node containing users preferences (from global
486 stylesheet parameters)</para>
492 </refsect1><refsect1><title>Returns</title>
494 <para>Depending on what output method is used for the
495 current stylesheet, either returns a text node or possibly an element
496 node, containing "source name" data.</para>
498 </refsect1></refentry>
500 <refentry xml:id="template.get.refentry.version">
502 <refname>get.refentry.version</refname>
503 <refpurpose>Gets version metadata for a refentry</refpurpose>
506 <synopsis><xsl:template name="get.refentry.version">
507 <xsl:param name="refname"/>
508 <xsl:param name="info"/>
509 <xsl:param name="prefs"/>
511 </xsl:template></synopsis>
513 <refsect1><title>Description</title>
515 <para>A "version" is one part of a (potentially) two-part
516 <replaceable>Name</replaceable> <replaceable>Version</replaceable>
517 source field. For more details, see the documentation for the
518 <function>get.refentry.source</function> template.</para>
520 </refsect1><refsect1><title>Parameters</title>
527 <para>The first <tag>refname</tag> in the refentry</para>
535 <para>A set of info nodes (from a <tag>refentry</tag>
536 element and its ancestors)</para>
544 <para>A node containing users preferences (from global
545 stylesheet parameters)</para>
551 </refsect1><refsect1><title>Returns</title>
553 <para>Depending on what output method is used for the
554 current stylesheet, either returns a text node or possibly an element
555 node, containing "version" data.</para>
557 </refsect1></refentry>
559 <refentry xml:id="template.get.refentry.manual">
561 <refname>get.refentry.manual</refname>
562 <refpurpose>Gets source metadata for a refentry</refpurpose>
565 <synopsis><xsl:template name="get.refentry.manual">
566 <xsl:param name="refname"/>
567 <xsl:param name="info"/>
568 <xsl:param name="prefs"/>
570 </xsl:template></synopsis>
572 <refsect1><title>Description</title>
574 <para>The <literal>man(7)</literal> man page describes this as "the
575 title of the manual (e.g., <citetitle>Linux Programmer's
576 Manual</citetitle>)". Here are some examples from existing man pages:
581 <para><citetitle>dpkg utilities</citetitle>
582 (<command>dpkg-name</command>)</para>
587 <para><citetitle>User Contributed Perl Documentation</citetitle>
588 (<command>GET</command>)</para>
593 <para><citetitle>GNU Development Tools</citetitle>
594 (<command>ld</command>)</para>
599 <para><citetitle>Emperor Norton Utilities</citetitle>
600 (<command>ddate</command>)</para>
605 <para><citetitle>Debian GNU/Linux manual</citetitle>
606 (<command>faked</command>)</para>
611 <para><citetitle>GIMP Manual Pages</citetitle>
612 (<command>gimp</command>)</para>
617 <para><citetitle>KDOC Documentation System</citetitle>
618 (<command>qt2kdoc</command>)</para>
627 <para>The <literal>solbook(5)</literal> man page describes
628 something very much like what <literal>man(7)</literal> calls
629 "manual", except that <literal>solbook(5)</literal> names it
630 "sectdesc" and describes it like this:
633 <para>This is the section title of the reference page; for
634 example <literal>User Commands</literal>.</para>
640 </refsect1><refsect1><title>Parameters</title>
647 <para>The first <tag>refname</tag> in the refentry</para>
655 <para>A set of info nodes (from a <tag>refentry</tag>
656 element and its ancestors)</para>
664 <para>A node containing users preferences (from global
665 stylesheet parameters)</para>
671 </refsect1><refsect1><title>Returns</title>
673 <para>Returns a <tag>manual</tag> node.</para>
675 </refsect1></refentry>
677 <refentry xml:id="template.get.refentry.metadata.prefs">
679 <refname>get.refentry.metadata.prefs</refname>
680 <refpurpose>Gets user preferences for refentry metadata gathering</refpurpose>
683 <synopsis><xsl:template name="get.refentry.metadata.prefs"/></synopsis>
685 <refsect1><title>Description</title>
687 <para>The DocBook XSL stylesheets include several user-configurable
688 global stylesheet parameters for controlling <tag>refentry</tag>
689 metadata gathering. Those parameters are not read directly by the
690 other <tag>refentry</tag> metadata-gathering
691 templates. Instead, they are read only by the
692 <function>get.refentry.metadata.prefs</function> template,
693 which assembles them into a structure that is then passed to
694 the other <tag>refentry</tag> metadata-gathering
699 <para>So the, <function>get.refentry.metadata.prefs</function>
700 template is the only interface to collecting stylesheet parameters for
701 controlling <tag>refentry</tag> metadata gathering.</para>
703 </refsect1><refsect1><title>Parameters</title>
705 <para>There are no local parameters for this template; however, it
706 does rely on a number of global parameters.</para>
708 </refsect1><refsect1><title>Returns</title>
710 <para>Returns a <tag>manual</tag> node.</para>
712 </refsect1></refentry>
714 <refentry xml:id="template.set.refentry.metadata">
716 <refname>set.refentry.metadata</refname>
717 <refpurpose>Sets content of a refentry metadata item</refpurpose>
720 <synopsis><xsl:template name="set.refentry.metadata">
721 <xsl:param name="refname"/>
722 <xsl:param name="info"/>
723 <xsl:param name="contents"/>
724 <xsl:param name="context"/>
725 <xsl:param name="preferred"/>
727 </xsl:template></synopsis>
729 <refsect1><title>Description</title>
731 <para>The <function>set.refentry.metadata</function> template is
732 called each time a suitable source element is found for a certain
733 metadata field.</para>
735 </refsect1><refsect1><title>Parameters</title>
742 <para>The first <tag>refname</tag> in the refentry</para>
750 <para>A single *info node that contains the selected source element.</para>
755 <term>contents</term>
758 <para>A node containing the selected source element.</para>
766 <para>A string describing the metadata context in which the
767 <function>set.refentry.metadata</function> template was
768 called: either "date", "source", "version", or "manual".</para>
774 </refsect1><refsect1><title>Returns</title>
776 <para>Returns formatted contents of a selected source element.</para>
777 </refsect1></refentry>