refentry.xsl 52 KB

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