refentry.xsl 52 KB

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