profile-docbook.xsl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <?xml version="1.0" encoding="US-ASCII"?>
  2. <!--This file was created automatically by xsl2profile-->
  3. <!--from the DocBook XSL stylesheets.-->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" xmlns:exslt="http://exslt.org/common" exslt:dummy="dummy" ng:dummy="dummy" db:dummy="dummy" extension-element-prefixes="exslt" exclude-result-prefixes="exsl exslt" version="1.0">
  5. <xsl:import href="../html/docbook.xsl"/>
  6. <xsl:import href="../html/manifest.xsl"/>
  7. <!-- * html-synop.xsl file is generated by build -->
  8. <xsl:import href="html-synop.xsl"/>
  9. <xsl:output method="text" encoding="UTF-8" indent="no"/>
  10. <!-- ********************************************************************
  11. $Id: docbook.xsl 8841 2010-08-14 07:21:25Z mzjn $
  12. ********************************************************************
  13. This file is part of the XSL DocBook Stylesheet distribution.
  14. See ../README or http://docbook.sf.net/release/xsl/current/ for
  15. copyright and other information.
  16. ******************************************************************** -->
  17. <!-- ==================================================================== -->
  18. <xsl:include href="../common/refentry.xsl"/>
  19. <xsl:include href="../common/charmap.xsl"/>
  20. <xsl:include href="param.xsl"/>
  21. <xsl:include href="utility.xsl"/>
  22. <xsl:include href="info.xsl"/>
  23. <xsl:include href="other.xsl"/>
  24. <xsl:include href="refentry.xsl"/>
  25. <xsl:include href="block.xsl"/>
  26. <xsl:include href="inline.xsl"/>
  27. <xsl:include href="synop.xsl"/>
  28. <xsl:include href="lists.xsl"/>
  29. <xsl:include href="endnotes.xsl"/>
  30. <xsl:include href="table.xsl"/>
  31. <xsl:include href="pi.xsl"/>
  32. <!-- * we rename the following just to avoid using params with "man" -->
  33. <!-- * prefixes in the table.xsl stylesheet (because that stylesheet -->
  34. <!-- * can potentially be reused for more than just man output) -->
  35. <xsl:param name="tbl.font.headings" select="$man.font.table.headings"/>
  36. <xsl:param name="tbl.font.title" select="$man.font.table.title"/>
  37. <xsl:param name="stylesheet.result.type" select="'manpages'"/>
  38. <!-- ==================================================================== -->
  39. <xslo:include xmlns:xslo="http://www.w3.org/1999/XSL/Transform" href="../profiling/profile-mode.xsl"/><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-content"><xslo:choose><xslo:when test="*/self::ng:* or */self::db:*"><xslo:message>Note: namesp. cut : stripped namespace before processing</xslo:message><xslo:variable name="stripped-content"><xslo:apply-templates select="/" mode="stripNS"/></xslo:variable><xslo:message>Note: namesp. cut : processing stripped document</xslo:message><xslo:apply-templates select="exslt:node-set($stripped-content)" mode="profile"/></xslo:when><xslo:otherwise><xslo:apply-templates select="/" mode="profile"/></xslo:otherwise></xslo:choose></xslo:variable><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-nodes" select="exslt:node-set($profiled-content)"/><xsl:template match="/">
  40. <!-- * Get a title for current doc so that we let the user -->
  41. <!-- * know what document we are processing at this point. -->
  42. <xsl:variable name="doc.title">
  43. <xsl:call-template name="get.doc.title"/>
  44. </xsl:variable>
  45. <xsl:choose>
  46. <!-- * when we find a namespaced document, strip the -->
  47. <!-- * namespace and then continue processing it. -->
  48. <xsl:when test="false()"/>
  49. <xsl:when test="//*[local-name() = 'refentry']">
  50. <!-- * Check to see if we have any refentry children in this -->
  51. <!-- * document; if so, process them. The reason we use -->
  52. <!-- * local-name()=refentry (instead of just //refentry) to to -->
  53. <!-- * check for refentry children is because this stylsheet is -->
  54. <!-- * also post-processed by the stylesheet build to create the -->
  55. <!-- * manpages/profile-docbook.xsl, and the refentry child check -->
  56. <!-- * in the profile-docbook.xsl stylesheet won't work if we do -->
  57. <!-- * a simple //refentry check. -->
  58. <xsl:apply-templates select="$profiled-nodes//refentry"/>
  59. <!-- * if $man.output.manifest.enabled is non-zero, -->
  60. <!-- * generate a manifest file -->
  61. <xsl:if test="not($man.output.manifest.enabled = 0)">
  62. <xsl:call-template name="generate.manifest">
  63. <xsl:with-param name="filename">
  64. <xsl:choose>
  65. <xsl:when test="not($man.output.manifest.filename = '')">
  66. <!-- * If a name for the manifest file is specified, -->
  67. <!-- * use that name. -->
  68. <xsl:value-of select="$man.output.manifest.filename"/>
  69. </xsl:when>
  70. <xsl:otherwise>
  71. <!-- * Otherwise, if user has unset -->
  72. <!-- * $man.output.manifest.filename, default to -->
  73. <!-- * using "MAN.MANIFEST" as the filename. Because -->
  74. <!-- * $man.output.manifest.enabled is non-zero and -->
  75. <!-- * so we must have a filename in order to -->
  76. <!-- * generate the manifest. -->
  77. <xsl:text>MAN.MANIFEST</xsl:text>
  78. </xsl:otherwise>
  79. </xsl:choose>
  80. </xsl:with-param>
  81. </xsl:call-template>
  82. </xsl:if>
  83. </xsl:when>
  84. <xsl:otherwise>
  85. <!-- * Otherwise, the document does not contain any -->
  86. <!-- * refentry elements, so log/emit message and stop. -->
  87. <xsl:call-template name="log.message">
  88. <xsl:with-param name="level">Erro</xsl:with-param>
  89. <xsl:with-param name="source" select="$doc.title"/>
  90. <xsl:with-param name="context-desc">
  91. <xsl:text> no refentry</xsl:text>
  92. </xsl:with-param>
  93. <xsl:with-param name="message">
  94. <xsl:text>No refentry elements found</xsl:text>
  95. <xsl:if test="$doc.title != ''">
  96. <xsl:text> in "</xsl:text>
  97. <xsl:choose>
  98. <xsl:when test="string-length($doc.title) &gt; 30">
  99. <xsl:value-of select="substring($doc.title,1,30)"/>
  100. <xsl:text>...</xsl:text>
  101. </xsl:when>
  102. <xsl:otherwise>
  103. <xsl:value-of select="$doc.title"/>
  104. </xsl:otherwise>
  105. </xsl:choose>
  106. <xsl:text>"</xsl:text>
  107. </xsl:if>
  108. <xsl:text>.</xsl:text>
  109. </xsl:with-param>
  110. </xsl:call-template>
  111. </xsl:otherwise>
  112. </xsl:choose>
  113. </xsl:template>
  114. <!-- ============================================================== -->
  115. <xsl:template match="refentry">
  116. <xsl:param name="lang">
  117. <xsl:call-template name="l10n.language"/>
  118. </xsl:param>
  119. <!-- * Just use the first refname found as the "name" of the man -->
  120. <!-- * page (which may different from the "title"...) -->
  121. <xsl:variable name="first.refname" select="refnamediv[1]/refname[1]"/>
  122. <xsl:call-template name="root.messages">
  123. <xsl:with-param name="refname" select="$first.refname"/>
  124. </xsl:call-template>
  125. <!-- * Because there are several times when we need to check *info of -->
  126. <!-- * each refentry and its ancestors, we get those and store the -->
  127. <!-- * data from them as a node-set in memory. -->
  128. <!-- * Make a node-set with contents of *info -->
  129. <xsl:variable name="get.info" select="ancestor-or-self::*/*[substring(local-name(), string-length(local-name()) - 3) = 'info']"/>
  130. <xsl:variable name="info" select="exsl:node-set($get.info)"/>
  131. <!-- * The get.refentry.metadata template is in -->
  132. <!-- * ../common/refentry.xsl. It looks for metadata in $info -->
  133. <!-- * and in various other places and then puts it into a form -->
  134. <!-- * that's easier for us to digest. -->
  135. <xsl:variable name="get.refentry.metadata">
  136. <xsl:call-template name="get.refentry.metadata">
  137. <xsl:with-param name="refname" select="$first.refname"/>
  138. <xsl:with-param name="info" select="$info"/>
  139. <xsl:with-param name="prefs" select="$refentry.metadata.prefs"/>
  140. </xsl:call-template>
  141. </xsl:variable>
  142. <xsl:variable name="refentry.metadata" select="exsl:node-set($get.refentry.metadata)"/>
  143. <!-- * Assemble the various parts into a complete page, then store into -->
  144. <!-- * $manpage.contents so that we can manipluate them further. -->
  145. <xsl:variable name="manpage.contents">
  146. <!-- * preprocessor invocation (need for legacy AT&T troff use) -->
  147. <!-- * this tells troff to pre-process the page through tbl(1) -->
  148. <!-- * (groff can figure it out automatically, but AT&T troff can't) -->
  149. <xsl:text>'\" t
  150. </xsl:text>
  151. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  152. <!-- * top.comment = commented-out section at top of roff source -->
  153. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  154. <xsl:call-template name="top.comment">
  155. <xsl:with-param name="info" select="$info"/>
  156. <xsl:with-param name="date" select="$refentry.metadata/date"/>
  157. <xsl:with-param name="title" select="$refentry.metadata/title"/>
  158. <xsl:with-param name="manual" select="$refentry.metadata/manual"/>
  159. <xsl:with-param name="source" select="$refentry.metadata/source"/>
  160. <xsl:with-param name="refname" select="$first.refname"/>
  161. </xsl:call-template>
  162. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  163. <!-- * TH.title.line = title line in header/footer of man page -->
  164. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  165. <xsl:call-template name="TH.title.line">
  166. <!-- * .TH TITLE section extra1 extra2 extra3 -->
  167. <!-- * -->
  168. <!-- * According to the man(7) man page: -->
  169. <!-- * -->
  170. <!-- * extra1 = date, "the date of the last revision" -->
  171. <!-- * extra2 = source, "the source of the command" -->
  172. <!-- * extra3 = manual, "the title of the manual -->
  173. <!-- * (e.g., Linux Programmer's Manual)" -->
  174. <!-- * -->
  175. <!-- * So, we end up with: -->
  176. <!-- * -->
  177. <!-- * .TH TITLE section date source manual -->
  178. <!-- * -->
  179. <xsl:with-param name="title" select="$refentry.metadata/title"/>
  180. <xsl:with-param name="section" select="$refentry.metadata/section"/>
  181. <xsl:with-param name="extra1" select="$refentry.metadata/date"/>
  182. <xsl:with-param name="extra2" select="$refentry.metadata/source"/>
  183. <xsl:with-param name="extra3" select="$refentry.metadata/manual"/>
  184. </xsl:call-template>
  185. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  186. <!-- * (re)define some macros -->
  187. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  188. <xsl:call-template name="define.portability.macros"/>
  189. <xsl:if test="not($man.output.better.ps.enabled = 0)">
  190. <xsl:call-template name="define.macros"/>
  191. </xsl:if>
  192. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  193. <!-- * Set default hyphenation, justification, indentation, and -->
  194. <!-- * line-breaking -->
  195. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  196. <xsl:call-template name="set.default.formatting"/>
  197. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  198. <!-- * Main body of man page -->
  199. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  200. <xsl:text>.\" -----------------------------------------------------------------
  201. </xsl:text>
  202. <xsl:text>.\" * MAIN CONTENT STARTS HERE *
  203. </xsl:text>
  204. <xsl:text>.\" -----------------------------------------------------------------
  205. </xsl:text>
  206. <xsl:apply-templates/>
  207. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  208. <!-- * AUTHOR section -->
  209. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  210. <xsl:if test="not($man.authors.section.enabled = 0)">
  211. <xsl:call-template name="author.section">
  212. <xsl:with-param name="info" select="$info"/>
  213. </xsl:call-template>
  214. </xsl:if>
  215. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  216. <!-- * COPYRIGHT section -->
  217. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  218. <xsl:if test="not($man.copyright.section.enabled = 0)">
  219. <xsl:call-template name="copyright.section">
  220. <xsl:with-param name="info" select="$info"/>
  221. </xsl:call-template>
  222. </xsl:if>
  223. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  224. <!-- * NOTES list (only if user wants endnotes numbered and/or listed) -->
  225. <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  226. <xsl:if test="$man.endnotes.list.enabled != 0 or $man.endnotes.are.numbered != 0">
  227. <xsl:call-template name="endnotes.list"/>
  228. </xsl:if>
  229. </xsl:variable> <!-- * end of manpage.contents -->
  230. <!-- * Prepare the page contents for final output, then store in -->
  231. <!-- * $manpage.contents.prepared so the we can pass it on to the -->
  232. <!-- * write.text.chunk() function -->
  233. <xsl:variable name="manpage.contents.prepared">
  234. <!-- * "Preparing" the page contents involves, at a minimum, -->
  235. <!-- * doubling any backslashes found (so they aren't interpreted -->
  236. <!-- * as roff escapes). -->
  237. <!-- * -->
  238. <!-- * If $charmap.enabled is true, "preparing" the page contents also -->
  239. <!-- * involves applying a character map to convert Unicode symbols and -->
  240. <!-- * special characters into corresponding roff escape sequences. -->
  241. <xsl:call-template name="prepare.manpage.contents">
  242. <xsl:with-param name="content" select="$manpage.contents"/>
  243. </xsl:call-template>
  244. </xsl:variable>
  245. <!-- * Write the prepared page contents to disk to create -->
  246. <!-- * the final man page. -->
  247. <xsl:call-template name="write.man.file">
  248. <xsl:with-param name="name" select="$first.refname"/>
  249. <xsl:with-param name="section" select="$refentry.metadata/section"/>
  250. <xsl:with-param name="lang" select="$lang"/>
  251. <xsl:with-param name="content" select="$manpage.contents.prepared"/>
  252. </xsl:call-template>
  253. <!-- * Generate "stub" (alias) pages (if any needed) -->
  254. <xsl:call-template name="write.stubs">
  255. <xsl:with-param name="first.refname" select="$first.refname"/>
  256. <xsl:with-param name="section" select="$refentry.metadata/section"/>
  257. <xsl:with-param name="lang" select="$lang"/>
  258. </xsl:call-template>
  259. </xsl:template>
  260. </xsl:stylesheet>