1
0

info.xsl 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:date="http://exslt.org/dates-and-times"
  4. xmlns:exsl="http://exslt.org/common"
  5. exclude-result-prefixes="date exsl"
  6. version='1.0'>
  7. <!-- ********************************************************************
  8. $Id: info.xsl 7883 2008-03-08 17:59:39Z 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. <xsl:variable name="blurb-indent">
  15. <xsl:choose>
  16. <xsl:when test="not($man.indent.blurbs = 0)">
  17. <xsl:value-of select="$man.indent.width"/>
  18. </xsl:when>
  19. <xsl:when test="not($man.indent.refsect = 0)">
  20. <!-- * "zq" is the name of a register we set for -->
  21. <!-- * preserving the original default indent value -->
  22. <!-- * when $man.indent.refsect is non-zero; -->
  23. <!-- * "u" is a roff unit specifier -->
  24. <xsl:text>\n(zqu</xsl:text>
  25. </xsl:when>
  26. <xsl:otherwise/> <!-- * otherwise, just leave it empty -->
  27. </xsl:choose>
  28. </xsl:variable>
  29. <!-- ================================================================== -->
  30. <!-- * About the $info param used in this stylesheet -->
  31. <!-- * -->
  32. <!-- * The $info param is a "master info" node set that contains -->
  33. <!-- * the entire contents of the *info child of the current -->
  34. <!-- * Refentry, plus the entire contents of the *info children of -->
  35. <!-- * all ancestors of the current Refentry, in document order. -->
  36. <!-- * -->
  37. <!-- * We try to find a "best match" for selecting content from -->
  38. <!-- * $infor; we look through it in reverse document order until we -->
  39. <!-- * can find something usable. -->
  40. <!-- * -->
  41. <!-- * Specifically what the basic metadata-gathering XPath expression -->
  42. <!-- * in this stylesheet does is: -->
  43. <!-- * -->
  44. <!-- * 1. Look through the entire "master info" node set.-->
  45. <!-- * 2. Get the last node in the set that contains, for -->
  46. <!-- * example, an Author element. That amounts to being the -->
  47. <!-- * closest *info node to the Refentry - either its *info -->
  48. <!-- * child, or the *info node of its closest ancestor that -->
  49. <!-- * contains an Author. -->
  50. <!-- ================================================================== -->
  51. <!-- * Get user "refentry metadata" preferences -->
  52. <!-- ================================================================== -->
  53. <!-- * The DocBook XSL stylesheets include several user-configurable -->
  54. <!-- * global stylesheet parameters for controlling refentry metadata -->
  55. <!-- * gathering. Those parameters are not read directly by the other -->
  56. <!-- * refentry metadata-gathering templates. Instead, they are read -->
  57. <!-- * only by the get.refentry.metadata.prefs template, which -->
  58. <!-- * assembles them into a structure that is then passed to the -->
  59. <!-- * other refentry metadata-gathering template. -->
  60. <xsl:variable name="get.refentry.metadata.prefs">
  61. <!-- * get.refentry.metadata.prefs is in common/refentry.xsl -->
  62. <xsl:call-template name="get.refentry.metadata.prefs"/>
  63. </xsl:variable>
  64. <xsl:variable name="refentry.metadata.prefs"
  65. select="exsl:node-set($get.refentry.metadata.prefs)"/>
  66. <!-- * ============================================================== -->
  67. <!-- * Get content for Author metadata field. -->
  68. <!-- * ============================================================== -->
  69. <!-- * The make.roff.metatada.author template and metadata.author -->
  70. <!-- * mode are used only for populating the Author field in the -->
  71. <!-- * metadata "top comment" we embed in roff source of each page. -->
  72. <xsl:template name="make.roff.metadata.author">
  73. <xsl:param name="info"/>
  74. <xsl:param name="refname"/>
  75. <xsl:choose>
  76. <xsl:when test="$info//author">
  77. <xsl:apply-templates
  78. select="(($info[//author])[last()]//author)[1]"
  79. mode="metadata.author"/>
  80. </xsl:when>
  81. <xsl:when test="$info//corpauthor">
  82. <xsl:apply-templates
  83. select="(($info[//corpauthor])[last()]//corpauthor)[1]"
  84. mode="metadata.author"/>
  85. </xsl:when>
  86. <xsl:when test="$info//editor">
  87. <xsl:apply-templates
  88. select="(($info[//editor])[last()]//editor)[1]"
  89. mode="metadata.author"/>
  90. </xsl:when>
  91. <xsl:when test="$info//corpcredit">
  92. <xsl:apply-templates
  93. select="(($info[//corpcredit])[last()]//corpcredit)[1]"
  94. mode="metadata.author"/>
  95. </xsl:when>
  96. <xsl:when test="$info//othercredit">
  97. <xsl:apply-templates
  98. select="(($info[//othercredit])[last()]//othercredit)[1]"
  99. mode="metadata.author"/>
  100. </xsl:when>
  101. <xsl:when test="$info//collab">
  102. <xsl:apply-templates
  103. select="(($info[//collab])[last()]//collab)[1]"
  104. mode="metadata.author"/>
  105. </xsl:when>
  106. <xsl:when test="$info//orgname">
  107. <xsl:apply-templates
  108. select="(($info[//orgname])[last()]//orgname)[1]"
  109. mode="metadata.author"/>
  110. </xsl:when>
  111. <xsl:when test="$info//publishername">
  112. <xsl:apply-templates
  113. select="(($info[//publishername])[last()]//publishername)[1]"
  114. mode="metadata.author"/>
  115. </xsl:when>
  116. <xsl:otherwise>
  117. <!-- * otherwise, we need to check to see if we have an "Author" -->
  118. <!-- * or "Authors" section in the refentry -->
  119. <xsl:variable name="gentext.author">
  120. <xsl:text>"</xsl:text>
  121. <xsl:call-template name="gentext">
  122. <xsl:with-param name="key" select="'Author'"/>
  123. </xsl:call-template>
  124. <xsl:text>"</xsl:text>
  125. </xsl:variable>
  126. <xsl:variable name="gentext.AUTHOR">
  127. <xsl:if test="not($gentext.author = '')">
  128. <xsl:call-template name="string.upper">
  129. <xsl:with-param name="string" select="$gentext.author"/>
  130. </xsl:call-template>
  131. </xsl:if>
  132. </xsl:variable>
  133. <xsl:variable name="gentext.authors">
  134. <xsl:text>"</xsl:text>
  135. <xsl:call-template name="gentext">
  136. <xsl:with-param name="key" select="'Authors'"/>
  137. </xsl:call-template>
  138. <xsl:text>"</xsl:text>
  139. </xsl:variable>
  140. <xsl:variable name="gentext.AUTHORS">
  141. <xsl:if test="not($gentext.authors = '')">
  142. <xsl:call-template name="string.upper">
  143. <xsl:with-param name="string" select="$gentext.authors"/>
  144. </xsl:call-template>
  145. </xsl:if>
  146. </xsl:variable>
  147. <!-- * get all refentry/refsect1/title & refentry/refsection/title -->
  148. <!-- * instances, delimit each with double quotes, and put them -->
  149. <!-- * into a single refsect1.titles string -->
  150. <xsl:variable name="refsect1.titles">
  151. <xsl:for-each select="refsect1/title">
  152. <xsl:text>"</xsl:text>
  153. <xsl:value-of select="normalize-space(.)"/>
  154. <xsl:text>"</xsl:text>
  155. <xsl:text> </xsl:text>
  156. </xsl:for-each>
  157. <xsl:for-each select="refsection/title">
  158. <xsl:text>"</xsl:text>
  159. <xsl:value-of select="normalize-space(.)"/>
  160. <xsl:text>"</xsl:text>
  161. <xsl:text> </xsl:text>
  162. </xsl:for-each>
  163. </xsl:variable>
  164. <xsl:variable name="author.section.title">
  165. <xsl:choose>
  166. <xsl:when test="not($gentext.authors = '') and
  167. contains($refsect1.titles,$gentext.authors)">
  168. <xsl:value-of select="$gentext.authors"/>
  169. </xsl:when>
  170. <xsl:when test="not($gentext.AUTHORS = '') and
  171. contains($refsect1.titles,$gentext.AUTHORS)">
  172. <xsl:value-of select="$gentext.AUTHORS"/>
  173. </xsl:when>
  174. <xsl:when test="not($gentext.author = '') and
  175. contains($refsect1.titles,$gentext.author)">
  176. <xsl:value-of select="$gentext.author"/>
  177. </xsl:when>
  178. <xsl:when test="not($gentext.AUTHOR = '') and
  179. contains($refsect1.titles,$gentext.AUTHOR)">
  180. <xsl:value-of select="$gentext.AUTHOR"/>
  181. </xsl:when>
  182. <!-- * git docs (for one) use "DOCUMENTATION" for their authors section -->
  183. <xsl:when test="contains($refsect1.titles,'Documentation')">
  184. <xsl:text>Documentation</xsl:text>
  185. </xsl:when>
  186. <xsl:when test="contains($refsect1.titles,'DOCUMENTATION')">
  187. <xsl:text>DOCUMENTATION</xsl:text>
  188. </xsl:when>
  189. <xsl:otherwise/> <!-- * otherwise, leave empty -->
  190. </xsl:choose>
  191. </xsl:variable>
  192. <xsl:choose>
  193. <xsl:when test="not($author.section.title = '')">
  194. <!-- * if we have a non-empty $author.section.title value, -->
  195. <!-- * then reference that title (instead of putting a -->
  196. <!-- * specific author name) -->
  197. <xsl:text>[see the </xsl:text>
  198. <xsl:value-of select="$author.section.title"/>
  199. <xsl:text> section]</xsl:text>
  200. </xsl:when>
  201. <xsl:otherwise>
  202. <!-- * otherwise we have no info/author content and no Author -->
  203. <!-- * or Authors section, so we insert a fixme and report -->
  204. <!-- * the problem to the user -->
  205. <xsl:text>[FIXME: author] [see http://docbook.sf.net/el/author]</xsl:text>
  206. <xsl:if test="$refentry.meta.get.quietly = 0">
  207. <xsl:call-template name="log.message">
  208. <xsl:with-param name="level">Warn</xsl:with-param>
  209. <xsl:with-param name="source" select="$refname"/>
  210. <xsl:with-param name="context-desc">meta author</xsl:with-param>
  211. <xsl:with-param name="message">
  212. <xsl:text>no refentry/info/author</xsl:text>
  213. </xsl:with-param>
  214. </xsl:call-template>
  215. <xsl:call-template name="log.message">
  216. <xsl:with-param name="level">Note</xsl:with-param>
  217. <xsl:with-param name="source" select="$refname"/>
  218. <xsl:with-param name="context-desc">meta author</xsl:with-param>
  219. <xsl:with-param name="message">
  220. <xsl:text>see http://docbook.sf.net/el/author</xsl:text>
  221. </xsl:with-param>
  222. </xsl:call-template>
  223. <xsl:call-template name="log.message">
  224. <xsl:with-param name="level">Warn</xsl:with-param>
  225. <xsl:with-param name="source" select="$refname"/>
  226. <xsl:with-param name="context-desc">meta author</xsl:with-param>
  227. <xsl:with-param name="message">
  228. <xsl:text>no author data, so inserted a fixme</xsl:text>
  229. </xsl:with-param>
  230. </xsl:call-template>
  231. </xsl:if>
  232. </xsl:otherwise>
  233. </xsl:choose>
  234. </xsl:otherwise>
  235. </xsl:choose>
  236. </xsl:template>
  237. <xsl:template match="author|editor|othercredit|collab" mode="metadata.author">
  238. <xsl:choose>
  239. <xsl:when test="collabname">
  240. <!-- * If this node is a Collab, then it should have a -->
  241. <!-- * Collabname child, so get that. -->
  242. <xsl:variable name="contents">
  243. <xsl:apply-templates select="collabname"/>
  244. </xsl:variable>
  245. <xsl:value-of select="normalize-space($contents)"/>
  246. </xsl:when>
  247. <xsl:otherwise>
  248. <!-- * Otherwise, this node is not a Collab, but instead -->
  249. <!-- * an author|editor|othercredit, which must have a name -->
  250. <!-- * of some kind; so get that name -->
  251. <xsl:call-template name="person.name.normalized"/>
  252. </xsl:otherwise>
  253. </xsl:choose>
  254. <xsl:if test=".//email|address/otheraddr/ulink">
  255. <xsl:text> </xsl:text>
  256. <!-- * For each attribution found, use only the first e-mail -->
  257. <!-- * address or ulink value found -->
  258. <xsl:apply-templates select="(.//email|address/otheraddr/ulink)[1]"
  259. mode="metadata.author"/>
  260. </xsl:if>
  261. </xsl:template>
  262. <xsl:template match="email|address/otheraddr/ulink" mode="metadata.author">
  263. <xsl:text>&lt;</xsl:text>
  264. <xsl:choose>
  265. <xsl:when test="self::email">
  266. <xsl:variable name="contents">
  267. <xsl:apply-templates/>
  268. </xsl:variable>
  269. <xsl:value-of select="normalize-space($contents)"/>
  270. </xsl:when>
  271. <xsl:when test="self::ulink">
  272. <xsl:variable name="contents">
  273. <xsl:apply-templates select="."/>
  274. </xsl:variable>
  275. <xsl:value-of select="normalize-space($contents)"/>
  276. </xsl:when>
  277. </xsl:choose>
  278. <xsl:text>&gt;</xsl:text>
  279. </xsl:template>
  280. <xsl:template match="corpauthor|corpcredit|orgname|publishername" mode="metadata.author">
  281. <xsl:variable name="contents">
  282. <xsl:apply-templates/>
  283. </xsl:variable>
  284. <xsl:value-of select="normalize-space($contents)"/>
  285. </xsl:template>
  286. <!-- * ============================================================== -->
  287. <!-- * Assemble the AUTHOR/AUTHORS section -->
  288. <!-- * ============================================================== -->
  289. <xsl:template name="author.section">
  290. <xsl:param name="info"/>
  291. <!-- * The $info param is a "master info" node set that contains -->
  292. <!-- * the entires contents of the *info child of the current -->
  293. <!-- * Refentry, plus the entire contents of the *info children of -->
  294. <!-- * all ancestors of the current Refentry, in document order. -->
  295. <xsl:choose>
  296. <xsl:when test="$info//author|$info//editor|$info//collab|
  297. $info//corpauthor|$info//corpcredit|
  298. $info//othercredit|$info/orgname|
  299. $info/publishername|$info/publisher">
  300. <xsl:variable name="authorcount">
  301. <xsl:value-of
  302. select="count(
  303. $info//author|$info//editor|$info//collab|
  304. $info//corpauthor|$info//corpcredit|
  305. $info//othercredit)">
  306. </xsl:value-of>
  307. </xsl:variable>
  308. <xsl:call-template name="make.subheading">
  309. <xsl:with-param name="title">
  310. <xsl:call-template name="make.authorsecttitle">
  311. <xsl:with-param name="authorcount" select="$authorcount"/>
  312. </xsl:call-template>
  313. </xsl:with-param>
  314. </xsl:call-template>
  315. <!-- * Now output all the actual author, editor, etc. content -->
  316. <xsl:for-each
  317. select="$info//author|$info//editor|$info//collab|
  318. $info//corpauthor|$info//corpcredit|
  319. $info//othercredit|$info/orgname|
  320. $info/publishername|$info/publisher">
  321. <xsl:apply-templates select="." mode="authorsect"/>
  322. </xsl:for-each>
  323. </xsl:when>
  324. <xsl:otherwise/> <!-- * do nothing, no author info found -->
  325. </xsl:choose>
  326. </xsl:template>
  327. <xsl:template name="make.authorsecttitle">
  328. <!-- * If we have exactly one attributable person/entity, then output -->
  329. <!-- * localized gentext for 'Author'; otherwise, output 'Authors'. -->
  330. <xsl:param name="authorcount"/>
  331. <xsl:param name="authorsecttitle">
  332. <xsl:choose>
  333. <xsl:when test="$authorcount = 1">
  334. <xsl:text>Author</xsl:text>
  335. </xsl:when>
  336. <xsl:otherwise>
  337. <xsl:text>Authors</xsl:text>
  338. </xsl:otherwise>
  339. </xsl:choose>
  340. </xsl:param>
  341. <xsl:call-template name="gentext">
  342. <xsl:with-param name="key" select="$authorsecttitle"/>
  343. </xsl:call-template>
  344. </xsl:template>
  345. <xsl:template match="author|editor|othercredit" mode="authorsect">
  346. <xsl:variable name="person-name">
  347. <xsl:call-template name="person.name.normalized"/>
  348. </xsl:variable>
  349. <!-- * If we have a person-name or email or ulink content, then -->
  350. <!-- * output name and email or ulink content on the same line -->
  351. <xsl:choose>
  352. <xsl:when test="not($person-name = '') or .//email or address/otheraddr/ulink">
  353. <xsl:text>.PP&#10;</xsl:text>
  354. <!-- * Display person name in bold -->
  355. <xsl:call-template name="bold">
  356. <xsl:with-param name="node" select="exsl:node-set($person-name)"/>
  357. <xsl:with-param name="context" select="."/>
  358. </xsl:call-template>
  359. <!-- * Display e-mail address(es) and ulink(s) on same line as name -->
  360. <xsl:apply-templates select=".//email|address/otheraddr/ulink" mode="authorsect"/>
  361. <xsl:text>&#10;</xsl:text>
  362. </xsl:when>
  363. <xsl:otherwise>
  364. <xsl:text>.br&#10;</xsl:text>
  365. </xsl:otherwise>
  366. </xsl:choose>
  367. <!-- * Display affiliation(s) on separate lines -->
  368. <xsl:apply-templates select="affiliation" mode="authorsect"/>
  369. <!-- * Display direct-child addresses on separate lines -->
  370. <xsl:apply-templates select="address" mode="authorsect"/>
  371. <!-- * Call template for handling various attribution possibilities -->
  372. <xsl:call-template name="attribution">
  373. <xsl:with-param name="person-name" select="$person-name"/>
  374. </xsl:call-template>
  375. </xsl:template>
  376. <xsl:template match="collab" mode="authorsect">
  377. <xsl:text>.PP&#10;</xsl:text>
  378. <xsl:call-template name="bold">
  379. <xsl:with-param name="node" select="collabname"/>
  380. <xsl:with-param name="context" select="."/>
  381. </xsl:call-template>
  382. <!-- * Display e-mail address(es) and ulink(s) on same line as name -->
  383. <xsl:apply-templates select=".//email|address/otheraddr/ulink" mode="authorsect"/>
  384. <xsl:text>&#10;</xsl:text>
  385. <!-- * Display affilition(s) on separate lines -->
  386. <xsl:apply-templates select="affiliation" mode="authorsect"/>
  387. </xsl:template>
  388. <xsl:template match="corpauthor|corpcredit|orgname|publishername" mode="authorsect">
  389. <xsl:text>.PP&#10;</xsl:text>
  390. <xsl:call-template name="bold">
  391. <xsl:with-param name="node" select="."/>
  392. <xsl:with-param name="context" select="."/>
  393. </xsl:call-template>
  394. <xsl:text>&#10;</xsl:text>
  395. <xsl:if test="self::publishername">
  396. <!-- * Display localized "Publisher" gentext -->
  397. <xsl:call-template name="publisher.attribution"/>
  398. </xsl:if>
  399. </xsl:template>
  400. <xsl:template match="publisher" mode="authorsect">
  401. <xsl:text>.PP&#10;</xsl:text>
  402. <xsl:call-template name="bold">
  403. <xsl:with-param name="node" select="publishername"/>
  404. <xsl:with-param name="context" select="."/>
  405. </xsl:call-template>
  406. <!-- * Display e-mail address(es) and ulink(s) on same line as name -->
  407. <xsl:apply-templates select=".//email|address/otheraddr/ulink" mode="authorsect"/>
  408. <!-- * Display addresses on separate lines -->
  409. <xsl:apply-templates select="address" mode="authorsect"/>
  410. <!-- * Display localized "Publisher" literal -->
  411. <xsl:call-template name="publisher.attribution"/>
  412. </xsl:template>
  413. <xsl:template name="publisher.attribution">
  414. <xsl:text>&#10;</xsl:text>
  415. <xsl:text>.RS</xsl:text>
  416. <xsl:if test="not($blurb-indent = '')">
  417. <xsl:text> </xsl:text>
  418. <xsl:value-of select="$blurb-indent"/>
  419. </xsl:if>
  420. <xsl:text>&#10;</xsl:text>
  421. <xsl:call-template name="gentext">
  422. <xsl:with-param name="key" select="'Publisher'"/>
  423. </xsl:call-template>
  424. <xsl:text>.&#10;</xsl:text>
  425. <xsl:text>.RE&#10;</xsl:text>
  426. </xsl:template>
  427. <xsl:template match="email|address/otheraddr/ulink" mode="authorsect">
  428. <xsl:choose>
  429. <xsl:when test="preceding-sibling::*[descendant-or-self::email]
  430. or preceding-sibling::address/otheraddr/ulink
  431. or ancestor::address[preceding-sibling::*[descendant-or-self::email]]
  432. or ancestor::address[preceding-sibling::address/otheraddr/ulink]">
  433. <!-- * This is not the first instance, so do nothing. -->
  434. </xsl:when>
  435. <xsl:otherwise>
  436. <!-- * This is first instances of an e-mail address or ulink, -->
  437. <!-- * so put a space before it. -->
  438. <xsl:text> </xsl:text>
  439. </xsl:otherwise>
  440. </xsl:choose>
  441. <!-- * Note that the reason for the \& character after the opening -->
  442. <!-- * angle bracket and before the closing angle bracket is to -->
  443. <!-- * prevent groff from inserting a linebreak at those points and -->
  444. <!-- * outputting a hyphen character where the break occurs -->
  445. <xsl:text>&lt;\&amp;</xsl:text>
  446. <xsl:choose>
  447. <xsl:when test="self::email">
  448. <xsl:variable name="contents">
  449. <xsl:apply-templates/>
  450. </xsl:variable>
  451. <xsl:value-of select="normalize-space($contents)"/>
  452. </xsl:when>
  453. <xsl:when test="self::ulink">
  454. <xsl:variable name="contents">
  455. <xsl:apply-templates select="."/>
  456. </xsl:variable>
  457. <xsl:value-of select="normalize-space($contents)"/>
  458. </xsl:when>
  459. </xsl:choose>
  460. <xsl:text>\&amp;&gt;</xsl:text>
  461. <xsl:choose>
  462. <xsl:when test="not(following-sibling::*[descendant-or-self::email]
  463. or following-sibling::address/otheraddr/ulink
  464. or ancestor::address[following-sibling::*[descendant-or-self::email]]
  465. or ancestor::address[following-sibling::address/otheraddr/ulink])">
  466. <!-- * This is the final instance, so do nothing. -->
  467. </xsl:when>
  468. <xsl:otherwise>
  469. <!-- * Separate multiple e-mail addresses or ulinks with a comma -->
  470. <xsl:text>, </xsl:text>
  471. </xsl:otherwise>
  472. </xsl:choose>
  473. </xsl:template>
  474. <xsl:template match="affiliation" mode="authorsect">
  475. <!-- * Get the string value of the contents of this Affiliation. If the -->
  476. <!-- * affiliation only contains an Address child whose only content is -->
  477. <!-- * an email address or ulink, then these contents will end up empty. -->
  478. <xsl:variable name="contents">
  479. <xsl:apply-templates mode="authorsect"/>
  480. </xsl:variable>
  481. <!-- * If contents are actually empty except for an email address -->
  482. <!-- * or ulink, then output nothing. -->
  483. <xsl:if test="$contents != ''">
  484. <xsl:text>.br&#10;</xsl:text>
  485. <xsl:for-each select="shortaffil|jobtitle|orgname|orgdiv|address">
  486. <!-- * only display output of nodes other than email or ulink -->
  487. <xsl:apply-templates select="node()[not(self::email) and not(self::otheraddr/ulink)]"/>
  488. <xsl:choose>
  489. <xsl:when test="position() = last()"/> <!-- do nothing -->
  490. <xsl:otherwise>
  491. <!-- * only add comma if the node has a child node other than -->
  492. <!-- * an email address or ulink -->
  493. <xsl:if test="child::node()[not(self::email) and not(self::otheraddr/ulink)]">
  494. <xsl:text>, </xsl:text>
  495. </xsl:if>
  496. </xsl:otherwise>
  497. </xsl:choose>
  498. </xsl:for-each>
  499. <xsl:text>&#10;</xsl:text>
  500. <xsl:choose>
  501. <xsl:when test="position() = last()"/> <!-- do nothing -->
  502. <xsl:otherwise>
  503. <!-- * put a line break after every Affiliation instance except -->
  504. <!-- * the last one in the set -->
  505. <xsl:text>.br&#10;</xsl:text>
  506. </xsl:otherwise>
  507. </xsl:choose>
  508. </xsl:if>
  509. </xsl:template>
  510. <xsl:template match="address" mode="authorsect">
  511. <xsl:variable name="contents"
  512. select="normalize-space(node()[not(self::email)
  513. and not(self::otheraddr/ulink)])"/>
  514. <!-- * If this contents of this Address do not contain anything except -->
  515. <!-- * an email address or ulink, then output nothing. -->
  516. <xsl:if test="$contents != ''">
  517. <xsl:text>&#10;</xsl:text>
  518. <xsl:text>.br&#10;</xsl:text>
  519. <!--* Skip email and ulink descendants of Address (rendered elsewhere) -->
  520. <xsl:apply-templates select="node()[not(self::email) and not(self::otheraddr/ulink)]"/>
  521. </xsl:if>
  522. </xsl:template>
  523. <xsl:template name="attribution">
  524. <xsl:param name="person-name"/>
  525. <xsl:param name="refname" select="ancestor::refentry/refnamediv[1]/refname[1]"/>
  526. <!-- * Determine appropriate attribution for a particular person's role. -->
  527. <xsl:choose>
  528. <!-- * if we have a *blurb or contrib, just use that -->
  529. <xsl:when test="contrib|personblurb|authorblurb">
  530. <xsl:apply-templates select="contrib|personblurb|authorblurb" mode="authorsect"/>
  531. <xsl:text>&#10;</xsl:text>
  532. </xsl:when>
  533. <xsl:otherwise>
  534. <!-- * otherwise we have no attribution information to use... -->
  535. <xsl:if test="not($person-name = '')">
  536. <!-- * if we have a person name or organization name -->
  537. <!-- * ($person-name can actually be an orgname, not just a -->
  538. <!-- * person name), then report to the user that we are -->
  539. <!-- * lacking attribution information for that person -->
  540. <xsl:if test="$refentry.meta.get.quietly = 0">
  541. <xsl:call-template name="log.message">
  542. <xsl:with-param name="level">Warn</xsl:with-param>
  543. <xsl:with-param name="source" select="$refname"/>
  544. <xsl:with-param name="context-desc">AUTHOR sect.</xsl:with-param>
  545. <xsl:with-param name="message">
  546. <xsl:text>no personblurb|contrib for </xsl:text>
  547. <xsl:value-of select="$person-name"/>
  548. </xsl:with-param>
  549. </xsl:call-template>
  550. <xsl:call-template name="log.message">
  551. <xsl:with-param name="level">Note</xsl:with-param>
  552. <xsl:with-param name="source" select="$refname"/>
  553. <xsl:with-param name="context-desc">AUTHOR sect.</xsl:with-param>
  554. <xsl:with-param name="message">
  555. <xsl:text>see see http://docbook.sf.net/el/contrib</xsl:text>
  556. </xsl:with-param>
  557. </xsl:call-template>
  558. <xsl:call-template name="log.message">
  559. <xsl:with-param name="level">Note</xsl:with-param>
  560. <xsl:with-param name="source" select="$refname"/>
  561. <xsl:with-param name="context-desc">AUTHOR sect.</xsl:with-param>
  562. <xsl:with-param name="message">
  563. <xsl:text>see see http://docbook.sf.net/el/personblurb</xsl:text>
  564. </xsl:with-param>
  565. </xsl:call-template>
  566. </xsl:if>
  567. </xsl:if>
  568. <xsl:choose>
  569. <!-- * If we have no *blurb or contrib, but this is an Author or -->
  570. <!-- * Editor, then render the corresponding localized gentext -->
  571. <xsl:when test="self::author">
  572. <xsl:text>&#10;</xsl:text>
  573. <xsl:text>.RS</xsl:text>
  574. <xsl:if test="not($blurb-indent = '')">
  575. <xsl:text> </xsl:text>
  576. <xsl:value-of select="$blurb-indent"/>
  577. </xsl:if>
  578. <xsl:text>&#10;</xsl:text>
  579. <xsl:call-template name="gentext">
  580. <xsl:with-param name="key" select="'Author'"/>
  581. </xsl:call-template>
  582. <xsl:text>.&#10;</xsl:text>
  583. <xsl:text>.RE&#10;</xsl:text>
  584. </xsl:when>
  585. <xsl:when test="self::editor">
  586. <xsl:text>&#10;</xsl:text>
  587. <xsl:text>.RS</xsl:text>
  588. <xsl:if test="not($blurb-indent = '')">
  589. <xsl:text> </xsl:text>
  590. <xsl:value-of select="$blurb-indent"/>
  591. </xsl:if>
  592. <xsl:text>&#10;</xsl:text>
  593. <xsl:call-template name="gentext">
  594. <xsl:with-param name="key" select="'Editor'"/>
  595. </xsl:call-template>
  596. <xsl:text>.&#10;</xsl:text>
  597. <xsl:text>.RE&#10;</xsl:text>
  598. </xsl:when>
  599. <!-- * If we have no *blurb or contrib, but this is an Othercredit, -->
  600. <!-- * check value of Class attribute and use corresponding gentext. -->
  601. <xsl:when test="self::othercredit">
  602. <xsl:choose>
  603. <xsl:when test="@class and @class != 'other'">
  604. <xsl:text>&#10;</xsl:text>
  605. <xsl:text>.RS</xsl:text>
  606. <xsl:if test="not($blurb-indent = '')">
  607. <xsl:text> </xsl:text>
  608. <xsl:value-of select="$blurb-indent"/>
  609. </xsl:if>
  610. <xsl:text>&#10;</xsl:text>
  611. <xsl:call-template name="gentext">
  612. <xsl:with-param name="key" select="@class"/>
  613. </xsl:call-template>
  614. <xsl:text>.&#10;</xsl:text>
  615. <xsl:text>.RE&#10;</xsl:text>
  616. </xsl:when>
  617. <xsl:otherwise>
  618. <!-- * We have an Othercredit, but no usable value for the Class -->
  619. <!-- * attribute, so nothing to show, do nothing -->
  620. </xsl:otherwise>
  621. </xsl:choose>
  622. </xsl:when>
  623. <xsl:otherwise>
  624. <!-- * We have no *blurb or contrib or anything else we can use to -->
  625. <!-- * display appropriate attribution for this person, so do nothing -->
  626. </xsl:otherwise>
  627. </xsl:choose>
  628. </xsl:otherwise>
  629. </xsl:choose>
  630. </xsl:template>
  631. <xsl:template match="personblurb|authorblurb" mode="authorsect">
  632. <xsl:call-template name="mark.up.blurb.or.contrib"/>
  633. <!-- * yeah, it's possible for a *blurb to have a "title" -->
  634. <xsl:apply-templates select="title"/>
  635. <xsl:apply-templates select="*[not(self::title)]"/>
  636. <!-- * If this *blurb has a sibling "name" element of some kind, then -->
  637. <!-- * the mark.up.blurb.or.contrib template will generated an "RS" -->
  638. <!-- * call that will cause it to be indented; so we need to call -->
  639. <!-- * "RE" to restore the previous indent level -->
  640. <xsl:if test="../personname|../surname|../firstname
  641. |../othername|../lineage|../honorific
  642. |../affiliation|../email|../address">
  643. <xsl:text>.RE&#10;</xsl:text>
  644. </xsl:if>
  645. </xsl:template>
  646. <xsl:template match="personblurb/title|authorblurb/title">
  647. <!-- * always render period after title -->
  648. <xsl:variable name="contents">
  649. <xsl:apply-templates/>
  650. </xsl:variable>
  651. <xsl:value-of select="normalize-space($contents)"/>
  652. <xsl:text>.</xsl:text>
  653. <!-- * render space after Title+period if the title is followed -->
  654. <!-- * by something element content -->
  655. <xsl:if test="following-sibling::*[name() != '']">
  656. <xsl:text> </xsl:text>
  657. </xsl:if>
  658. </xsl:template>
  659. <xsl:template match="contrib" mode="authorsect">
  660. <xsl:call-template name="mark.up.blurb.or.contrib"/>
  661. <xsl:variable name="contents">
  662. <xsl:apply-templates/>
  663. </xsl:variable>
  664. <xsl:value-of select="normalize-space($contents)"/>
  665. <xsl:text>&#10;</xsl:text>
  666. <xsl:if test="../personname|../surname|../firstname
  667. |../othername|../lineage|../honorific
  668. |../affiliation|../email|../address">
  669. <xsl:text>.RE&#10;</xsl:text>
  670. </xsl:if>
  671. </xsl:template>
  672. <xsl:template name="mark.up.blurb.or.contrib">
  673. <xsl:choose>
  674. <!-- * If this *blurb has a sibling "name" element of some kind, then -->
  675. <!-- * we are already outputting the name content, and we need to -->
  676. <!-- * indent the *blurb content after that. -->
  677. <xsl:when
  678. test="../personname|../surname|../firstname
  679. |../othername|../lineage|../honorific
  680. |../affiliation|../email|../address">
  681. <xsl:text>&#10;</xsl:text>
  682. <xsl:text>.RS</xsl:text>
  683. <xsl:if test="not($blurb-indent = '')">
  684. <xsl:text> </xsl:text>
  685. <xsl:value-of select="$blurb-indent"/>
  686. </xsl:if>
  687. </xsl:when>
  688. <xsl:otherwise>
  689. <!-- * otherwise, we have no "name" content, so don't indent; -->
  690. <!-- * instead, decide if we need a .PP or just a .br -->
  691. <xsl:choose>
  692. <xsl:when test="not(preceding-sibling::*)">
  693. <!-- * if this *blurb or contrib has no preceding -->
  694. <!-- * siblings, then we need to start a new paragraph -->
  695. <xsl:text>.PP</xsl:text>
  696. </xsl:when>
  697. <xsl:otherwise>
  698. <!-- * otherwise, this has no preceding siblings, so -->
  699. <!-- * just put a linebreak -->
  700. <xsl:text>.br</xsl:text>
  701. </xsl:otherwise>
  702. </xsl:choose>
  703. </xsl:otherwise>
  704. </xsl:choose>
  705. <xsl:text>&#10;</xsl:text>
  706. </xsl:template>
  707. <!-- * ============================================================== -->
  708. <!-- * Assemble the COPYRIGHT section -->
  709. <!-- * ============================================================== -->
  710. <!-- * The COPYRIGHT section is output only if a copyright or -->
  711. <!-- * legalnotice is found. It contains the copyright contents -->
  712. <!-- * followed by the legalnotice contents. -->
  713. <xsl:template name="copyright.section">
  714. <xsl:param name="info"/>
  715. <xsl:choose>
  716. <xsl:when test="$info//copyright|$info//legalnotice">
  717. <xsl:call-template name="make.subheading">
  718. <xsl:with-param name="title">
  719. <xsl:call-template name="gentext">
  720. <xsl:with-param name="key">Copyright</xsl:with-param>
  721. </xsl:call-template>
  722. </xsl:with-param>
  723. </xsl:call-template>
  724. <xsl:text>.br&#10;</xsl:text>
  725. <!-- * the copyright mode="titlepage.mode" template is -->
  726. <!-- * imported from the HTML stylesheets -->
  727. <xsl:for-each select="
  728. (($info[//copyright])[last()]//copyright)
  729. | (($info[//legalnotice])[last()]//legalnotice)">
  730. <xsl:choose>
  731. <xsl:when test="local-name(.) = 'copyright'">
  732. <xsl:variable name="contents">
  733. <xsl:apply-templates select="." mode="titlepage.mode"/>
  734. </xsl:variable>
  735. <xsl:value-of select="normalize-space($contents)"/>
  736. <xsl:text>&#10;</xsl:text>
  737. <xsl:text>.br&#10;</xsl:text>
  738. </xsl:when>
  739. <xsl:otherwise>
  740. <xsl:apply-templates select="." mode="titlepage.mode"/>
  741. <xsl:text>&#10;</xsl:text>
  742. <xsl:text>.sp&#10;</xsl:text>
  743. </xsl:otherwise>
  744. </xsl:choose>
  745. </xsl:for-each>
  746. </xsl:when>
  747. <xsl:otherwise/> <!-- * do nothing, no copyright or legalnotice found -->
  748. </xsl:choose>
  749. </xsl:template>
  750. <xsl:template match="legalnotice">
  751. <xsl:apply-templates/>
  752. </xsl:template>
  753. <!-- * ============================================================== -->
  754. <!-- * suppress refmeta and all *info (we grab what we need from them -->
  755. <!-- * elsewhere) -->
  756. <xsl:template match="refmeta"/>
  757. <xsl:template match="info|refentryinfo|referenceinfo|refsynopsisdivinfo
  758. |refsectioninfo|refsect1info|refsect2info|refsect3info
  759. |setinfo|bookinfo|articleinfo|chapterinfo|sectioninfo
  760. |sect1info|sect2info|sect3info|sect4info|sect5info
  761. |partinfo|prefaceinfo|appendixinfo|docinfo"/>
  762. <!-- ============================================================== -->
  763. </xsl:stylesheet>