synop.xsl 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. <?xml version='1.0'?>
  2. <!DOCTYPE xsl:stylesheet [
  3. <!ENTITY RE "&#10;">
  4. <!ENTITY nbsp "&#160;">
  5. ]>
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  8. version='1.0'>
  9. <!-- ********************************************************************
  10. $Id$
  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. <!-- ==================================================================== -->
  17. <!-- synopsis is in verbatim -->
  18. <!-- ==================================================================== -->
  19. <xsl:template match="cmdsynopsis">
  20. <fo:block xsl:use-attribute-sets="normal.para.spacing">
  21. <xsl:apply-templates/>
  22. </fo:block>
  23. </xsl:template>
  24. <xsl:template match="cmdsynopsis/command">
  25. <xsl:call-template name="inline.monoseq"/>
  26. <xsl:text> </xsl:text>
  27. </xsl:template>
  28. <xsl:template match="cmdsynopsis/command[1]" priority="2">
  29. <xsl:call-template name="inline.monoseq"/>
  30. <xsl:text> </xsl:text>
  31. </xsl:template>
  32. <xsl:template match="group|arg" name="group-or-arg">
  33. <xsl:variable name="choice" select="@choice"/>
  34. <xsl:variable name="rep" select="@rep"/>
  35. <xsl:variable name="sepchar">
  36. <xsl:choose>
  37. <xsl:when test="ancestor-or-self::*/@sepchar">
  38. <xsl:value-of select="ancestor-or-self::*/@sepchar"/>
  39. </xsl:when>
  40. <xsl:otherwise>
  41. <xsl:text> </xsl:text>
  42. </xsl:otherwise>
  43. </xsl:choose>
  44. </xsl:variable>
  45. <xsl:if test="preceding-sibling::*">
  46. <xsl:value-of select="$sepchar"/>
  47. </xsl:if>
  48. <xsl:choose>
  49. <xsl:when test="$choice='plain'">
  50. <xsl:value-of select="$arg.choice.plain.open.str"/>
  51. </xsl:when>
  52. <xsl:when test="$choice='req'">
  53. <xsl:value-of select="$arg.choice.req.open.str"/>
  54. </xsl:when>
  55. <xsl:when test="$choice='opt'">
  56. <xsl:value-of select="$arg.choice.opt.open.str"/>
  57. </xsl:when>
  58. <xsl:otherwise>
  59. <xsl:value-of select="$arg.choice.def.open.str"/>
  60. </xsl:otherwise>
  61. </xsl:choose>
  62. <xsl:apply-templates/>
  63. <xsl:choose>
  64. <xsl:when test="$rep='repeat'">
  65. <xsl:value-of select="$arg.rep.repeat.str"/>
  66. </xsl:when>
  67. <xsl:when test="$rep='norepeat'">
  68. <xsl:value-of select="$arg.rep.norepeat.str"/>
  69. </xsl:when>
  70. <xsl:otherwise>
  71. <xsl:value-of select="$arg.rep.def.str"/>
  72. </xsl:otherwise>
  73. </xsl:choose>
  74. <xsl:choose>
  75. <xsl:when test="$choice='plain'">
  76. <xsl:value-of select="$arg.choice.plain.close.str"/>
  77. </xsl:when>
  78. <xsl:when test="$choice='req'">
  79. <xsl:value-of select="$arg.choice.req.close.str"/>
  80. </xsl:when>
  81. <xsl:when test="$choice='opt'">
  82. <xsl:value-of select="$arg.choice.opt.close.str"/>
  83. </xsl:when>
  84. <xsl:otherwise>
  85. <xsl:value-of select="$arg.choice.def.close.str"/>
  86. </xsl:otherwise>
  87. </xsl:choose>
  88. </xsl:template>
  89. <xsl:template match="group/arg">
  90. <xsl:variable name="choice" select="@choice"/>
  91. <xsl:variable name="rep" select="@rep"/>
  92. <xsl:if test="preceding-sibling::*">
  93. <xsl:value-of select="$arg.or.sep"/>
  94. </xsl:if>
  95. <xsl:call-template name="group-or-arg"/>
  96. </xsl:template>
  97. <xsl:template match="sbr">
  98. <fo:block/>
  99. </xsl:template>
  100. <!-- ==================================================================== -->
  101. <xsl:template match="synopfragmentref">
  102. <xsl:variable name="target" select="key('id',@linkend)"/>
  103. <xsl:variable name="snum">
  104. <xsl:apply-templates select="$target" mode="synopfragment.number"/>
  105. </xsl:variable>
  106. <fo:inline font-style="italic">
  107. <fo:basic-link internal-destination="{@linkend}"
  108. xsl:use-attribute-sets="xref.properties">
  109. <xsl:text>(</xsl:text>
  110. <xsl:value-of select="$snum"/>
  111. <xsl:text>)</xsl:text>
  112. </fo:basic-link>
  113. <xsl:text>&#160;</xsl:text>
  114. <xsl:apply-templates/>
  115. </fo:inline>
  116. </xsl:template>
  117. <xsl:template match="synopfragment" mode="synopfragment.number">
  118. <xsl:number format="1"/>
  119. </xsl:template>
  120. <xsl:template match="synopfragment">
  121. <xsl:variable name="snum">
  122. <xsl:apply-templates select="." mode="synopfragment.number"/>
  123. </xsl:variable>
  124. <xsl:variable name="id">
  125. <xsl:call-template name="object.id"/>
  126. </xsl:variable>
  127. <fo:block id="{$id}">
  128. <xsl:text>(</xsl:text>
  129. <xsl:value-of select="$snum"/>
  130. <xsl:text>)</xsl:text>
  131. <xsl:text> </xsl:text>
  132. <xsl:apply-templates/>
  133. </fo:block>
  134. </xsl:template>
  135. <xsl:template match="funcsynopsis">
  136. <xsl:call-template name="informal.object"/>
  137. </xsl:template>
  138. <xsl:template match="funcsynopsisinfo">
  139. <fo:block space-after.minimum="0.8em"
  140. space-after.optimum="1em"
  141. space-after.maximum="1.2em">
  142. <xsl:apply-templates/>
  143. </fo:block>
  144. </xsl:template>
  145. <xsl:template match="funcprototype">
  146. <fo:block font-family="{$monospace.font.family}"
  147. space-before.minimum="0.8em"
  148. space-before.optimum="1em"
  149. space-before.maximum="1.2em">
  150. <xsl:apply-templates/>
  151. <xsl:if test="$funcsynopsis.style='kr'">
  152. <fo:block
  153. space-before.minimum="0.8em"
  154. space-before.optimum="1em"
  155. space-before.maximum="1.2em">
  156. <xsl:apply-templates select="./paramdef" mode="kr-funcsynopsis-mode"/>
  157. </fo:block>
  158. </xsl:if>
  159. </fo:block>
  160. </xsl:template>
  161. <xsl:template match="funcdef">
  162. <fo:inline font-family="{$monospace.font.family}">
  163. <xsl:apply-templates/>
  164. </fo:inline>
  165. </xsl:template>
  166. <xsl:template match="funcdef/function">
  167. <xsl:choose>
  168. <xsl:when test="$funcsynopsis.decoration != 0">
  169. <fo:inline font-weight="bold">
  170. <xsl:apply-templates/>
  171. </fo:inline>
  172. </xsl:when>
  173. <xsl:otherwise>
  174. <xsl:apply-templates/>
  175. </xsl:otherwise>
  176. </xsl:choose>
  177. </xsl:template>
  178. <xsl:template match="void">
  179. <xsl:choose>
  180. <xsl:when test="$funcsynopsis.style='ansi'">
  181. <xsl:text>(void);</xsl:text>
  182. </xsl:when>
  183. <xsl:otherwise>
  184. <xsl:text>();</xsl:text>
  185. </xsl:otherwise>
  186. </xsl:choose>
  187. </xsl:template>
  188. <xsl:template match="varargs">
  189. <xsl:text>(...);</xsl:text>
  190. </xsl:template>
  191. <xsl:template match="paramdef">
  192. <xsl:variable name="paramnum">
  193. <xsl:number count="paramdef" format="1"/>
  194. </xsl:variable>
  195. <xsl:if test="$paramnum=1">(</xsl:if>
  196. <xsl:choose>
  197. <xsl:when test="$funcsynopsis.style='ansi'">
  198. <xsl:apply-templates/>
  199. </xsl:when>
  200. <xsl:otherwise>
  201. <xsl:apply-templates select="./parameter"/>
  202. </xsl:otherwise>
  203. </xsl:choose>
  204. <xsl:choose>
  205. <xsl:when test="following-sibling::paramdef">
  206. <xsl:text>, </xsl:text>
  207. </xsl:when>
  208. <xsl:otherwise>
  209. <xsl:text>);</xsl:text>
  210. </xsl:otherwise>
  211. </xsl:choose>
  212. </xsl:template>
  213. <xsl:template match="paramdef/parameter">
  214. <xsl:choose>
  215. <xsl:when test="$funcsynopsis.decoration != 0">
  216. <xsl:call-template name="inline.italicseq"/>
  217. </xsl:when>
  218. <xsl:otherwise>
  219. <xsl:apply-templates/>
  220. </xsl:otherwise>
  221. </xsl:choose>
  222. <xsl:if test="following-sibling::parameter">
  223. <xsl:text>, </xsl:text>
  224. </xsl:if>
  225. </xsl:template>
  226. <xsl:template match="paramdef" mode="kr-funcsynopsis-mode">
  227. <fo:block>
  228. <xsl:apply-templates/>
  229. <xsl:text>;</xsl:text>
  230. </fo:block>
  231. </xsl:template>
  232. <xsl:template match="funcparams">
  233. <xsl:text>(</xsl:text>
  234. <xsl:apply-templates/>
  235. <xsl:text>)</xsl:text>
  236. </xsl:template>
  237. <!-- ==================================================================== -->
  238. <xsl:variable name="default-classsynopsis-language">java</xsl:variable>
  239. <xsl:template match="classsynopsis
  240. |fieldsynopsis
  241. |methodsynopsis
  242. |constructorsynopsis
  243. |destructorsynopsis">
  244. <xsl:param name="language">
  245. <xsl:choose>
  246. <xsl:when test="@language">
  247. <xsl:value-of select="@language"/>
  248. </xsl:when>
  249. <xsl:otherwise>
  250. <xsl:value-of select="$default-classsynopsis-language"/>
  251. </xsl:otherwise>
  252. </xsl:choose>
  253. </xsl:param>
  254. <!--
  255. <xsl:message>process <xsl:value-of select="local-name(.)"/> in <xsl:value-of select="$language"/></xsl:message>
  256. -->
  257. <xsl:choose>
  258. <xsl:when test="$language='java' or $language='Java'">
  259. <xsl:apply-templates select="." mode="java"/>
  260. </xsl:when>
  261. <xsl:when test="$language='perl' or $language='Perl'">
  262. <xsl:apply-templates select="." mode="perl"/>
  263. </xsl:when>
  264. <xsl:when test="$language='idl' or $language='IDL'">
  265. <xsl:apply-templates select="." mode="idl"/>
  266. </xsl:when>
  267. <xsl:when test="$language='cpp' or $language='c++' or $language='C++'">
  268. <xsl:apply-templates select="." mode="cpp"/>
  269. </xsl:when>
  270. <xsl:otherwise>
  271. <xsl:message>
  272. <xsl:text>Unrecognized language on </xsl:text>
  273. <xsl:value-of select="local-name(.)"/>
  274. <xsl:text>: </xsl:text>
  275. <xsl:value-of select="$language"/>
  276. </xsl:message>
  277. <xsl:apply-templates select=".">
  278. <xsl:with-param name="language"
  279. select="$default-classsynopsis-language"/>
  280. </xsl:apply-templates>
  281. </xsl:otherwise>
  282. </xsl:choose>
  283. </xsl:template>
  284. <xsl:template name="synop-break">
  285. <xsl:if test="parent::classsynopsis
  286. or (following-sibling::fieldsynopsis
  287. |following-sibling::methodsynopsis
  288. |following-sibling::constructorsynopsis
  289. |following-sibling::destructorsynopsis)">
  290. <fo:inline>&RE;</fo:inline>
  291. </xsl:if>
  292. </xsl:template>
  293. <!-- ===== Java ======================================================== -->
  294. <xsl:template match="classsynopsis" mode="java">
  295. <fo:block wrap-option='no-wrap'
  296. white-space-collapse='false'
  297. linefeed-treatment="preserve"
  298. xsl:use-attribute-sets="monospace.verbatim.properties">
  299. <xsl:apply-templates select="ooclass[1]" mode="java"/>
  300. <xsl:if test="ooclass[preceding-sibling::*]">
  301. <xsl:text> extends</xsl:text>
  302. <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="java"/>
  303. <xsl:if test="oointerface|ooexception">
  304. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  305. </xsl:if>
  306. </xsl:if>
  307. <xsl:if test="oointerface">
  308. <xsl:text>implements</xsl:text>
  309. <xsl:apply-templates select="oointerface" mode="java"/>
  310. <xsl:if test="ooexception">
  311. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  312. </xsl:if>
  313. </xsl:if>
  314. <xsl:if test="ooexception">
  315. <xsl:text>throws</xsl:text>
  316. <xsl:apply-templates select="ooexception" mode="java"/>
  317. </xsl:if>
  318. <xsl:text>&nbsp;{&RE;</xsl:text>
  319. <xsl:apply-templates select="constructorsynopsis
  320. |destructorsynopsis
  321. |fieldsynopsis
  322. |methodsynopsis
  323. |classsynopsisinfo" mode="java"/>
  324. <xsl:text>}</xsl:text>
  325. </fo:block>
  326. </xsl:template>
  327. <xsl:template match="classsynopsisinfo" mode="java">
  328. <xsl:apply-templates mode="java"/>
  329. </xsl:template>
  330. <xsl:template match="ooclass|oointerface|ooexception" mode="java">
  331. <xsl:choose>
  332. <xsl:when test="preceding-sibling::*">
  333. <xsl:text>, </xsl:text>
  334. </xsl:when>
  335. <xsl:otherwise>
  336. <xsl:text> </xsl:text>
  337. </xsl:otherwise>
  338. </xsl:choose>
  339. <xsl:apply-templates mode="java"/>
  340. </xsl:template>
  341. <xsl:template match="modifier|package" mode="java">
  342. <xsl:apply-templates mode="java"/>
  343. <xsl:if test="following-sibling::*">
  344. <xsl:text>&nbsp;</xsl:text>
  345. </xsl:if>
  346. </xsl:template>
  347. <xsl:template match="classname" mode="java">
  348. <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
  349. <xsl:text>, </xsl:text>
  350. </xsl:if>
  351. <xsl:apply-templates mode="java"/>
  352. </xsl:template>
  353. <xsl:template match="interfacename" mode="java">
  354. <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
  355. <xsl:text>, </xsl:text>
  356. </xsl:if>
  357. <xsl:apply-templates mode="java"/>
  358. </xsl:template>
  359. <xsl:template match="exceptionname" mode="java">
  360. <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
  361. <xsl:text>, </xsl:text>
  362. </xsl:if>
  363. <xsl:apply-templates mode="java"/>
  364. </xsl:template>
  365. <xsl:template match="fieldsynopsis" mode="java">
  366. <fo:block wrap-option='no-wrap'
  367. white-space-collapse='false'
  368. linefeed-treatment="preserve"
  369. xsl:use-attribute-sets="monospace.verbatim.properties">
  370. <xsl:text>&nbsp;&nbsp;</xsl:text>
  371. <xsl:apply-templates mode="java"/>
  372. <xsl:text>;</xsl:text>
  373. <xsl:call-template name="synop-break"/>
  374. </fo:block>
  375. </xsl:template>
  376. <xsl:template match="type" mode="java">
  377. <xsl:apply-templates mode="java"/>
  378. <xsl:text>&nbsp;</xsl:text>
  379. </xsl:template>
  380. <xsl:template match="varname" mode="java">
  381. <xsl:apply-templates mode="java"/>
  382. <xsl:text>&nbsp;</xsl:text>
  383. </xsl:template>
  384. <xsl:template match="initializer" mode="java">
  385. <xsl:text>=&nbsp;</xsl:text>
  386. <xsl:apply-templates mode="java"/>
  387. </xsl:template>
  388. <xsl:template match="void" mode="java">
  389. <xsl:text>void&nbsp;</xsl:text>
  390. </xsl:template>
  391. <xsl:template match="methodname" mode="java">
  392. <xsl:apply-templates mode="java"/>
  393. </xsl:template>
  394. <xsl:template match="methodparam" mode="java">
  395. <xsl:param name="indent">0</xsl:param>
  396. <xsl:if test="preceding-sibling::methodparam">
  397. <xsl:text>,&RE;</xsl:text>
  398. <xsl:if test="$indent &gt; 0">
  399. <xsl:call-template name="copy-string">
  400. <xsl:with-param name="string">&nbsp;</xsl:with-param>
  401. <xsl:with-param name="count" select="$indent + 1"/>
  402. </xsl:call-template>
  403. </xsl:if>
  404. </xsl:if>
  405. <xsl:apply-templates mode="java"/>
  406. </xsl:template>
  407. <xsl:template match="parameter" mode="java">
  408. <xsl:apply-templates mode="java"/>
  409. </xsl:template>
  410. <xsl:template mode="java"
  411. match="constructorsynopsis|destructorsynopsis|methodsynopsis">
  412. <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
  413. <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
  414. <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
  415. <xsl:variable name="decl">
  416. <xsl:text> </xsl:text>
  417. <xsl:apply-templates select="$start-modifiers" mode="java"/>
  418. <!-- type -->
  419. <xsl:if test="local-name($notmod[1]) != 'methodname'">
  420. <xsl:apply-templates select="$notmod[1]" mode="java"/>
  421. </xsl:if>
  422. <xsl:apply-templates select="methodname" mode="java"/>
  423. </xsl:variable>
  424. <fo:block wrap-option='no-wrap'
  425. white-space-collapse='false'
  426. linefeed-treatment="preserve"
  427. xsl:use-attribute-sets="monospace.verbatim.properties">
  428. <xsl:copy-of select="$decl"/>
  429. <xsl:text>(</xsl:text>
  430. <xsl:apply-templates select="methodparam" mode="java">
  431. <xsl:with-param name="indent" select="string-length($decl)"/>
  432. </xsl:apply-templates>
  433. <xsl:text>)</xsl:text>
  434. <xsl:if test="exceptionname">
  435. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;throws&nbsp;</xsl:text>
  436. <xsl:apply-templates select="exceptionname" mode="java"/>
  437. </xsl:if>
  438. <xsl:if test="modifier[preceding-sibling::*[local-name(.) != 'modifier']]">
  439. <xsl:text> </xsl:text>
  440. <xsl:apply-templates select="$end-modifiers" mode="java"/>
  441. </xsl:if>
  442. <xsl:text>;</xsl:text>
  443. </fo:block>
  444. <xsl:call-template name="synop-break"/>
  445. </xsl:template>
  446. <!-- ===== C++ ========================================================= -->
  447. <xsl:template match="classsynopsis" mode="cpp">
  448. <fo:block wrap-option='no-wrap'
  449. white-space-collapse='false'
  450. linefeed-treatment="preserve"
  451. xsl:use-attribute-sets="monospace.verbatim.properties">
  452. <xsl:apply-templates select="ooclass[1]" mode="cpp"/>
  453. <xsl:if test="ooclass[preceding-sibling::*]">
  454. <xsl:text>: </xsl:text>
  455. <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="cpp"/>
  456. <xsl:if test="oointerface|ooexception">
  457. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  458. </xsl:if>
  459. </xsl:if>
  460. <xsl:if test="oointerface">
  461. <xsl:text> implements</xsl:text>
  462. <xsl:apply-templates select="oointerface" mode="cpp"/>
  463. <xsl:if test="ooexception">
  464. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  465. </xsl:if>
  466. </xsl:if>
  467. <xsl:if test="ooexception">
  468. <xsl:text> throws</xsl:text>
  469. <xsl:apply-templates select="ooexception" mode="cpp"/>
  470. </xsl:if>
  471. <xsl:text>&nbsp;{&RE;</xsl:text>
  472. <xsl:apply-templates select="constructorsynopsis
  473. |destructorsynopsis
  474. |fieldsynopsis
  475. |methodsynopsis
  476. |classsynopsisinfo" mode="cpp"/>
  477. <xsl:text>}</xsl:text>
  478. </fo:block>
  479. </xsl:template>
  480. <xsl:template match="classsynopsisinfo" mode="cpp">
  481. <xsl:apply-templates mode="cpp"/>
  482. </xsl:template>
  483. <xsl:template match="ooclass|oointerface|ooexception" mode="cpp">
  484. <xsl:if test="preceding-sibling::*">
  485. <xsl:text>, </xsl:text>
  486. </xsl:if>
  487. <xsl:apply-templates mode="cpp"/>
  488. </xsl:template>
  489. <xsl:template match="modifier|package" mode="cpp">
  490. <xsl:apply-templates mode="cpp"/>
  491. <xsl:if test="following-sibling::*">
  492. <xsl:text>&nbsp;</xsl:text>
  493. </xsl:if>
  494. </xsl:template>
  495. <xsl:template match="classname" mode="cpp">
  496. <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
  497. <xsl:text>, </xsl:text>
  498. </xsl:if>
  499. <xsl:apply-templates mode="cpp"/>
  500. </xsl:template>
  501. <xsl:template match="interfacename" mode="cpp">
  502. <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
  503. <xsl:text>, </xsl:text>
  504. </xsl:if>
  505. <xsl:apply-templates mode="cpp"/>
  506. </xsl:template>
  507. <xsl:template match="exceptionname" mode="cpp">
  508. <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
  509. <xsl:text>, </xsl:text>
  510. </xsl:if>
  511. <xsl:apply-templates mode="cpp"/>
  512. </xsl:template>
  513. <xsl:template match="fieldsynopsis" mode="cpp">
  514. <fo:block wrap-option='no-wrap'
  515. white-space-collapse='false'
  516. linefeed-treatment="preserve"
  517. xsl:use-attribute-sets="monospace.verbatim.properties">
  518. <xsl:text>&nbsp;&nbsp;</xsl:text>
  519. <xsl:apply-templates mode="cpp"/>
  520. <xsl:text>;</xsl:text>
  521. </fo:block>
  522. <xsl:call-template name="synop-break"/>
  523. </xsl:template>
  524. <xsl:template match="type" mode="cpp">
  525. <xsl:apply-templates mode="cpp"/>
  526. <xsl:text>&nbsp;</xsl:text>
  527. </xsl:template>
  528. <xsl:template match="varname" mode="cpp">
  529. <xsl:apply-templates mode="cpp"/>
  530. <xsl:text>&nbsp;</xsl:text>
  531. </xsl:template>
  532. <xsl:template match="initializer" mode="cpp">
  533. <xsl:text>=&nbsp;</xsl:text>
  534. <xsl:apply-templates mode="cpp"/>
  535. </xsl:template>
  536. <xsl:template match="void" mode="cpp">
  537. <xsl:text>void&nbsp;</xsl:text>
  538. </xsl:template>
  539. <xsl:template match="methodname" mode="cpp">
  540. <xsl:apply-templates mode="cpp"/>
  541. </xsl:template>
  542. <xsl:template match="methodparam" mode="cpp">
  543. <xsl:if test="preceding-sibling::methodparam">
  544. <xsl:text>, </xsl:text>
  545. </xsl:if>
  546. <xsl:apply-templates mode="cpp"/>
  547. </xsl:template>
  548. <xsl:template match="parameter" mode="cpp">
  549. <xsl:apply-templates mode="cpp"/>
  550. </xsl:template>
  551. <xsl:template mode="cpp"
  552. match="constructorsynopsis|destructorsynopsis|methodsynopsis">
  553. <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
  554. <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
  555. <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
  556. <fo:block wrap-option='no-wrap'
  557. white-space-collapse='false'
  558. linefeed-treatment="preserve"
  559. xsl:use-attribute-sets="monospace.verbatim.properties">
  560. <xsl:text> </xsl:text>
  561. <xsl:apply-templates select="$start-modifiers" mode="cpp"/>
  562. <!-- type -->
  563. <xsl:if test="local-name($notmod[1]) != 'methodname'">
  564. <xsl:apply-templates select="$notmod[1]" mode="cpp"/>
  565. </xsl:if>
  566. <xsl:apply-templates select="methodname" mode="cpp"/>
  567. <xsl:text>(</xsl:text>
  568. <xsl:apply-templates select="methodparam" mode="cpp"/>
  569. <xsl:text>)</xsl:text>
  570. <xsl:if test="exceptionname">
  571. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;throws&nbsp;</xsl:text>
  572. <xsl:apply-templates select="exceptionname" mode="cpp"/>
  573. </xsl:if>
  574. <xsl:if test="modifier[preceding-sibling::*[local-name(.) != 'modifier']]">
  575. <xsl:text> </xsl:text>
  576. <xsl:apply-templates select="$end-modifiers" mode="cpp"/>
  577. </xsl:if>
  578. <xsl:text>;</xsl:text>
  579. </fo:block>
  580. <xsl:call-template name="synop-break"/>
  581. </xsl:template>
  582. <!-- ===== IDL ========================================================= -->
  583. <xsl:template match="classsynopsis" mode="idl">
  584. <fo:block wrap-option='no-wrap'
  585. white-space-collapse='false'
  586. linefeed-treatment="preserve"
  587. xsl:use-attribute-sets="monospace.verbatim.properties">
  588. <xsl:text>interface </xsl:text>
  589. <xsl:apply-templates select="ooclass[1]" mode="idl"/>
  590. <xsl:if test="ooclass[preceding-sibling::*]">
  591. <xsl:text>: </xsl:text>
  592. <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="idl"/>
  593. <xsl:if test="oointerface|ooexception">
  594. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  595. </xsl:if>
  596. </xsl:if>
  597. <xsl:if test="oointerface">
  598. <xsl:text> implements</xsl:text>
  599. <xsl:apply-templates select="oointerface" mode="idl"/>
  600. <xsl:if test="ooexception">
  601. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  602. </xsl:if>
  603. </xsl:if>
  604. <xsl:if test="ooexception">
  605. <xsl:text> throws</xsl:text>
  606. <xsl:apply-templates select="ooexception" mode="idl"/>
  607. </xsl:if>
  608. <xsl:text>&nbsp;{&RE;</xsl:text>
  609. <xsl:apply-templates select="constructorsynopsis
  610. |destructorsynopsis
  611. |fieldsynopsis
  612. |methodsynopsis
  613. |classsynopsisinfo" mode="idl"/>
  614. <xsl:text>}</xsl:text>
  615. </fo:block>
  616. </xsl:template>
  617. <xsl:template match="classsynopsisinfo" mode="idl">
  618. <xsl:apply-templates mode="idl"/>
  619. </xsl:template>
  620. <xsl:template match="ooclass|oointerface|ooexception" mode="idl">
  621. <xsl:if test="preceding-sibling::*">
  622. <xsl:text>, </xsl:text>
  623. </xsl:if>
  624. <xsl:apply-templates mode="idl"/>
  625. </xsl:template>
  626. <xsl:template match="modifier|package" mode="idl">
  627. <xsl:apply-templates mode="idl"/>
  628. <xsl:if test="following-sibling::*">
  629. <xsl:text>&nbsp;</xsl:text>
  630. </xsl:if>
  631. </xsl:template>
  632. <xsl:template match="classname" mode="idl">
  633. <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
  634. <xsl:text>, </xsl:text>
  635. </xsl:if>
  636. <xsl:apply-templates mode="idl"/>
  637. </xsl:template>
  638. <xsl:template match="interfacename" mode="idl">
  639. <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
  640. <xsl:text>, </xsl:text>
  641. </xsl:if>
  642. <xsl:apply-templates mode="idl"/>
  643. </xsl:template>
  644. <xsl:template match="exceptionname" mode="idl">
  645. <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
  646. <xsl:text>, </xsl:text>
  647. </xsl:if>
  648. <xsl:apply-templates mode="idl"/>
  649. </xsl:template>
  650. <xsl:template match="fieldsynopsis" mode="idl">
  651. <fo:block wrap-option='no-wrap'
  652. white-space-collapse='false'
  653. linefeed-treatment="preserve"
  654. xsl:use-attribute-sets="monospace.verbatim.properties">
  655. <xsl:text>&nbsp;&nbsp;</xsl:text>
  656. <xsl:apply-templates mode="idl"/>
  657. <xsl:text>;</xsl:text>
  658. </fo:block>
  659. <xsl:call-template name="synop-break"/>
  660. </xsl:template>
  661. <xsl:template match="type" mode="idl">
  662. <xsl:apply-templates mode="idl"/>
  663. <xsl:text>&nbsp;</xsl:text>
  664. </xsl:template>
  665. <xsl:template match="varname" mode="idl">
  666. <xsl:apply-templates mode="idl"/>
  667. <xsl:text>&nbsp;</xsl:text>
  668. </xsl:template>
  669. <xsl:template match="initializer" mode="idl">
  670. <xsl:text>=&nbsp;</xsl:text>
  671. <xsl:apply-templates mode="idl"/>
  672. </xsl:template>
  673. <xsl:template match="void" mode="idl">
  674. <xsl:text>void&nbsp;</xsl:text>
  675. </xsl:template>
  676. <xsl:template match="methodname" mode="idl">
  677. <xsl:apply-templates mode="idl"/>
  678. </xsl:template>
  679. <xsl:template match="methodparam" mode="idl">
  680. <xsl:if test="preceding-sibling::methodparam">
  681. <xsl:text>, </xsl:text>
  682. </xsl:if>
  683. <xsl:apply-templates mode="idl"/>
  684. </xsl:template>
  685. <xsl:template match="parameter" mode="idl">
  686. <xsl:apply-templates mode="idl"/>
  687. </xsl:template>
  688. <xsl:template mode="idl"
  689. match="constructorsynopsis|destructorsynopsis|methodsynopsis">
  690. <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
  691. <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
  692. <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
  693. <fo:block wrap-option='no-wrap'
  694. white-space-collapse='false'
  695. linefeed-treatment="preserve"
  696. xsl:use-attribute-sets="monospace.verbatim.properties">
  697. <xsl:text> </xsl:text>
  698. <xsl:apply-templates select="$start-modifiers" mode="idl"/>
  699. <!-- type -->
  700. <xsl:if test="local-name($notmod[1]) != 'methodname'">
  701. <xsl:apply-templates select="$notmod[1]" mode="idl"/>
  702. </xsl:if>
  703. <xsl:apply-templates select="methodname" mode="idl"/>
  704. <xsl:text>(</xsl:text>
  705. <xsl:apply-templates select="methodparam" mode="idl"/>
  706. <xsl:text>)</xsl:text>
  707. <xsl:if test="exceptionname">
  708. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;raises(</xsl:text>
  709. <xsl:apply-templates select="exceptionname" mode="idl"/>
  710. <xsl:text>)</xsl:text>
  711. </xsl:if>
  712. <xsl:if test="modifier[preceding-sibling::*[local-name(.) != 'modifier']]">
  713. <xsl:text> </xsl:text>
  714. <xsl:apply-templates select="$end-modifiers" mode="idl"/>
  715. </xsl:if>
  716. <xsl:text>;</xsl:text>
  717. </fo:block>
  718. <xsl:call-template name="synop-break"/>
  719. </xsl:template>
  720. <!-- ===== Perl ======================================================== -->
  721. <xsl:template match="classsynopsis" mode="perl">
  722. <fo:block wrap-option='no-wrap'
  723. white-space-collapse='false'
  724. linefeed-treatment="preserve"
  725. xsl:use-attribute-sets="monospace.verbatim.properties">
  726. <xsl:text>package </xsl:text>
  727. <xsl:apply-templates select="ooclass[1]" mode="perl"/>
  728. <xsl:text>;&RE;</xsl:text>
  729. <xsl:if test="ooclass[preceding-sibling::*]">
  730. <xsl:text>@ISA = (</xsl:text>
  731. <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="perl"/>
  732. <xsl:text>);&RE;</xsl:text>
  733. </xsl:if>
  734. <xsl:apply-templates select="constructorsynopsis
  735. |destructorsynopsis
  736. |fieldsynopsis
  737. |methodsynopsis
  738. |classsynopsisinfo" mode="perl"/>
  739. </fo:block>
  740. </xsl:template>
  741. <xsl:template match="classsynopsisinfo" mode="perl">
  742. <xsl:apply-templates mode="perl"/>
  743. </xsl:template>
  744. <xsl:template match="ooclass|oointerface|ooexception" mode="perl">
  745. <xsl:if test="preceding-sibling::*">
  746. <xsl:text>, </xsl:text>
  747. </xsl:if>
  748. <xsl:apply-templates mode="perl"/>
  749. </xsl:template>
  750. <xsl:template match="modifier|package" mode="perl">
  751. <xsl:apply-templates mode="perl"/>
  752. <xsl:if test="following-sibling::*">
  753. <xsl:text>&nbsp;</xsl:text>
  754. </xsl:if>
  755. </xsl:template>
  756. <xsl:template match="classname" mode="perl">
  757. <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
  758. <xsl:text>, </xsl:text>
  759. </xsl:if>
  760. <xsl:apply-templates mode="perl"/>
  761. </xsl:template>
  762. <xsl:template match="interfacename" mode="perl">
  763. <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
  764. <xsl:text>, </xsl:text>
  765. </xsl:if>
  766. <xsl:apply-templates mode="perl"/>
  767. </xsl:template>
  768. <xsl:template match="exceptionname" mode="perl">
  769. <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
  770. <xsl:text>, </xsl:text>
  771. </xsl:if>
  772. <xsl:apply-templates mode="perl"/>
  773. </xsl:template>
  774. <xsl:template match="fieldsynopsis" mode="perl">
  775. <fo:block wrap-option='no-wrap'
  776. white-space-collapse='false'
  777. linefeed-treatment="preserve"
  778. xsl:use-attribute-sets="monospace.verbatim.properties">
  779. <xsl:text>&nbsp;&nbsp;</xsl:text>
  780. <xsl:apply-templates mode="perl"/>
  781. <xsl:text>;</xsl:text>
  782. </fo:block>
  783. <xsl:call-template name="synop-break"/>
  784. </xsl:template>
  785. <xsl:template match="type" mode="perl">
  786. <xsl:apply-templates mode="perl"/>
  787. <xsl:text>&nbsp;</xsl:text>
  788. </xsl:template>
  789. <xsl:template match="varname" mode="perl">
  790. <xsl:apply-templates mode="perl"/>
  791. <xsl:text>&nbsp;</xsl:text>
  792. </xsl:template>
  793. <xsl:template match="initializer" mode="perl">
  794. <xsl:text>=&nbsp;</xsl:text>
  795. <xsl:apply-templates mode="perl"/>
  796. </xsl:template>
  797. <xsl:template match="void" mode="perl">
  798. <xsl:text>void&nbsp;</xsl:text>
  799. </xsl:template>
  800. <xsl:template match="methodname" mode="perl">
  801. <xsl:apply-templates mode="perl"/>
  802. </xsl:template>
  803. <xsl:template match="methodparam" mode="perl">
  804. <xsl:if test="preceding-sibling::methodparam">
  805. <xsl:text>, </xsl:text>
  806. </xsl:if>
  807. <xsl:apply-templates mode="perl"/>
  808. </xsl:template>
  809. <xsl:template match="parameter" mode="perl">
  810. <xsl:apply-templates mode="perl"/>
  811. </xsl:template>
  812. <xsl:template mode="perl"
  813. match="constructorsynopsis|destructorsynopsis|methodsynopsis">
  814. <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
  815. <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
  816. <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
  817. <fo:block wrap-option='no-wrap'
  818. white-space-collapse='false'
  819. linefeed-treatment="preserve"
  820. xsl:use-attribute-sets="monospace.verbatim.properties">
  821. <xsl:text>sub </xsl:text>
  822. <xsl:apply-templates select="methodname" mode="perl"/>
  823. <xsl:text> { ... };</xsl:text>
  824. <xsl:call-template name="synop-break"/>
  825. </fo:block>
  826. </xsl:template>
  827. <!-- ==================================================================== -->
  828. <!-- * DocBook 5 allows linking elements (link, olink, and xref) -->
  829. <!-- * within the OO *synopsis elements (classsynopsis, fieldsynopsis, -->
  830. <!-- * methodsynopsis, constructorsynopsis, destructorsynopsis) and -->
  831. <!-- * their children. So we need to have mode="java|cpp|idl|perl" -->
  832. <!-- * per-mode matches for those linking elements in order for them -->
  833. <!-- * to be processed as expected. -->
  834. <xsl:template match="link|olink|xref" mode="java">
  835. <xsl:apply-templates select="."/>
  836. </xsl:template>
  837. <xsl:template match="link|olink|xref" mode="cpp">
  838. <xsl:apply-templates select="."/>
  839. </xsl:template>
  840. <xsl:template match="link|olink|xref" mode="idl">
  841. <xsl:apply-templates select="."/>
  842. </xsl:template>
  843. <xsl:template match="link|olink|xref" mode="perl">
  844. <xsl:apply-templates select="."/>
  845. </xsl:template>
  846. </xsl:stylesheet>