refentry.xsl 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352
  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: refentry.xsl 7867 2008-03-07 09:54:25Z xmldoc $
  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: refentry.xsl 7867 2008-03-07 09:54:25Z xmldoc $
  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 <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. <!-- * The following block is commented out because: -->
  367. <!-- * -->
  368. <!-- * - having a missing date in the source doesn’t result in -->
  369. <!-- * any information being missing from the generated man -->
  370. <!-- * page (since we generate the needed date) -->
  371. <!-- * -->
  372. <!-- * - experience has shown the many users omit the date -->
  373. <!-- * intentionally, because they want to be it generated -->
  374. <!-- * -->
  375. <!-- * - in practice it’s not really a condition that most users -->
  376. <!-- * want reported to them -->
  377. <!-- * -->
  378. <!-- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  379. <!-- * <xsl:if test="$refentry.meta.get.quietly = 0"> -->
  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>no date; using generated date</xsl:text> -->
  386. <!-- * </xsl:with-param> -->
  387. <!-- * </xsl:call-template> -->
  388. <!-- * <xsl:call-template name="log.message"> -->
  389. <!-- * <xsl:with-param name="level">Note</xsl:with-param> -->
  390. <!-- * <xsl:with-param name="source" select="$refname"/> -->
  391. <!-- * <xsl:with-param name="context-desc">meta date</xsl:with-param> -->
  392. <!-- * <xsl:with-param name="message"> -->
  393. <!-- * <xsl:text>see http://docbook.sf.net/el/date</xsl:text> -->
  394. <!-- * </xsl:with-param> -->
  395. <!-- * </xsl:call-template> -->
  396. <!-- * </xsl:if> -->
  397. <!-- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  398. <xsl:call-template name="datetime.format">
  399. <xsl:with-param name="date">
  400. <xsl:choose>
  401. <xsl:when test="function-available('date:date-time')">
  402. <xsl:value-of select="date:date-time()"/>
  403. </xsl:when>
  404. <xsl:when test="function-available('date:dateTime')">
  405. <!-- Xalan quirk -->
  406. <xsl:value-of select="date:dateTime()"/>
  407. </xsl:when>
  408. </xsl:choose>
  409. </xsl:with-param>
  410. <xsl:with-param name="format">
  411. <xsl:call-template name="gentext.template">
  412. <xsl:with-param name="context" select="'datetime'"/>
  413. <xsl:with-param name="name" select="'format'"/>
  414. </xsl:call-template>
  415. </xsl:with-param>
  416. </xsl:call-template>
  417. </xsl:otherwise>
  418. </xsl:choose>
  419. </xsl:template>
  420. <!-- ==================================================================== -->
  421. <doc:template name="get.refentry.source" xmlns="">
  422. <refpurpose>Gets source metadata for a refentry</refpurpose>
  423. <refdescription id="get.refentry.source-desc">
  424. <para>The <literal>man(7)</literal> man page describes this as "the
  425. source of the command", and provides the following examples:
  426. <itemizedlist>
  427. <listitem>
  428. <para>For binaries, use something like: GNU, NET-2, SLS
  429. Distribution, MCC Distribution.</para>
  430. </listitem>
  431. <listitem>
  432. <para>For system calls, use the version of the kernel that you are
  433. currently looking at: Linux 0.99.11.</para>
  434. </listitem>
  435. <listitem>
  436. <para>For library calls, use the source of the function: GNU, BSD
  437. 4.3, Linux DLL 4.4.1.</para>
  438. </listitem>
  439. </itemizedlist>
  440. </para>
  441. <para>The <literal>solbook(5)</literal> man page describes
  442. something very much like what <literal>man(7)</literal> calls
  443. "source", except that <literal>solbook(5)</literal> names it
  444. "software" and describes it like this:
  445. <blockquote>
  446. <para>This is the name of the software product that the topic
  447. discussed on the reference page belongs to. For example UNIX
  448. commands are part of the <literal>SunOS x.x</literal>
  449. release.</para>
  450. </blockquote>
  451. </para>
  452. <para>In practice, there are many pages that simply have a version
  453. number in the "source" field. So, it looks like what we have is a
  454. two-part field,
  455. <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>,
  456. where:
  457. <variablelist>
  458. <varlistentry>
  459. <term>Name</term>
  460. <listitem>
  461. <para>product name (e.g., BSD) or org. name (e.g., GNU)</para>
  462. </listitem>
  463. </varlistentry>
  464. <varlistentry>
  465. <term>Version</term>
  466. <listitem>
  467. <para>version name</para>
  468. </listitem>
  469. </varlistentry>
  470. </variablelist>
  471. Each part is optional. If the <replaceable>Name</replaceable> is a
  472. product name, then the <replaceable>Version</replaceable> is probably
  473. the version of the product. Or there may be no
  474. <replaceable>Name</replaceable>, in which case, if there is a
  475. <replaceable>Version</replaceable>, it is probably the version of the
  476. item itself, not the product it is part of. Or, if the
  477. <replaceable>Name</replaceable> is an organization name, then there
  478. probably will be no <replaceable>Version</replaceable>.
  479. </para>
  480. </refdescription>
  481. <refparameter id="get.refentry.source-params">
  482. <variablelist>
  483. <varlistentry>
  484. <term>refname</term>
  485. <listitem>
  486. <para>The first <tag>refname</tag> in the refentry</para>
  487. </listitem>
  488. </varlistentry>
  489. <varlistentry>
  490. <term>info</term>
  491. <listitem>
  492. <para>A set of info nodes (from a <tag>refentry</tag>
  493. element and its ancestors)</para>
  494. </listitem>
  495. </varlistentry>
  496. <varlistentry>
  497. <term>prefs</term>
  498. <listitem>
  499. <para>A node containing users preferences (from global
  500. stylesheet parameters)</para>
  501. </listitem>
  502. </varlistentry>
  503. </variablelist>
  504. </refparameter>
  505. <refreturn id="get.refentry.source-returns">
  506. <para>Returns a <tag>source</tag> node.</para>
  507. </refreturn>
  508. </doc:template>
  509. <xsl:template name="get.refentry.source">
  510. <xsl:param name="refname"/>
  511. <xsl:param name="info"/>
  512. <xsl:param name="prefs"/>
  513. <xsl:variable name="Name">
  514. <xsl:if test="$prefs/Name/@suppress = 0">
  515. <xsl:call-template name="get.refentry.source.name">
  516. <xsl:with-param name="info" select="$info"/>
  517. <xsl:with-param name="refname" select="$refname"/>
  518. <xsl:with-param name="prefs" select="$prefs/Name"/>
  519. </xsl:call-template>
  520. </xsl:if>
  521. </xsl:variable>
  522. <xsl:variable name="Version">
  523. <xsl:if test="$prefs/Version/@suppress = 0">
  524. <xsl:call-template name="get.refentry.version">
  525. <xsl:with-param name="info" select="$info"/>
  526. <xsl:with-param name="refname" select="$refname"/>
  527. <xsl:with-param name="prefs" select="$prefs/Version"/>
  528. </xsl:call-template>
  529. </xsl:if>
  530. </xsl:variable>
  531. <xsl:choose>
  532. <!-- * if we have a Name and/or Version, use either or both -->
  533. <!-- * of those, in the form "Name Version" or just "Name" -->
  534. <!-- * or just "Version" -->
  535. <xsl:when test="not($Name = '') or not($Version = '')">
  536. <xsl:choose>
  537. <xsl:when test="not($Name = '') and not($Version = '')">
  538. <xsl:copy-of select="$Name"/>
  539. <xsl:text> </xsl:text>
  540. </xsl:when>
  541. <xsl:otherwise>
  542. <xsl:copy-of select="$Name"/>
  543. </xsl:otherwise>
  544. </xsl:choose>
  545. <xsl:copy-of select="$Version"/>
  546. </xsl:when>
  547. <!-- * if no Name and no Version, use fallback (if any) -->
  548. <xsl:when test="not($prefs/@fallback = '')">
  549. <xsl:variable name="source.fallback">
  550. <xsl:call-template name="evaluate.info.profile">
  551. <xsl:with-param name="profile" select="$prefs/@fallback"/>
  552. <xsl:with-param name="info" select="$info"/>
  553. </xsl:call-template>
  554. </xsl:variable>
  555. <!-- * At this point, we know that we don't have properly marked-up -->
  556. <!-- * source metadata, so even if we do have source fallback -->
  557. <!-- * content, we still report to the user that it should be -->
  558. <!-- * marked up properly instead. -->
  559. <xsl:if test="$refentry.meta.get.quietly = 0">
  560. <xsl:call-template name="report.missing.source.name">
  561. <xsl:with-param name="refname" select="$refname"/>
  562. </xsl:call-template>
  563. <xsl:call-template name="report.missing.version">
  564. <xsl:with-param name="refname" select="$refname"/>
  565. </xsl:call-template>
  566. </xsl:if>
  567. <xsl:choose>
  568. <xsl:when test="not($source.fallback = '')">
  569. <xsl:value-of select="$source.fallback"/>
  570. <xsl:if test="$refentry.meta.get.quietly = 0">
  571. <xsl:call-template name="log.message">
  572. <xsl:with-param name="level">Warn</xsl:with-param>
  573. <xsl:with-param name="source" select="$refname"/>
  574. <xsl:with-param name="context-desc">meta source</xsl:with-param>
  575. <xsl:with-param name="message">
  576. <xsl:text>using</xsl:text>
  577. <xsl:text> "</xsl:text>
  578. <xsl:value-of select="$source.fallback"/>
  579. <xsl:text>" </xsl:text>
  580. <xsl:text>for "source"</xsl:text>
  581. </xsl:with-param>
  582. </xsl:call-template>
  583. </xsl:if>
  584. </xsl:when>
  585. <xsl:otherwise>
  586. <!-- * we have no Name, no Version, and no fallback content, so -->
  587. <!-- * insert a fixme -->
  588. <xsl:text>[FIXME: source]</xsl:text>
  589. <xsl:if test="$refentry.meta.get.quietly = 0">
  590. <xsl:call-template name="log.message">
  591. <xsl:with-param name="level">Warn</xsl:with-param>
  592. <xsl:with-param name="source" select="$refname"/>
  593. <xsl:with-param name="context-desc">meta source</xsl:with-param>
  594. <xsl:with-param name="message">
  595. <xsl:text>no fallback for source, so inserted a fixme</xsl:text>
  596. </xsl:with-param>
  597. </xsl:call-template>
  598. </xsl:if>
  599. </xsl:otherwise>
  600. </xsl:choose>
  601. </xsl:when>
  602. <xsl:otherwise>
  603. <!-- * we have no Name, no Version, and no fallback given, so -->
  604. <!-- * insert a fixme -->
  605. <xsl:text>[FIXME: source]</xsl:text>
  606. <xsl:if test="$refentry.meta.get.quietly = 0">
  607. <xsl:call-template name="log.message">
  608. <xsl:with-param name="level">Warn</xsl:with-param>
  609. <xsl:with-param name="source" select="$refname"/>
  610. <xsl:with-param name="context-desc">meta source</xsl:with-param>
  611. <xsl:with-param name="message">
  612. <xsl:text>no source fallback given, so inserted a fixme</xsl:text>
  613. </xsl:with-param>
  614. </xsl:call-template>
  615. </xsl:if>
  616. </xsl:otherwise>
  617. </xsl:choose>
  618. </xsl:template>
  619. <!-- ==================================================================== -->
  620. <doc:template name="get.refentry.source.name" xmlns="">
  621. <refpurpose>Gets source-name metadata for a refentry</refpurpose>
  622. <refdescription id="get.refentry.source.name-desc">
  623. <para>A "source name" is one part of a (potentially) two-part
  624. <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>
  625. source field. For more details, see the documentation for the
  626. <function>get.refentry.source</function> template.</para>
  627. </refdescription>
  628. <refparameter id="get.refentry.source.name-params">
  629. <variablelist>
  630. <varlistentry>
  631. <term>refname</term>
  632. <listitem>
  633. <para>The first <tag>refname</tag> in the refentry</para>
  634. </listitem>
  635. </varlistentry>
  636. <varlistentry>
  637. <term>info</term>
  638. <listitem>
  639. <para>A set of info nodes (from a <tag>refentry</tag>
  640. element and its ancestors)</para>
  641. </listitem>
  642. </varlistentry>
  643. <varlistentry>
  644. <term>prefs</term>
  645. <listitem>
  646. <para>A node containing users preferences (from global
  647. stylesheet parameters)</para>
  648. </listitem>
  649. </varlistentry>
  650. </variablelist>
  651. </refparameter>
  652. <refreturn id="get.refentry.source.name-returns">
  653. <para>Depending on what output method is used for the
  654. current stylesheet, either returns a text node or possibly an element
  655. node, containing "source name" data.</para>
  656. </refreturn>
  657. </doc:template>
  658. <xsl:template name="get.refentry.source.name">
  659. <xsl:param name="refname"/>
  660. <xsl:param name="info"/>
  661. <xsl:param name="prefs"/>
  662. <xsl:choose>
  663. <!-- * if profiling is enabled for source.name, and the -->
  664. <!-- * source.name profile is non-empty, use it -->
  665. <xsl:when test="not($prefs/@profileEnabled = 0) and
  666. not($prefs/@profile = '')">
  667. <xsl:call-template name="evaluate.info.profile">
  668. <xsl:with-param name="profile" select="$prefs/@profile"/>
  669. <xsl:with-param name="info" select="$info"/>
  670. </xsl:call-template>
  671. </xsl:when>
  672. <xsl:otherwise>
  673. <!-- * either profiling for source.name is not enabled, or-->
  674. <!-- * the source.name profile is empty; so we need to look -->
  675. <!-- * for a name to use -->
  676. <xsl:choose>
  677. <xsl:when test="refmeta/refmiscinfo[@class = 'source' or @class = 'software']">
  678. <xsl:apply-templates
  679. select="refmeta/refmiscinfo[@class = 'source' or @class='software'][1]/node()"/>
  680. </xsl:when>
  681. <xsl:otherwise>
  682. <xsl:choose>
  683. <xsl:when test="$info/productname">
  684. <xsl:call-template name="set.refentry.metadata">
  685. <xsl:with-param name="refname" select="$refname"/>
  686. <xsl:with-param
  687. name="info"
  688. select="($info[productname])[last()]"/>
  689. <xsl:with-param
  690. name="contents"
  691. select="(($info[productname])[last()]/productname)[1]"/>
  692. <xsl:with-param name="context">source</xsl:with-param>
  693. </xsl:call-template>
  694. </xsl:when>
  695. <xsl:when test="$info/corpname">
  696. <xsl:call-template name="set.refentry.metadata">
  697. <xsl:with-param name="refname" select="$refname"/>
  698. <xsl:with-param
  699. name="info"
  700. select="($info[corpname])[last()]"/>
  701. <xsl:with-param
  702. name="contents"
  703. select="(($info[corpname])[last()]/corpname)[1]"/>
  704. <xsl:with-param name="context">source</xsl:with-param>
  705. <xsl:with-param name="preferred">productname</xsl:with-param>
  706. </xsl:call-template>
  707. </xsl:when>
  708. <xsl:when test="$info/corpcredit">
  709. <xsl:call-template name="set.refentry.metadata">
  710. <xsl:with-param name="refname" select="$refname"/>
  711. <xsl:with-param
  712. name="info"
  713. select="($info[corpcredit])[last()]"/>
  714. <xsl:with-param
  715. name="contents"
  716. select="(($info[corpcredit])[last()]/corpcredit)[1]"/>
  717. <xsl:with-param name="context">source</xsl:with-param>
  718. <xsl:with-param name="preferred">productname</xsl:with-param>
  719. </xsl:call-template>
  720. </xsl:when>
  721. <xsl:when test="$info/corpauthor">
  722. <xsl:call-template name="set.refentry.metadata">
  723. <xsl:with-param name="refname" select="$refname"/>
  724. <xsl:with-param
  725. name="info"
  726. select="($info[corpauthor])[last()]"/>
  727. <xsl:with-param
  728. name="contents"
  729. select="(($info[corpauthor])[last()]/corpauthor)[1]"/>
  730. <xsl:with-param name="context">source</xsl:with-param>
  731. <xsl:with-param name="preferred">productname</xsl:with-param>
  732. </xsl:call-template>
  733. </xsl:when>
  734. <xsl:when test="$info//orgname">
  735. <xsl:call-template name="set.refentry.metadata">
  736. <xsl:with-param name="refname" select="$refname"/>
  737. <xsl:with-param
  738. name="info"
  739. select="($info[//orgname])[last()]"/>
  740. <xsl:with-param
  741. name="contents"
  742. select="(($info[//orgname])[last()]//orgname)[1]"/>
  743. <xsl:with-param name="context">source</xsl:with-param>
  744. <xsl:with-param name="preferred">productname</xsl:with-param>
  745. </xsl:call-template>
  746. </xsl:when>
  747. <xsl:when test="$info//publishername">
  748. <xsl:call-template name="set.refentry.metadata">
  749. <xsl:with-param name="refname" select="$refname"/>
  750. <xsl:with-param
  751. name="info"
  752. select="($info[//publishername])[last()]"/>
  753. <xsl:with-param
  754. name="contents"
  755. select="(($info[//publishername])[last()]//publishername)[1]"/>
  756. <xsl:with-param name="context">source</xsl:with-param>
  757. <xsl:with-param name="preferred">productname</xsl:with-param>
  758. </xsl:call-template>
  759. </xsl:when>
  760. </xsl:choose>
  761. </xsl:otherwise>
  762. </xsl:choose>
  763. </xsl:otherwise>
  764. </xsl:choose>
  765. </xsl:template>
  766. <xsl:template name="report.missing.source.name">
  767. <xsl:param name="refname"/>
  768. <xsl:call-template name="log.message">
  769. <xsl:with-param name="level">Note</xsl:with-param>
  770. <xsl:with-param name="source" select="$refname"/>
  771. <xsl:with-param name="context-desc">meta source</xsl:with-param>
  772. <xsl:with-param name="message">
  773. <xsl:text>no *info/productname or alternative</xsl:text>
  774. </xsl:with-param>
  775. </xsl:call-template>
  776. <xsl:call-template name="log.message">
  777. <xsl:with-param name="level">Note</xsl:with-param>
  778. <xsl:with-param name="source" select="$refname"/>
  779. <xsl:with-param name="context-desc">meta source</xsl:with-param>
  780. <xsl:with-param name="message">
  781. <xsl:text>see http://docbook.sf.net/el/productname</xsl:text>
  782. </xsl:with-param>
  783. </xsl:call-template>
  784. <xsl:call-template name="log.message">
  785. <xsl:with-param name="level">Note</xsl:with-param>
  786. <xsl:with-param name="source" select="$refname"/>
  787. <xsl:with-param name="context-desc">meta source</xsl:with-param>
  788. <xsl:with-param name="message">
  789. <xsl:text>no refentry/refmeta/refmiscinfo@class=source</xsl:text>
  790. </xsl:with-param>
  791. </xsl:call-template>
  792. <xsl:call-template name="log.message">
  793. <xsl:with-param name="level">Note</xsl:with-param>
  794. <xsl:with-param name="source" select="$refname"/>
  795. <xsl:with-param name="context-desc">meta source</xsl:with-param>
  796. <xsl:with-param name="message">
  797. <xsl:text>see http://docbook.sf.net/el/refmiscinfo</xsl:text>
  798. </xsl:with-param>
  799. </xsl:call-template>
  800. </xsl:template>
  801. <!-- ==================================================================== -->
  802. <doc:template name="get.refentry.version" xmlns="">
  803. <refpurpose>Gets version metadata for a refentry</refpurpose>
  804. <refdescription id="get.refentry.version-desc">
  805. <para>A "version" is one part of a (potentially) two-part
  806. <replaceable>Name</replaceable>&#160;<replaceable>Version</replaceable>
  807. source field. For more details, see the documentation for the
  808. <function>get.refentry.source</function> template.</para>
  809. </refdescription>
  810. <refparameter id="get.refentry.version-params">
  811. <variablelist>
  812. <varlistentry>
  813. <term>refname</term>
  814. <listitem>
  815. <para>The first <tag>refname</tag> in the refentry</para>
  816. </listitem>
  817. </varlistentry>
  818. <varlistentry>
  819. <term>info</term>
  820. <listitem>
  821. <para>A set of info nodes (from a <tag>refentry</tag>
  822. element and its ancestors)</para>
  823. </listitem>
  824. </varlistentry>
  825. <varlistentry>
  826. <term>prefs</term>
  827. <listitem>
  828. <para>A node containing users preferences (from global
  829. stylesheet parameters)</para>
  830. </listitem>
  831. </varlistentry>
  832. </variablelist>
  833. </refparameter>
  834. <refreturn id="get.refentry.version-returns">
  835. <para>Depending on what output method is used for the
  836. current stylesheet, either returns a text node or possibly an element
  837. node, containing "version" data.</para>
  838. </refreturn>
  839. </doc:template>
  840. <xsl:template name="get.refentry.version">
  841. <xsl:param name="refname"/>
  842. <xsl:param name="info"/>
  843. <xsl:param name="prefs"/>
  844. <xsl:choose>
  845. <!-- * if profiling is enabled for version, and the -->
  846. <!-- * version profile is non-empty, use it -->
  847. <xsl:when test="not($prefs/@profileEnabled = 0) and
  848. not($prefs/@profile = '')">
  849. <xsl:call-template name="evaluate.info.profile">
  850. <xsl:with-param name="profile" select="$prefs/@profile"/>
  851. <xsl:with-param name="info" select="$info"/>
  852. </xsl:call-template>
  853. </xsl:when>
  854. <xsl:otherwise>
  855. <!-- * either profiling for source.name is not enabled, or-->
  856. <!-- * the source.name profile is empty; so we need to look -->
  857. <!-- * for a name to use -->
  858. <xsl:choose>
  859. <xsl:when test="refmeta/refmiscinfo[@class = 'version']">
  860. <xsl:apply-templates
  861. select="refmeta/refmiscinfo[@class = 'version'][1]/node()"/>
  862. </xsl:when>
  863. <xsl:otherwise>
  864. <xsl:choose>
  865. <xsl:when test="$info/productnumber">
  866. <xsl:call-template name="set.refentry.metadata">
  867. <xsl:with-param name="refname" select="$refname"/>
  868. <xsl:with-param
  869. name="info"
  870. select="($info[productnumber])[last()]"/>
  871. <xsl:with-param
  872. name="contents"
  873. select="(($info[productnumber])[last()]/productnumber)[1]"/>
  874. <xsl:with-param name="context">version</xsl:with-param>
  875. </xsl:call-template>
  876. </xsl:when>
  877. <xsl:when test="$info/edition">
  878. <xsl:call-template name="set.refentry.metadata">
  879. <xsl:with-param name="refname" select="$refname"/>
  880. <xsl:with-param
  881. name="info"
  882. select="($info[edition])[last()]"/>
  883. <xsl:with-param
  884. name="contents"
  885. select="(($info[edition])[last()]/edition)[1]"/>
  886. <xsl:with-param name="context">version</xsl:with-param>
  887. <xsl:with-param name="preferred">productnumber</xsl:with-param>
  888. </xsl:call-template>
  889. </xsl:when>
  890. <xsl:when test="$info/releaseinfo">
  891. <xsl:call-template name="set.refentry.metadata">
  892. <xsl:with-param name="refname" select="$refname"/>
  893. <xsl:with-param
  894. name="info"
  895. select="($info[releaseinfo])[last()]"/>
  896. <xsl:with-param
  897. name="contents"
  898. select="(($info[releaseinfo])[last()]/releaseinfo)[1]"/>
  899. <xsl:with-param name="context">version</xsl:with-param>
  900. <xsl:with-param name="preferred">productnumber</xsl:with-param>
  901. </xsl:call-template>
  902. </xsl:when>
  903. </xsl:choose>
  904. </xsl:otherwise>
  905. </xsl:choose>
  906. </xsl:otherwise>
  907. </xsl:choose>
  908. </xsl:template>
  909. <xsl:template name="report.missing.version">
  910. <xsl:param name="refname"/>
  911. <xsl:call-template name="log.message">
  912. <xsl:with-param name="level">Note</xsl:with-param>
  913. <xsl:with-param name="source" select="$refname"/>
  914. <xsl:with-param name="context-desc">meta version</xsl:with-param>
  915. <xsl:with-param name="message">
  916. <xsl:text>no *info/productnumber or alternative</xsl:text>
  917. </xsl:with-param>
  918. </xsl:call-template>
  919. <xsl:call-template name="log.message">
  920. <xsl:with-param name="level">Note</xsl:with-param>
  921. <xsl:with-param name="source" select="$refname"/>
  922. <xsl:with-param name="context-desc">meta version</xsl:with-param>
  923. <xsl:with-param name="message">
  924. <xsl:text>see http://docbook.sf.net/el/productnumber</xsl:text>
  925. </xsl:with-param>
  926. </xsl:call-template>
  927. <xsl:call-template name="log.message">
  928. <xsl:with-param name="level">Note</xsl:with-param>
  929. <xsl:with-param name="source" select="$refname"/>
  930. <xsl:with-param name="context-desc">meta version</xsl:with-param>
  931. <xsl:with-param name="message">
  932. <xsl:text>no refentry/refmeta/refmiscinfo@class=version</xsl:text>
  933. </xsl:with-param>
  934. </xsl:call-template>
  935. <xsl:call-template name="log.message">
  936. <xsl:with-param name="level">Note</xsl:with-param>
  937. <xsl:with-param name="source" select="$refname"/>
  938. <xsl:with-param name="context-desc">meta version</xsl:with-param>
  939. <xsl:with-param name="message">
  940. <xsl:text>see http://docbook.sf.net/el/refmiscinfo</xsl:text>
  941. </xsl:with-param>
  942. </xsl:call-template>
  943. </xsl:template>
  944. <!-- ==================================================================== -->
  945. <doc:template name="get.refentry.manual" xmlns="">
  946. <refpurpose>Gets source metadata for a refentry</refpurpose>
  947. <refdescription id="get.refentry.manual-desc">
  948. <para>The <literal>man(7)</literal> man page describes this as "the
  949. title of the manual (e.g., <citetitle>Linux Programmer's
  950. Manual</citetitle>)". Here are some examples from existing man pages:
  951. <itemizedlist>
  952. <listitem>
  953. <para><citetitle>dpkg utilities</citetitle>
  954. (<command>dpkg-name</command>)</para>
  955. </listitem>
  956. <listitem>
  957. <para><citetitle>User Contributed Perl Documentation</citetitle>
  958. (<command>GET</command>)</para>
  959. </listitem>
  960. <listitem>
  961. <para><citetitle>GNU Development Tools</citetitle>
  962. (<command>ld</command>)</para>
  963. </listitem>
  964. <listitem>
  965. <para><citetitle>Emperor Norton Utilities</citetitle>
  966. (<command>ddate</command>)</para>
  967. </listitem>
  968. <listitem>
  969. <para><citetitle>Debian GNU/Linux manual</citetitle>
  970. (<command>faked</command>)</para>
  971. </listitem>
  972. <listitem>
  973. <para><citetitle>GIMP Manual Pages</citetitle>
  974. (<command>gimp</command>)</para>
  975. </listitem>
  976. <listitem>
  977. <para><citetitle>KDOC Documentation System</citetitle>
  978. (<command>qt2kdoc</command>)</para>
  979. </listitem>
  980. </itemizedlist>
  981. </para>
  982. <para>The <literal>solbook(5)</literal> man page describes
  983. something very much like what <literal>man(7)</literal> calls
  984. "manual", except that <literal>solbook(5)</literal> names it
  985. "sectdesc" and describes it like this:
  986. <blockquote>
  987. <para>This is the section title of the reference page; for
  988. example <literal>User Commands</literal>.</para>
  989. </blockquote>
  990. </para>
  991. </refdescription>
  992. <refparameter id="get.refentry.manual-params">
  993. <variablelist>
  994. <varlistentry>
  995. <term>refname</term>
  996. <listitem>
  997. <para>The first <tag>refname</tag> in the refentry</para>
  998. </listitem>
  999. </varlistentry>
  1000. <varlistentry>
  1001. <term>info</term>
  1002. <listitem>
  1003. <para>A set of info nodes (from a <tag>refentry</tag>
  1004. element and its ancestors)</para>
  1005. </listitem>
  1006. </varlistentry>
  1007. <varlistentry>
  1008. <term>prefs</term>
  1009. <listitem>
  1010. <para>A node containing users preferences (from global
  1011. stylesheet parameters)</para>
  1012. </listitem>
  1013. </varlistentry>
  1014. </variablelist>
  1015. </refparameter>
  1016. <refreturn id="get.refentry.manual-returns">
  1017. <para>Returns a <tag>manual</tag> node.</para>
  1018. </refreturn>
  1019. </doc:template>
  1020. <xsl:template name="get.refentry.manual">
  1021. <xsl:param name="refname"/>
  1022. <xsl:param name="info"/>
  1023. <xsl:param name="prefs"/>
  1024. <xsl:variable name="Manual">
  1025. <xsl:choose>
  1026. <!-- * if profiling is enabled for manual, and the manual -->
  1027. <!-- * profile is non-empty, use it -->
  1028. <xsl:when test="not($prefs/@profileEnabled = 0) and
  1029. not($prefs/@profile = '')">
  1030. <xsl:call-template name="evaluate.info.profile">
  1031. <xsl:with-param name="profile" select="$prefs/@profile"/>
  1032. <xsl:with-param name="info" select="$info"/>
  1033. </xsl:call-template>
  1034. </xsl:when>
  1035. <xsl:otherwise>
  1036. <xsl:choose>
  1037. <xsl:when test="refmeta/refmiscinfo[@class = 'manual' or @class = 'sectdesc']">
  1038. <xsl:apply-templates
  1039. select="refmeta/refmiscinfo[@class = 'manual' or @class = 'sectdesc'][1]/node()"/>
  1040. </xsl:when>
  1041. <xsl:otherwise>
  1042. <!-- * only in the case of choosing appropriate -->
  1043. <!-- * "manual" content do we select the furthest -->
  1044. <!-- * (first) matching element instead of the -->
  1045. <!-- * closest (last) matching one -->
  1046. <xsl:choose>
  1047. <xsl:when test="ancestor::*/title">
  1048. <xsl:call-template name="set.refentry.metadata">
  1049. <xsl:with-param name="refname" select="$refname"/>
  1050. <xsl:with-param
  1051. name="info"
  1052. select="(ancestor::*[title])[1]"/>
  1053. <xsl:with-param
  1054. name="contents"
  1055. select="(ancestor::*[title])[1]/title"/>
  1056. <xsl:with-param name="context">manual</xsl:with-param>
  1057. </xsl:call-template>
  1058. </xsl:when>
  1059. <xsl:when test="$info/title">
  1060. <xsl:call-template name="set.refentry.metadata">
  1061. <xsl:with-param name="refname" select="$refname"/>
  1062. <xsl:with-param
  1063. name="info"
  1064. select="($info[title])[1]"/>
  1065. <xsl:with-param
  1066. name="contents"
  1067. select="(($info[title])[1]/title)[1]"/>
  1068. <xsl:with-param name="context">manual</xsl:with-param>
  1069. </xsl:call-template>
  1070. </xsl:when>
  1071. <xsl:otherwise>
  1072. </xsl:otherwise>
  1073. </xsl:choose>
  1074. </xsl:otherwise>
  1075. </xsl:choose>
  1076. </xsl:otherwise>
  1077. </xsl:choose>
  1078. </xsl:variable>
  1079. <xsl:choose>
  1080. <xsl:when test="not($Manual = '')">
  1081. <xsl:copy-of select="$Manual"/>
  1082. </xsl:when>
  1083. <!-- * if no Manual, use contents of specified fallback (if any) -->
  1084. <xsl:when test="not($prefs/@fallback = '')">
  1085. <xsl:variable name="manual.fallback">
  1086. <xsl:call-template name="evaluate.info.profile">
  1087. <xsl:with-param name="profile" select="$prefs/@fallback"/>
  1088. <xsl:with-param name="info" select="$info"/>
  1089. </xsl:call-template>
  1090. </xsl:variable>
  1091. <!-- * At this point, we know that we don't have properly marked-up -->
  1092. <!-- * manual metadata, so even if we do have manual fallback -->
  1093. <!-- * content, we still report to the user that it should be -->
  1094. <!-- * marked up properly instead. -->
  1095. <xsl:if test="$refentry.meta.get.quietly = 0">
  1096. <xsl:call-template name="report.missing.manual">
  1097. <xsl:with-param name="refname" select="$refname"/>
  1098. </xsl:call-template>
  1099. </xsl:if>
  1100. <xsl:choose>
  1101. <xsl:when test="not($manual.fallback = '')">
  1102. <xsl:value-of select="$manual.fallback"/>
  1103. <xsl:if test="$refentry.meta.get.quietly = 0">
  1104. <xsl:call-template name="log.message">
  1105. <xsl:with-param name="level">Warn</xsl:with-param>
  1106. <xsl:with-param name="source" select="$refname"/>
  1107. <xsl:with-param name="context-desc">meta manual</xsl:with-param>
  1108. <xsl:with-param name="message">
  1109. <xsl:text>using</xsl:text>
  1110. <xsl:text> "</xsl:text>
  1111. <xsl:value-of select="$manual.fallback"/>
  1112. <xsl:text>" </xsl:text>
  1113. <xsl:text>for "manual"</xsl:text>
  1114. </xsl:with-param>
  1115. </xsl:call-template>
  1116. </xsl:if>
  1117. </xsl:when>
  1118. <xsl:otherwise>
  1119. <!-- * we have nothing appropriate to use for manual, and no fallback -->
  1120. <!-- * content, so report insert a fixme -->
  1121. <xsl:text>[FIXME: manual]</xsl:text>
  1122. <xsl:if test="$refentry.meta.get.quietly = 0">
  1123. <xsl:call-template name="log.message">
  1124. <xsl:with-param name="level">Warn</xsl:with-param>
  1125. <xsl:with-param name="source" select="$refname"/>
  1126. <xsl:with-param name="context-desc">meta manual</xsl:with-param>
  1127. <xsl:with-param name="message">
  1128. <xsl:text>no fallback for manual, so inserted a fixme</xsl:text>
  1129. </xsl:with-param>
  1130. </xsl:call-template>
  1131. </xsl:if>
  1132. </xsl:otherwise>
  1133. </xsl:choose>
  1134. </xsl:when>
  1135. <xsl:otherwise>
  1136. <!-- * we have nothing appropriate to use for manual, and no fallback -->
  1137. <!-- * given, so insert a fixme -->
  1138. <xsl:text>[FIXME: manual]</xsl:text>
  1139. <xsl:if test="$refentry.meta.get.quietly = 0">
  1140. <xsl:call-template name="log.message">
  1141. <xsl:with-param name="level">Warn</xsl:with-param>
  1142. <xsl:with-param name="source" select="$refname"/>
  1143. <xsl:with-param name="context-desc">meta manual</xsl:with-param>
  1144. <xsl:with-param name="message">
  1145. <xsl:text>no manual fallback given, so inserted a fixme</xsl:text>
  1146. </xsl:with-param>
  1147. </xsl:call-template>
  1148. </xsl:if>
  1149. </xsl:otherwise>
  1150. </xsl:choose>
  1151. </xsl:template>
  1152. <xsl:template name="report.missing.manual">
  1153. <xsl:param name="refname"/>
  1154. <xsl:call-template name="log.message">
  1155. <xsl:with-param name="level">Note</xsl:with-param>
  1156. <xsl:with-param name="source" select="$refname"/>
  1157. <xsl:with-param name="context-desc">meta manual</xsl:with-param>
  1158. <xsl:with-param name="message">
  1159. <xsl:text>no titled ancestor of refentry</xsl:text>
  1160. </xsl:with-param>
  1161. </xsl:call-template>
  1162. <xsl:call-template name="log.message">
  1163. <xsl:with-param name="level">Note</xsl:with-param>
  1164. <xsl:with-param name="source" select="$refname"/>
  1165. <xsl:with-param name="context-desc">meta manual</xsl:with-param>
  1166. <xsl:with-param name="message">
  1167. <xsl:text>no refentry/refmeta/refmiscinfo@class=manual</xsl:text>
  1168. </xsl:with-param>
  1169. </xsl:call-template>
  1170. <xsl:call-template name="log.message">
  1171. <xsl:with-param name="level">Note</xsl:with-param>
  1172. <xsl:with-param name="source" select="$refname"/>
  1173. <xsl:with-param name="context-desc">meta manual</xsl:with-param>
  1174. <xsl:with-param name="message">
  1175. <xsl:text>see http://docbook.sf.net/el/refmiscinfo</xsl:text>
  1176. </xsl:with-param>
  1177. </xsl:call-template>
  1178. </xsl:template>
  1179. <!-- ====================================================================== -->
  1180. <doc:template name="get.refentry.metadata.prefs" xmlns="">
  1181. <refpurpose>Gets user preferences for refentry metadata gathering</refpurpose>
  1182. <refdescription id="get.refentry.metadata.prefs-desc">
  1183. <para>The DocBook XSL stylesheets include several user-configurable
  1184. global stylesheet parameters for controlling <tag>refentry</tag>
  1185. metadata gathering. Those parameters are not read directly by the
  1186. other <tag>refentry</tag> metadata-gathering
  1187. templates. Instead, they are read only by the
  1188. <function>get.refentry.metadata.prefs</function> template,
  1189. which assembles them into a structure that is then passed to
  1190. the other <tag>refentry</tag> metadata-gathering
  1191. templates.</para>
  1192. <para>So the, <function>get.refentry.metadata.prefs</function>
  1193. template is the only interface to collecting stylesheet parameters for
  1194. controlling <tag>refentry</tag> metadata gathering.</para>
  1195. </refdescription>
  1196. <refparameter id="get.refentry.metadata.prefs-params">
  1197. <para>There are no local parameters for this template; however, it
  1198. does rely on a number of global parameters.</para>
  1199. </refparameter>
  1200. <refreturn id="get.refentry.metadata.prefs-returns">
  1201. <para>Returns a <tag>manual</tag> node.</para>
  1202. </refreturn>
  1203. </doc:template>
  1204. <xsl:template name="get.refentry.metadata.prefs">
  1205. <DatePrefs>
  1206. <xsl:attribute name="profile">
  1207. <xsl:value-of select="$refentry.date.profile"/>
  1208. </xsl:attribute>
  1209. <xsl:attribute name="profileEnabled">
  1210. <xsl:value-of select="$refentry.date.profile.enabled"/>
  1211. </xsl:attribute>
  1212. </DatePrefs>
  1213. <SourcePrefs>
  1214. <xsl:attribute name="fallback">
  1215. <xsl:value-of select="$refentry.source.fallback.profile"/>
  1216. </xsl:attribute>
  1217. <Name>
  1218. <xsl:attribute name="profile">
  1219. <xsl:value-of select="$refentry.source.name.profile"/>
  1220. </xsl:attribute>
  1221. <xsl:attribute name="profileEnabled">
  1222. <xsl:value-of select="$refentry.source.name.profile.enabled"/>
  1223. </xsl:attribute>
  1224. <xsl:attribute name="suppress">
  1225. <xsl:value-of select="$refentry.source.name.suppress"/>
  1226. </xsl:attribute>
  1227. </Name>
  1228. <Version>
  1229. <xsl:attribute name="profile">
  1230. <xsl:value-of select="$refentry.version.profile"/>
  1231. </xsl:attribute>
  1232. <xsl:attribute name="profileEnabled">
  1233. <xsl:value-of select="$refentry.version.profile.enabled"/>
  1234. </xsl:attribute>
  1235. <xsl:attribute name="suppress">
  1236. <xsl:value-of select="$refentry.version.suppress"/>
  1237. </xsl:attribute>
  1238. </Version>
  1239. </SourcePrefs>
  1240. <ManualPrefs>
  1241. <xsl:attribute name="fallback">
  1242. <xsl:value-of select="$refentry.manual.fallback.profile"/>
  1243. </xsl:attribute>
  1244. <xsl:attribute name="profile">
  1245. <xsl:value-of select="$refentry.manual.profile"/>
  1246. </xsl:attribute>
  1247. <xsl:attribute name="profileEnabled">
  1248. <xsl:value-of select="$refentry.manual.profile.enabled"/>
  1249. </xsl:attribute>
  1250. </ManualPrefs>
  1251. </xsl:template>
  1252. <!-- ====================================================================== -->
  1253. <doc:template name="set.refentry.metadata" xmlns="">
  1254. <refpurpose>Sets content of a refentry metadata item</refpurpose>
  1255. <refdescription id="set.refentry.metadata-desc">
  1256. <para>The <function>set.refentry.metadata</function> template is
  1257. called each time a suitable source element is found for a certain
  1258. metadata field.</para>
  1259. </refdescription>
  1260. <refparameter id="set.refentry.metadata-params">
  1261. <variablelist>
  1262. <varlistentry>
  1263. <term>refname</term>
  1264. <listitem>
  1265. <para>The first <tag>refname</tag> in the refentry</para>
  1266. </listitem>
  1267. </varlistentry>
  1268. <varlistentry>
  1269. <term>info</term>
  1270. <listitem>
  1271. <para>A single *info node that contains the selected source element.</para>
  1272. </listitem>
  1273. </varlistentry>
  1274. <varlistentry>
  1275. <term>contents</term>
  1276. <listitem>
  1277. <para>A node containing the selected source element.</para>
  1278. </listitem>
  1279. </varlistentry>
  1280. <varlistentry>
  1281. <term>context</term>
  1282. <listitem>
  1283. <para>A string describing the metadata context in which the
  1284. <function>set.refentry.metadata</function> template was
  1285. called: either "date", "source", "version", or "manual".</para>
  1286. </listitem>
  1287. </varlistentry>
  1288. </variablelist>
  1289. </refparameter>
  1290. <refreturn id="set.refentry.metadata-returns">
  1291. <para>Returns formatted contents of a selected source element.</para></refreturn>
  1292. </doc:template>
  1293. <xsl:template name="set.refentry.metadata">
  1294. <xsl:param name="refname"/>
  1295. <xsl:param name="info"/>
  1296. <xsl:param name="contents"/>
  1297. <xsl:param name="context"/>
  1298. <xsl:param name="preferred"/>
  1299. <!-- * <xsl:if test="not($preferred = '')"> -->
  1300. <!-- * <xsl:if test="$refentry.meta.get.quietly = 0"> -->
  1301. <!-- * <xsl:call-template name="log.message"> -->
  1302. <!-- * <xsl:with-param name="level">Note</xsl:with-param> -->
  1303. <!-- * <xsl:with-param name="source" select="$refname"/> -->
  1304. <!-- * <xsl:with-param name="context-desc" select="concat('meta ', $context)"/> -->
  1305. <!-- * <xsl:with-param name="message" select="concat('No ', $preferred)"/> -->
  1306. <!-- * </xsl:call-template> -->
  1307. <!-- * <xsl:call-template name="log.message"> -->
  1308. <!-- * <xsl:with-param name="level">Note</xsl:with-param> -->
  1309. <!-- * <xsl:with-param name="source" select="$refname"/> -->
  1310. <!-- * <xsl:with-param name="context-desc" select="concat('meta ', $context)"/> -->
  1311. <!-- * <xsl:with-param name="message"> -->
  1312. <!-- * <xsl:text>no refentry/refmeta/refmiscinfo@class=</xsl:text> -->
  1313. <!-- * <xsl:value-of select="$context"/> -->
  1314. <!-- * </xsl:with-param> -->
  1315. <!-- * </xsl:call-template> -->
  1316. <!-- * <xsl:call-template name="log.message"> -->
  1317. <!-- * <xsl:with-param name="level">Note</xsl:with-param> -->
  1318. <!-- * <xsl:with-param name="source" select="$refname"/> -->
  1319. <!-- * <xsl:with-param name="context-desc" select="concat('meta ', $context)"/> -->
  1320. <!-- * <xsl:with-param name="message" select="concat('Using ', local-name($contents))"/> -->
  1321. <!-- * </xsl:call-template> -->
  1322. <!-- * </xsl:if> -->
  1323. <!-- * </xsl:if> -->
  1324. <xsl:value-of select="$contents"/>
  1325. </xsl:template>
  1326. </xsl:stylesheet>