other.xsl 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:exsl="http://exslt.org/common"
  4. xmlns:ng="http://docbook.org/docbook-ng"
  5. xmlns:db="http://docbook.org/ns/docbook"
  6. xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
  7. exclude-result-prefixes="exsl"
  8. version='1.0'>
  9. <!-- ********************************************************************
  10. $Id: other.xsl 8865 2010-08-20 18:22:06Z mzjn $
  11. ********************************************************************
  12. This file is part of the XSL DocBook Stylesheet distribution.
  13. See ../README or http://docbook.sf.net/release/xsl/current/ for
  14. copyright and other information.
  15. ******************************************************************** -->
  16. <!-- * This file contains named templates related to things other than -->
  17. <!-- * just assembling the actual text of the main text flow of each man -->
  18. <!-- * page. This "other" stuff currently amounts to these steps: -->
  19. <!-- * -->
  20. <!-- * - get contents of the "map" used to convert special characters -->
  21. <!-- * - output boilerplate messages -->
  22. <!-- * - escape backslash, dot, dash, and apostrophe characters -->
  23. <!-- * - convert non-breaking spaces -->
  24. <!-- * - add a comment to top part of roff source of each page -->
  25. <!-- * - make a .TH title line (for controlling page header/footer) -->
  26. <!-- * - set hyphenation, alignment, indent & line-breaking defaults -->
  27. <!-- * - "prepare" the complete man page contents for final output -->
  28. <!-- * - write the actual man file to the filesystem -->
  29. <!-- * - write any "stub" pages to the filesystem -->
  30. <!-- * -->
  31. <!-- * The templates in this file are actually called only once per -->
  32. <!-- * each Refentry; they are just in a separate file for the purpose -->
  33. <!-- * of keeping things modular. -->
  34. <!-- ==================================================================== -->
  35. <xsl:preserve-space elements="*"/>
  36. <xsl:strip-space elements="
  37. abstract affiliation anchor answer appendix area areaset areaspec
  38. artheader article audiodata audioobject author authorblurb authorgroup
  39. beginpage bibliodiv biblioentry bibliography biblioset blockquote book
  40. bookbiblio bookinfo callout calloutlist caption caution chapter
  41. citerefentry cmdsynopsis co collab colophon colspec confgroup
  42. copyright dedication docinfo editor entrytbl epigraph equation
  43. example figure footnote footnoteref formalpara funcprototype
  44. funcsynopsis glossary glossdef glossdiv glossentry glosslist graphicco
  45. group highlights imagedata imageobject imageobjectco important index
  46. indexdiv indexentry indexterm informalequation informalexample
  47. informalfigure informaltable inlineequation inlinemediaobject
  48. itemizedlist itermset keycombo keywordset legalnotice listitem lot
  49. mediaobject mediaobjectco menuchoice msg msgentry msgexplan msginfo
  50. msgmain msgrel msgset msgsub msgtext note objectinfo
  51. orderedlist othercredit part partintro preface printhistory procedure
  52. programlistingco publisher qandadiv qandaentry qandaset question
  53. refentry reference refmeta refnamediv refsection refsect1 refsect1info refsect2
  54. refsect2info refsect3 refsect3info refsynopsisdiv refsynopsisdivinfo
  55. revhistory revision row sbr screenco screenshot sect1 sect1info sect2
  56. sect2info sect3 sect3info sect4 sect4info sect5 sect5info section
  57. sectioninfo seglistitem segmentedlist seriesinfo set setindex setinfo
  58. shortcut sidebar simplelist simplesect spanspec step subject
  59. subjectset substeps synopfragment table tbody textobject tfoot tgroup
  60. thead tip toc tocchap toclevel1 toclevel2 toclevel3 toclevel4
  61. toclevel5 tocpart varargs variablelist varlistentry videodata
  62. videoobject void warning subjectset
  63. classsynopsis
  64. constructorsynopsis
  65. destructorsynopsis
  66. fieldsynopsis
  67. methodparam
  68. methodsynopsis
  69. ooclass
  70. ooexception
  71. oointerface
  72. simplemsgentry
  73. manvolnum
  74. "/>
  75. <!-- ==================================================================== -->
  76. <!-- * Get character map contents -->
  77. <!-- ==================================================================== -->
  78. <xsl:variable name="man.charmap.contents">
  79. <xsl:if test="$man.charmap.enabled != 0">
  80. <xsl:variable name="lang">
  81. <xsl:call-template name="l10n.language">
  82. <xsl:with-param name="target" select="//refentry[1]"/>
  83. </xsl:call-template>
  84. </xsl:variable>
  85. <xsl:call-template name="read-character-map">
  86. <xsl:with-param name="use.subset" select="$man.charmap.use.subset"/>
  87. <xsl:with-param name="subset.profile">
  88. <xsl:choose>
  89. <xsl:when test="$lang = 'en'">
  90. <xsl:value-of select="$man.charmap.subset.profile.english"/>
  91. </xsl:when>
  92. <xsl:otherwise>
  93. <xsl:value-of select="$man.charmap.subset.profile"/>
  94. </xsl:otherwise>
  95. </xsl:choose>
  96. </xsl:with-param>
  97. <xsl:with-param name="uri">
  98. <xsl:choose>
  99. <xsl:when test="$man.charmap.uri != ''">
  100. <xsl:value-of select="$man.charmap.uri"/>
  101. </xsl:when>
  102. <xsl:otherwise>
  103. <xsl:value-of select="'../manpages/charmap.groff.xsl'"/>
  104. </xsl:otherwise>
  105. </xsl:choose>
  106. </xsl:with-param>
  107. </xsl:call-template>
  108. </xsl:if>
  109. </xsl:variable>
  110. <!-- ==================================================================== -->
  111. <xsl:template name="root.messages">
  112. <xsl:param name="refname"/>
  113. <!-- redefine this any way you'd like to output messages -->
  114. <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE -->
  115. <!-- Example:
  116. <xsl:if test="//foo">
  117. <xsl:call-template name="log.message">
  118. <xsl:with-param name="level">Warn</xsl:with-param>
  119. <xsl:with-param name="source" select="$refname"/>
  120. <xsl:with-param name="context-desc">
  121. <xsl:text>limitation</xsl:text>
  122. </xsl:with-param>
  123. <xsl:with-param name="message">
  124. <xsl:text>Output for foo element is not yet supported.</xsl:text>
  125. </xsl:with-param>
  126. </xsl:call-template>
  127. </xsl:if>
  128. -->
  129. </xsl:template>
  130. <!-- ==================================================================== -->
  131. <!-- * Escape roff special chars -->
  132. <!-- ==================================================================== -->
  133. <!-- ******************************************************************** -->
  134. <!-- * -->
  135. <!-- * The backslash, dot, dash, and apostrophe (\, ., -, ') characters -->
  136. <!-- * have special meaning for roff, so before we do any other -->
  137. <!-- * processing, we must escape those characters where they appear in -->
  138. <!-- * the source content. -->
  139. <!-- * -->
  140. <!-- * Here we also deal with replacing U+00a0 (non-breaking space) with -->
  141. <!-- * its roff equivalent -->
  142. <!-- * -->
  143. <!-- ******************************************************************** -->
  144. <xsl:template match="//refentry//text()">
  145. <xsl:call-template name="escape.roff.specials">
  146. <xsl:with-param name="content">
  147. <xsl:value-of select="."/>
  148. </xsl:with-param>
  149. </xsl:call-template>
  150. </xsl:template>
  151. <xsl:template name="escape.roff.specials">
  152. <xsl:param name="content"/>
  153. <xsl:call-template name="convert.nobreak-space">
  154. <xsl:with-param name="content">
  155. <xsl:call-template name="escape.apostrophe">
  156. <xsl:with-param name="content">
  157. <xsl:call-template name="escape.dash">
  158. <xsl:with-param name="content">
  159. <xsl:call-template name="escape.dot">
  160. <xsl:with-param name="content">
  161. <xsl:call-template name="escape.backslash">
  162. <xsl:with-param name="content" select="$content"/>
  163. </xsl:call-template>
  164. </xsl:with-param>
  165. </xsl:call-template>
  166. </xsl:with-param>
  167. </xsl:call-template>
  168. </xsl:with-param>
  169. </xsl:call-template>
  170. </xsl:with-param>
  171. </xsl:call-template>
  172. </xsl:template>
  173. <xsl:template name="escape.backslash">
  174. <xsl:param name="content"/>
  175. <xsl:call-template name="string.subst">
  176. <xsl:with-param name="string" select="$content"/>
  177. <xsl:with-param name="target">\</xsl:with-param>
  178. <!-- * we use "\e" instead of "\\" because the groff docs say -->
  179. <!-- * that's the correct thing to do; also because testing -->
  180. <!-- * shows that "\\" doesn't always work as expected; for -->
  181. <!-- * example, "\\" within a table seems to mess things up -->
  182. <xsl:with-param name="replacement">\e</xsl:with-param>
  183. </xsl:call-template>
  184. </xsl:template>
  185. <xsl:template name="escape.dot">
  186. <xsl:param name="content"/>
  187. <xsl:call-template name="string.subst">
  188. <xsl:with-param name="string" select="$content"/>
  189. <xsl:with-param name="target">.</xsl:with-param>
  190. <xsl:with-param name="replacement">\&amp;.</xsl:with-param>
  191. </xsl:call-template>
  192. </xsl:template>
  193. <xsl:template name="escape.dash">
  194. <xsl:param name="content"/>
  195. <xsl:call-template name="string.subst">
  196. <xsl:with-param name="string" select="$content"/>
  197. <xsl:with-param name="target">-</xsl:with-param>
  198. <xsl:with-param name="replacement">\-</xsl:with-param>
  199. </xsl:call-template>
  200. </xsl:template>
  201. <xsl:template name="escape.apostrophe">
  202. <xsl:param name="content"/>
  203. <xsl:call-template name="string.subst">
  204. <xsl:with-param name="string" select="$content"/>
  205. <xsl:with-param name="target">'</xsl:with-param>
  206. <xsl:with-param name="replacement">\*(Aq</xsl:with-param>
  207. </xsl:call-template>
  208. </xsl:template>
  209. <xsl:template name="convert.nobreak-space">
  210. <xsl:param name="content"/>
  211. <xsl:call-template name="string.subst">
  212. <xsl:with-param name="string" select="$content"/>
  213. <xsl:with-param name="target">&#x00a0;</xsl:with-param>
  214. <!-- * A no-break space can be written two ways in roff; the -->
  215. <!-- * difference, according to the "Page Motions" node in the -->
  216. <!-- * groff info page, is: -->
  217. <!-- * -->
  218. <!-- * "\ " = -->
  219. <!-- * An unbreakable and unpaddable (i.e. not expanded -->
  220. <!-- * during filling) space. -->
  221. <!-- * -->
  222. <!-- * "\~" = -->
  223. <!-- * An unbreakable space that stretches like a normal -->
  224. <!-- * inter-word space when a line is adjusted." -->
  225. <!-- * -->
  226. <!-- * Unfortunately, roff seems to do some weird things with -->
  227. <!-- * long lines that only have words separated by "\~" -->
  228. <!-- * spaces, so it's safer just to stick with the "\ " space -->
  229. <!-- * -->
  230. <!-- * We append a "\&" to handle the case of a no-break space that -->
  231. <!-- * appears at the end of a line - because later processing will -->
  232. <!-- * cause that space to get eaten otherwise. -->
  233. <xsl:with-param name="replacement">\ \&amp;</xsl:with-param>
  234. </xsl:call-template>
  235. </xsl:template>
  236. <!-- ==================================================================== -->
  237. <!-- * top.comment generates a comment containing metadata for the man -->
  238. <!-- * page; for example, Author, Generator, and Date information -->
  239. <xsl:template name="top.comment">
  240. <xsl:param name="info"/>
  241. <xsl:param name="date"/>
  242. <xsl:param name="title"/>
  243. <xsl:param name="manual"/>
  244. <xsl:param name="source"/>
  245. <xsl:param name="refname"/>
  246. <xsl:text>.\" Title: </xsl:text>
  247. <xsl:call-template name="replace.dots.and.dashes">
  248. <xsl:with-param name="content" select="$title"/>
  249. </xsl:call-template>
  250. <xsl:text>&#10;</xsl:text>
  251. <xsl:text>.\" Author: </xsl:text>
  252. <xsl:call-template name="replace.dots.and.dashes">
  253. <xsl:with-param name="content">
  254. <xsl:call-template name="make.roff.metadata.author">
  255. <xsl:with-param name="info" select="$info"/>
  256. <xsl:with-param name="refname" select="$refname"/>
  257. </xsl:call-template>
  258. </xsl:with-param>
  259. </xsl:call-template>
  260. <xsl:text>&#10;</xsl:text>
  261. <xsl:text>.\" Generator: DocBook </xsl:text>
  262. <xsl:value-of select="$DistroTitle"/>
  263. <xsl:text> v</xsl:text>
  264. <xsl:call-template name="replace.dots.and.dashes">
  265. <xsl:with-param name="content" select="$VERSION"/>
  266. </xsl:call-template>
  267. <xsl:text> &lt;http://docbook.sf.net/></xsl:text>
  268. <xsl:text>&#10;</xsl:text>
  269. <xsl:text>.\" Date: </xsl:text>
  270. <xsl:call-template name="replace.dots.and.dashes">
  271. <xsl:with-param name="content" select="$date"/>
  272. </xsl:call-template>
  273. <xsl:text>&#10;</xsl:text>
  274. <xsl:text>.\" Manual: </xsl:text>
  275. <xsl:call-template name="replace.dots.and.dashes">
  276. <xsl:with-param name="content" select="$manual"/>
  277. </xsl:call-template>
  278. <xsl:text>&#10;</xsl:text>
  279. <xsl:text>.\" Source: </xsl:text>
  280. <xsl:call-template name="replace.dots.and.dashes">
  281. <xsl:with-param name="content" select="$source"/>
  282. </xsl:call-template>
  283. <xsl:text>&#10;</xsl:text>
  284. <xsl:text>.\" Language: </xsl:text>
  285. <xsl:call-template name="l10n.language.name"/>
  286. <xsl:text>&#10;</xsl:text>
  287. <xsl:text>.\"</xsl:text>
  288. <xsl:text>&#10;</xsl:text>
  289. </xsl:template>
  290. <!-- ==================================================================== -->
  291. <xsl:template name="TH.title.line">
  292. <!-- * The exact way that .TH contents are displayed is system- -->
  293. <!-- * dependent; it varies somewhat between OSes and roff -->
  294. <!-- * versions. Below is a description of how Linux systems with -->
  295. <!-- * a modern groff seem to render .TH contents. -->
  296. <!-- * -->
  297. <!-- * title(section) extra3 title(section) <- page header -->
  298. <!-- * extra2 extra1 title(section) <- page footer-->
  299. <!-- * -->
  300. <!-- * Or, using the names with which the man(7) man page refers -->
  301. <!-- * to the various fields: -->
  302. <!-- * -->
  303. <!-- * title(section) manual title(section) <- page header -->
  304. <!-- * source date title(section) <- page footer-->
  305. <!-- * -->
  306. <!-- * Note that while extra1, extra2, and extra3 are all (nominally) -->
  307. <!-- * optional, in practice almost all pages include an "extra1" -->
  308. <!-- * field, which is, universally, a date (in some form), and it is -->
  309. <!-- * always rendered in the same place (the middle footer position) -->
  310. <!-- * -->
  311. <!-- * Here are a couple of examples of real-world man pages that -->
  312. <!-- * have somewhat useful page headers/footers: -->
  313. <!-- * -->
  314. <!-- * gtk-options(7) GTK+ User's Manual gtk-options(7) -->
  315. <!-- * GTK+ 1.2 2003-10-20 gtk-options(7) -->
  316. <!-- * -->
  317. <!-- * svgalib(7) Svgalib User Manual svgalib(7) -->
  318. <!-- * Svgalib 1.4.1 16 December 1999 svgalib(7) -->
  319. <!-- * -->
  320. <xsl:param name="title"/>
  321. <xsl:param name="section"/>
  322. <xsl:param name="extra1"/>
  323. <xsl:param name="extra2"/>
  324. <xsl:param name="extra3"/>
  325. <xsl:call-template name="mark.subheading"/>
  326. <!-- * Note that we generate quotes around _every_ field in the -->
  327. <!-- * .TH title line, including the "title" and "section" -->
  328. <!-- * fields. That is because we use the contents of those "as -->
  329. <!-- * is", unchanged from the DocBook source; and DTD-based -->
  330. <!-- * validation does not provide a way to constrain them to be -->
  331. <!-- * "space free" -->
  332. <xsl:text>.TH "</xsl:text>
  333. <xsl:call-template name="string.upper">
  334. <xsl:with-param name="string">
  335. <xsl:choose>
  336. <xsl:when test="$man.th.title.max.length != ''">
  337. <xsl:value-of
  338. select="normalize-space(substring($title, 1, $man.th.title.max.length))"/>
  339. </xsl:when>
  340. <xsl:otherwise>
  341. <xsl:value-of select="normalize-space($title)"/>
  342. </xsl:otherwise>
  343. </xsl:choose>
  344. </xsl:with-param>
  345. </xsl:call-template>
  346. <xsl:text>" "</xsl:text>
  347. <xsl:value-of select="normalize-space($section)"/>
  348. <xsl:text>" "</xsl:text>
  349. <xsl:if test="$man.th.extra1.suppress = 0">
  350. <!-- * there is no max.length for the extra1 field; the reason -->
  351. <!-- * is, it is almost always a date, and it is not possible -->
  352. <!-- * to truncate dates without changing their meaning -->
  353. <xsl:value-of select="normalize-space($extra1)"/>
  354. </xsl:if>
  355. <xsl:text>" "</xsl:text>
  356. <xsl:if test="$man.th.extra2.suppress = 0">
  357. <xsl:choose>
  358. <!-- * if max.length is non-empty, use value to truncate field -->
  359. <xsl:when test="$man.th.extra2.max.length != ''">
  360. <xsl:value-of
  361. select="normalize-space(substring($extra2, 1, $man.th.extra2.max.length))"/>
  362. </xsl:when>
  363. <xsl:otherwise>
  364. <xsl:value-of select="normalize-space($extra2)"/>
  365. </xsl:otherwise>
  366. </xsl:choose>
  367. </xsl:if>
  368. <xsl:text>" "</xsl:text>
  369. <xsl:if test="$man.th.extra3.suppress = 0">
  370. <xsl:choose>
  371. <!-- * if max.length is non-empty, use value to truncate field -->
  372. <xsl:when test="$man.th.extra3.max.length != ''">
  373. <xsl:value-of
  374. select="normalize-space(substring($extra3, 1, $man.th.extra3.max.length))"/>
  375. </xsl:when>
  376. <xsl:otherwise>
  377. <xsl:value-of select="normalize-space($extra3)"/>
  378. </xsl:otherwise>
  379. </xsl:choose>
  380. </xsl:if>
  381. <xsl:text>"&#10;</xsl:text>
  382. <xsl:call-template name="mark.subheading"/>
  383. </xsl:template>
  384. <!-- ============================================================== -->
  385. <xsl:template name="set.default.formatting">
  386. <!-- * Set default hyphenation, justification, indentation and -->
  387. <!-- * line-breaking -->
  388. <!-- * -->
  389. <!-- * If the value of man.hypenate is zero (the default), then -->
  390. <!-- * disable hyphenation (".nh" = "no hyphenation") -->
  391. <xsl:text>.\" -----------------------------------------------------------------&#10;</xsl:text>
  392. <xsl:text>.\" * set default formatting&#10;</xsl:text>
  393. <xsl:text>.\" -----------------------------------------------------------------&#10;</xsl:text>
  394. <xsl:if test="$man.hyphenate = 0">
  395. <xsl:text>.\" disable hyphenation&#10;</xsl:text>
  396. <xsl:text>.nh&#10;</xsl:text>
  397. </xsl:if>
  398. <!-- * If the value of man.justify is zero (the default), then -->
  399. <!-- * disable justification (".ad l" means "adjust to left only") -->
  400. <xsl:if test="$man.justify = 0">
  401. <xsl:text>.\" disable justification</xsl:text>
  402. <xsl:text> (adjust text to left margin only)&#10;</xsl:text>
  403. <xsl:text>.ad l&#10;</xsl:text>
  404. </xsl:if>
  405. <xsl:if test="not($man.indent.refsect = 0)">
  406. <xsl:text>.\" store initial "default indentation value"&#10;</xsl:text>
  407. <xsl:text>.nr zq \n(IN&#10;</xsl:text>
  408. <xsl:text>.\" adjust default indentation&#10;</xsl:text>
  409. <xsl:text>.nr IN </xsl:text>
  410. <xsl:value-of select="$man.indent.width"/>
  411. <xsl:text>&#10;</xsl:text>
  412. <xsl:text>.\" adjust indentation of SS headings&#10;</xsl:text>
  413. <xsl:text>.nr SN \n(IN&#10;</xsl:text>
  414. </xsl:if>
  415. <!-- * Unless the value of man.break.after.slash is zero (the -->
  416. <!-- * default), tell groff that it is OK to break a line -->
  417. <!-- * after a slash when needed. -->
  418. <xsl:if test="$man.break.after.slash != 0">
  419. <xsl:text>.\" enable line breaks after slashes&#10;</xsl:text>
  420. <xsl:text>.cflags 4 /&#10;</xsl:text>
  421. </xsl:if>
  422. </xsl:template>
  423. <!-- ================================================================== -->
  424. <!-- * The prepare.manpage.contents template is called after all -->
  425. <!-- * other processing has been done, before serializing the -->
  426. <!-- * result of all the other processing. It basically works on -->
  427. <!-- * the result as one big string. -->
  428. <xsl:template name="prepare.manpage.contents">
  429. <xsl:param name="content" select="''"/>
  430. <!-- * If user has provided a "local" string-substitution map to -->
  431. <!-- * be applied /before/ the standard string-substitution map, -->
  432. <!-- * apply it. -->
  433. <xsl:variable name="pre.adjusted.content">
  434. <xsl:choose>
  435. <xsl:when test="$man.string.subst.map.local.pre">
  436. <!-- * normalized value of man.string.subst.map.local.pre -->
  437. <!-- * is non-empty, so get contents of map and apply them -->
  438. <xsl:call-template name="apply-string-subst-map">
  439. <xsl:with-param name="content" select="$content"/>
  440. <xsl:with-param name="map.contents"
  441. select="exsl:node-set($man.string.subst.map.local.pre)/*"/>
  442. </xsl:call-template>
  443. </xsl:when>
  444. <xsl:otherwise>
  445. <!-- * value of man.string.subst.map.local.pre is empty, -->
  446. <!-- * so just copy original contents -->
  447. <xsl:value-of select="$content"/>
  448. </xsl:otherwise>
  449. </xsl:choose>
  450. </xsl:variable>
  451. <!-- * Apply standard string-substitution map. The main purpose -->
  452. <!-- * of this map is to escape certain characters that have -->
  453. <!-- * special meaning in roff, and to replace certain characters -->
  454. <!-- * used within the stylesheet internally to represent roff -->
  455. <!-- * markup characters. -->
  456. <xsl:variable name="adjusted.content">
  457. <xsl:call-template name="apply-string-subst-map">
  458. <xsl:with-param name="content" select="$pre.adjusted.content"/>
  459. <xsl:with-param name="map.contents"
  460. select="exsl:node-set($man.string.subst.map)/*"/>
  461. </xsl:call-template>
  462. </xsl:variable>
  463. <!-- * If user has provided a "local" string-substitution map to -->
  464. <!-- * be applied /after/ the standard string-substitution map, -->
  465. <!-- * apply it. -->
  466. <xsl:variable name="post.adjusted.content">
  467. <xsl:choose>
  468. <xsl:when test="$man.string.subst.map.local.post">
  469. <!-- * normalized value of man.string.subst.map.local.post -->
  470. <!-- * is non-empty, so get contents of map and apply them -->
  471. <xsl:call-template name="apply-string-subst-map">
  472. <xsl:with-param name="content" select="$adjusted.content"/>
  473. <xsl:with-param name="map.contents"
  474. select="exsl:node-set($man.string.subst.map.local.post)/*"/>
  475. </xsl:call-template>
  476. </xsl:when>
  477. <xsl:otherwise>
  478. <!-- * value of man.string.subst.map.local.post is empty, -->
  479. <!-- * so just copy original contents -->
  480. <xsl:value-of select="$adjusted.content"/>
  481. </xsl:otherwise>
  482. </xsl:choose>
  483. </xsl:variable>
  484. <!-- * Optionally, apply a character map to replace Unicode -->
  485. <!-- * symbols and special characters. -->
  486. <xsl:choose>
  487. <xsl:when test="$man.charmap.enabled != 0">
  488. <xsl:call-template name="apply-character-map">
  489. <xsl:with-param name="content" select="$post.adjusted.content"/>
  490. <xsl:with-param name="map.contents"
  491. select="exsl:node-set($man.charmap.contents)/*"/>
  492. </xsl:call-template>
  493. </xsl:when>
  494. <xsl:otherwise>
  495. <!-- * if we reach here, value of $man.charmap.enabled is zero, -->
  496. <!-- * so we just pass the adjusted contents through "as is" -->
  497. <xsl:value-of select="$adjusted.content"/>
  498. </xsl:otherwise>
  499. </xsl:choose>
  500. </xsl:template>
  501. <!-- ================================================================== -->
  502. <xsl:template name="write.man.file">
  503. <xsl:param name="name"/>
  504. <xsl:param name="section"/>
  505. <xsl:param name="lang"/>
  506. <xsl:param name="content"/>
  507. <xsl:param name="filename">
  508. <xsl:call-template name="make.adjusted.man.filename">
  509. <xsl:with-param name="name" select="$name"/>
  510. <xsl:with-param name="section" select="$section"/>
  511. <xsl:with-param name="lang" select="$lang"/>
  512. </xsl:call-template>
  513. </xsl:param>
  514. <xsl:call-template name="write.text.chunk">
  515. <xsl:with-param name="filename" select="$filename"/>
  516. <xsl:with-param name="suppress-context-node-name" select="1"/>
  517. <xsl:with-param name="quiet" select="$man.output.quietly"/>
  518. <xsl:with-param
  519. name="message-prolog"
  520. >Note: </xsl:with-param>
  521. <xsl:with-param name="encoding" select="$man.output.encoding"/>
  522. <xsl:with-param name="content" select="$content"/>
  523. </xsl:call-template>
  524. </xsl:template>
  525. <!-- ============================================================== -->
  526. <!-- * A "stub" is sort of alias for another file, intended to be read -->
  527. <!-- * and expanded by soelim(1); it's simply a file whose complete -->
  528. <!-- * contents are just a single line of the following form: -->
  529. <!-- * -->
  530. <!-- * .so manX/realname.X -->
  531. <!-- * -->
  532. <!-- * "realname" is a name of another man-page file. That .so line is -->
  533. <!-- * basically a roff "include" statement. When the man command finds -->
  534. <!-- * it, it calls soelim(1) and includes and displays the contents of -->
  535. <!-- * the manX/realqname.X file. -->
  536. <!-- * -->
  537. <!-- * If a refentry has multiple refnames, we generate a "stub" page for -->
  538. <!-- * each refname found, except for the first one. -->
  539. <xsl:template name="write.stubs">
  540. <xsl:param name="first.refname"/>
  541. <xsl:param name="section"/>
  542. <xsl:param name="lang"/>
  543. <xsl:for-each select="refnamediv/refname">
  544. <xsl:if test=". != $first.refname">
  545. <xsl:call-template name="write.text.chunk">
  546. <xsl:with-param name="filename">
  547. <xsl:call-template name="make.adjusted.man.filename">
  548. <xsl:with-param name="name" select="."/>
  549. <xsl:with-param name="section" select="$section"/>
  550. <xsl:with-param name="lang" select="$lang"/>
  551. </xsl:call-template>
  552. </xsl:with-param>
  553. <xsl:with-param name="quiet" select="$man.output.quietly"/>
  554. <xsl:with-param name="suppress-context-node-name" select="1"/>
  555. <xsl:with-param name="message-prolog">Note: </xsl:with-param>
  556. <xsl:with-param name="message-epilog"> (soelim stub)</xsl:with-param>
  557. <xsl:with-param name="content">
  558. <xsl:value-of select="'.so '"/>
  559. <xsl:call-template name="make.adjusted.man.filename">
  560. <xsl:with-param name="name" select="$first.refname"/>
  561. <xsl:with-param name="section" select="$section"/>
  562. <xsl:with-param name="lang" select="$lang"/>
  563. </xsl:call-template>
  564. <xsl:text>&#10;</xsl:text>
  565. </xsl:with-param>
  566. </xsl:call-template>
  567. </xsl:if>
  568. </xsl:for-each>
  569. </xsl:template>
  570. <!-- ============================================================== -->
  571. <!-- * A manifest file is useful for doing "make clean" during -->
  572. <!-- * builds and for other purposes. When we make the manifest -->
  573. <!-- * file, we need to include in it a filename for each man-page -->
  574. <!-- * generated, including any "stub" pages. -->
  575. <xsl:template name="generate.manifest">
  576. <xsl:variable name="filelist">
  577. <xsl:for-each select="//refentry">
  578. <!-- * all refname instances in a Refentry inherit their section -->
  579. <!-- * numbers from the parent Refentry; so we only need to get -->
  580. <!-- * the section once per Refentry, not once per Refname -->
  581. <xsl:variable name="section">
  582. <xsl:call-template name="get.refentry.section">
  583. <xsl:with-param name="quiet" select="1"/>
  584. </xsl:call-template>
  585. </xsl:variable>
  586. <xsl:variable name="lang">
  587. <xsl:call-template name="l10n.language"/>
  588. </xsl:variable>
  589. <xsl:for-each select="refnamediv/refname">
  590. <xsl:call-template name="make.adjusted.man.filename">
  591. <xsl:with-param name="name" select="."/>
  592. <xsl:with-param name="section" select="$section"/>
  593. <xsl:with-param name="lang" select="$lang"/>
  594. </xsl:call-template>
  595. <xsl:text>&#10;</xsl:text>
  596. </xsl:for-each>
  597. </xsl:for-each>
  598. </xsl:variable>
  599. <!-- * we write the manifest file once per document, not once per -->
  600. <!-- * Refentry -->
  601. <xsl:call-template name="write.text.chunk">
  602. <xsl:with-param name="filename">
  603. <xsl:value-of select="$man.output.manifest.filename"/>
  604. </xsl:with-param>
  605. <xsl:with-param name="quiet" select="1"/>
  606. <xsl:with-param name="message-prolog">Note: </xsl:with-param>
  607. <xsl:with-param name="message-epilog"> (manifest file)</xsl:with-param>
  608. <xsl:with-param name="content">
  609. <xsl:value-of select="$filelist"/>
  610. </xsl:with-param>
  611. </xsl:call-template>
  612. <xsl:if test="$man.output.quietly = 0">
  613. <xsl:message><xsl:text>&#10;</xsl:text></xsl:message>
  614. </xsl:if>
  615. </xsl:template>
  616. <!-- ============================================================== -->
  617. <!-- There is some stuff, that is not portable between groff/troff. -->
  618. <xsl:template name="define.portability.macros">
  619. <xsl:text>.\" -----------------------------------------------------------------&#10;</xsl:text>
  620. <xsl:text>.\" * Define some portability stuff&#10;</xsl:text>
  621. <xsl:text>.\" -----------------------------------------------------------------&#10;</xsl:text>
  622. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  623. <xsl:text>.\" http://bugs.debian.org/507673&#10;</xsl:text>
  624. <xsl:text>.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html&#10;</xsl:text>
  625. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  626. <xsl:text>&#10;</xsl:text>
  627. <xsl:text>.ie \n(.g .ds Aq \(aq</xsl:text>
  628. <xsl:text>&#10;</xsl:text>
  629. <xsl:text>.el .ds Aq '</xsl:text>
  630. <xsl:text>&#10;</xsl:text>
  631. </xsl:template>
  632. <!-- ============================================================== -->
  633. <xsl:template name="define.macros">
  634. <xsl:text>.\" -----------------------------------------------------------------&#10;</xsl:text>
  635. <xsl:text>.\" * (re)Define some macros&#10;</xsl:text>
  636. <xsl:text>.\" -----------------------------------------------------------------&#10;</xsl:text>
  637. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  638. <xsl:text>.\" toupper - uppercase a string (locale-aware)&#10;</xsl:text>
  639. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  640. <xsl:text>.de toupper&#10;</xsl:text>
  641. <xsl:text>.tr</xsl:text>
  642. <xsl:text> </xsl:text>
  643. <xsl:call-template name="make.tr.uppercase.arg"/>
  644. <xsl:text>\\$*&#10;</xsl:text>
  645. <xsl:text>.tr</xsl:text>
  646. <xsl:text> </xsl:text>
  647. <xsl:call-template name="make.tr.normalcase.arg"/>
  648. <xsl:text>..&#10;</xsl:text>
  649. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  650. <xsl:text>.\" SH-xref - format a cross-reference to an SH section&#10;</xsl:text>
  651. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  652. <xsl:text>.de SH-xref
  653. .ie n \{\
  654. .\}
  655. .toupper \\$*
  656. .el \{\
  657. \\$*
  658. .\}
  659. ..&#10;</xsl:text>
  660. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  661. <xsl:text>.\" SH - level-one heading that works better for non-TTY output&#10;</xsl:text>
  662. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  663. <xsl:text>.de1 SH&#10;</xsl:text>
  664. <xsl:text>.\" put an extra blank line of space above the head in non-TTY output&#10;</xsl:text>
  665. <xsl:call-template name="roff-if-start">
  666. <xsl:with-param name="condition">t</xsl:with-param>
  667. </xsl:call-template>
  668. <xsl:text>.sp 1&#10;</xsl:text>
  669. <xsl:call-template name="roff-if-end"/>
  670. <xsl:text>.sp \\n[PD]u
  671. .nr an-level 1
  672. .set-an-margin
  673. .nr an-prevailing-indent \\n[IN]
  674. .fi
  675. .in \\n[an-margin]u
  676. .ti 0
  677. .HTML-TAG ".NH \\n[an-level]"
  678. .it 1 an-trap
  679. .nr an-no-space-flag 1
  680. .nr an-break-flag 1
  681. \." make the size of the head bigger
  682. .ps +3
  683. .ft B
  684. .ne (2v + 1u)
  685. .ie n \{\
  686. .\" if n (TTY output), use uppercase
  687. .toupper \\$*
  688. .\}
  689. .el \{\
  690. .nr an-break-flag 0
  691. .\" if not n (not TTY), use normal case (not uppercase)
  692. \\$1
  693. .in \\n[an-margin]u
  694. .ti 0
  695. .\" if not n (not TTY), put a border/line under subheading
  696. .sp -.6
  697. \l'\n(.lu'
  698. .\}
  699. ..&#10;</xsl:text>
  700. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  701. <xsl:text>.\" SS - level-two heading that works better for non-TTY output&#10;</xsl:text>
  702. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  703. <xsl:text>.de1 SS
  704. .sp \\n[PD]u
  705. .nr an-level 1
  706. .set-an-margin
  707. .nr an-prevailing-indent \\n[IN]
  708. .fi
  709. .in \\n[IN]u
  710. .ti \\n[SN]u
  711. .it 1 an-trap
  712. .nr an-no-space-flag 1
  713. .nr an-break-flag 1
  714. .ps \\n[PS-SS]u
  715. \." make the size of the head bigger
  716. .ps +2
  717. .ft B
  718. .ne (2v + 1u)
  719. .if \\n[.$] \&amp;\\$*
  720. ..&#10;</xsl:text>
  721. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  722. <xsl:text>.\" BB/EB - put background/screen (filled box) around block of text&#10;</xsl:text>
  723. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  724. <xsl:text>.de BB
  725. .if t \{\
  726. .sp -.5
  727. .br
  728. .in +2n
  729. .ll -2n
  730. .gcolor red
  731. .di BX
  732. .\}
  733. ..
  734. .de EB
  735. .if t \{\
  736. .if "\\$2"adjust-for-leading-newline" \{\
  737. .sp -1
  738. .\}
  739. .br
  740. .di
  741. .in
  742. .ll
  743. .gcolor
  744. .nr BW \\n(.lu-\\n(.i
  745. .nr BH \\n(dn+.5v
  746. .ne \\n(BHu+.5v
  747. .ie "\\$2"adjust-for-leading-newline" \{\
  748. \M[\\$1]\h'1n'\v'+.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[]
  749. .\}
  750. .el \{\
  751. \M[\\$1]\h'1n'\v'-.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[]
  752. .\}
  753. .in 0
  754. .sp -.5v
  755. .nf
  756. .BX
  757. .in
  758. .sp .5v
  759. .fi
  760. .\}
  761. ..&#10;</xsl:text>
  762. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  763. <xsl:text>.\" BM/EM - put colored marker in margin next to block of text&#10;</xsl:text>
  764. <xsl:text>.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#10;</xsl:text>
  765. <xsl:text>.de BM
  766. .if t \{\
  767. .br
  768. .ll -2n
  769. .gcolor red
  770. .di BX
  771. .\}
  772. ..
  773. .de EM
  774. .if t \{\
  775. .br
  776. .di
  777. .ll
  778. .gcolor
  779. .nr BH \\n(dn
  780. .ne \\n(BHu
  781. \M[\\$1]\D'P -.75n 0 0 \\n(BHu -(\\n[.i]u - \\n(INu - .75n) 0 0 -\\n(BHu'\M[]
  782. .in 0
  783. .nf
  784. .BX
  785. .in
  786. .fi
  787. .\}
  788. ..&#10;</xsl:text>
  789. </xsl:template>
  790. <xsl:template name="make.tr.uppercase.arg">
  791. <xsl:call-template name="string.shuffle">
  792. <xsl:with-param name="string1">
  793. <xsl:call-template name="gentext">
  794. <xsl:with-param name="key" select="'lowercase.alpha'"/>
  795. </xsl:call-template>
  796. </xsl:with-param>
  797. <xsl:with-param name="string2">
  798. <xsl:call-template name="gentext">
  799. <xsl:with-param name="key" select="'uppercase.alpha'"/>
  800. </xsl:call-template>
  801. </xsl:with-param>
  802. </xsl:call-template>
  803. <xsl:text>&#10;</xsl:text>
  804. </xsl:template>
  805. <xsl:template name="make.tr.normalcase.arg">
  806. <xsl:call-template name="string.shuffle">
  807. <xsl:with-param name="string1">
  808. <xsl:call-template name="gentext">
  809. <xsl:with-param name="key" select="'lowercase.alpha'"/>
  810. </xsl:call-template>
  811. </xsl:with-param>
  812. <xsl:with-param name="string2">
  813. <xsl:call-template name="gentext">
  814. <xsl:with-param name="key" select="'lowercase.alpha'"/>
  815. </xsl:call-template>
  816. </xsl:with-param>
  817. </xsl:call-template>
  818. <xsl:text>&#10;</xsl:text>
  819. </xsl:template>
  820. <xsl:template name="string.shuffle">
  821. <!-- * given two strings, "shuffle" them together into one -->
  822. <xsl:param name="string1"/>
  823. <xsl:param name="string2"/>
  824. <xsl:value-of select="substring($string1, 1, 1)"/>
  825. <xsl:value-of select="substring($string2, 1, 1)"/>
  826. <xsl:if test="string-length($string1) > 1">
  827. <xsl:call-template name="string.shuffle">
  828. <xsl:with-param name="string1">
  829. <xsl:value-of select="substring($string1, 2)"/>
  830. </xsl:with-param>
  831. <xsl:with-param name="string2">
  832. <xsl:value-of select="substring($string2, 2)"/>
  833. </xsl:with-param>
  834. </xsl:call-template>
  835. </xsl:if>
  836. </xsl:template>
  837. </xsl:stylesheet>