synop.xsl 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  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: synop.xsl 8334 2009-03-15 14:26:23Z 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. <!-- ==================================================================== -->
  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. <xsl:variable name="style">
  147. <xsl:call-template name="funcsynopsis.style"/>
  148. </xsl:variable>
  149. <fo:block font-family="{$monospace.font.family}"
  150. space-before.minimum="0.8em"
  151. space-before.optimum="1em"
  152. space-before.maximum="1.2em">
  153. <xsl:apply-templates/>
  154. <xsl:if test="$style='kr'">
  155. <fo:block
  156. space-before.minimum="0.8em"
  157. space-before.optimum="1em"
  158. space-before.maximum="1.2em">
  159. <xsl:apply-templates select="./paramdef" mode="kr-funcsynopsis-mode"/>
  160. </fo:block>
  161. </xsl:if>
  162. </fo:block>
  163. </xsl:template>
  164. <xsl:template match="funcdef">
  165. <fo:inline font-family="{$monospace.font.family}">
  166. <xsl:apply-templates/>
  167. </fo:inline>
  168. </xsl:template>
  169. <xsl:template match="funcdef/function">
  170. <xsl:choose>
  171. <xsl:when test="$funcsynopsis.decoration != 0">
  172. <fo:inline font-weight="bold">
  173. <xsl:apply-templates/>
  174. </fo:inline>
  175. </xsl:when>
  176. <xsl:otherwise>
  177. <xsl:apply-templates/>
  178. </xsl:otherwise>
  179. </xsl:choose>
  180. </xsl:template>
  181. <xsl:template match="void">
  182. <xsl:variable name="style">
  183. <xsl:call-template name="funcsynopsis.style"/>
  184. </xsl:variable>
  185. <xsl:choose>
  186. <xsl:when test="$style='ansi'">
  187. <xsl:text>(void);</xsl:text>
  188. </xsl:when>
  189. <xsl:otherwise>
  190. <xsl:text>();</xsl:text>
  191. </xsl:otherwise>
  192. </xsl:choose>
  193. </xsl:template>
  194. <xsl:template match="varargs">
  195. <xsl:text>(...);</xsl:text>
  196. </xsl:template>
  197. <xsl:template match="paramdef">
  198. <xsl:variable name="style">
  199. <xsl:call-template name="funcsynopsis.style"/>
  200. </xsl:variable>
  201. <xsl:variable name="paramnum">
  202. <xsl:number count="paramdef" format="1"/>
  203. </xsl:variable>
  204. <xsl:if test="$paramnum=1">(</xsl:if>
  205. <xsl:choose>
  206. <xsl:when test="$style='ansi'">
  207. <xsl:apply-templates/>
  208. </xsl:when>
  209. <xsl:otherwise>
  210. <xsl:apply-templates select="./parameter"/>
  211. </xsl:otherwise>
  212. </xsl:choose>
  213. <xsl:choose>
  214. <xsl:when test="following-sibling::paramdef">
  215. <xsl:text>, </xsl:text>
  216. </xsl:when>
  217. <xsl:otherwise>
  218. <xsl:text>);</xsl:text>
  219. </xsl:otherwise>
  220. </xsl:choose>
  221. </xsl:template>
  222. <xsl:template match="paramdef/parameter">
  223. <xsl:choose>
  224. <xsl:when test="$funcsynopsis.decoration != 0">
  225. <xsl:call-template name="inline.italicseq"/>
  226. </xsl:when>
  227. <xsl:otherwise>
  228. <xsl:apply-templates/>
  229. </xsl:otherwise>
  230. </xsl:choose>
  231. <xsl:if test="following-sibling::parameter">
  232. <xsl:text>, </xsl:text>
  233. </xsl:if>
  234. </xsl:template>
  235. <xsl:template match="paramdef" mode="kr-funcsynopsis-mode">
  236. <fo:block>
  237. <xsl:apply-templates/>
  238. <xsl:text>;</xsl:text>
  239. </fo:block>
  240. </xsl:template>
  241. <xsl:template match="funcparams">
  242. <xsl:text>(</xsl:text>
  243. <xsl:apply-templates/>
  244. <xsl:text>)</xsl:text>
  245. </xsl:template>
  246. <!-- Return value of PI or parameter -->
  247. <xsl:template name="funcsynopsis.style">
  248. <xsl:variable name="pi.style">
  249. <xsl:call-template name="pi.dbfo_funcsynopsis-style">
  250. <xsl:with-param name="node" select="ancestor::funcsynopsis/descendant-or-self::*"/>
  251. </xsl:call-template>
  252. </xsl:variable>
  253. <xsl:choose>
  254. <xsl:when test="$pi.style != ''">
  255. <xsl:value-of select="$pi.style"/>
  256. </xsl:when>
  257. <xsl:otherwise>
  258. <xsl:value-of select="$funcsynopsis.style"/>
  259. </xsl:otherwise>
  260. </xsl:choose>
  261. </xsl:template>
  262. <!-- ==================================================================== -->
  263. <xsl:variable name="default-classsynopsis-language">java</xsl:variable>
  264. <xsl:template match="classsynopsis
  265. |fieldsynopsis
  266. |methodsynopsis
  267. |constructorsynopsis
  268. |destructorsynopsis">
  269. <xsl:param name="language">
  270. <xsl:choose>
  271. <xsl:when test="@language">
  272. <xsl:value-of select="@language"/>
  273. </xsl:when>
  274. <xsl:otherwise>
  275. <xsl:value-of select="$default-classsynopsis-language"/>
  276. </xsl:otherwise>
  277. </xsl:choose>
  278. </xsl:param>
  279. <!--
  280. <xsl:message>process <xsl:value-of select="local-name(.)"/> in <xsl:value-of select="$language"/></xsl:message>
  281. -->
  282. <xsl:choose>
  283. <xsl:when test="$language='java' or $language='Java'">
  284. <xsl:apply-templates select="." mode="java"/>
  285. </xsl:when>
  286. <xsl:when test="$language='perl' or $language='Perl'">
  287. <xsl:apply-templates select="." mode="perl"/>
  288. </xsl:when>
  289. <xsl:when test="$language='idl' or $language='IDL'">
  290. <xsl:apply-templates select="." mode="idl"/>
  291. </xsl:when>
  292. <xsl:when test="$language='cpp' or $language='c++' or $language='C++'">
  293. <xsl:apply-templates select="." mode="cpp"/>
  294. </xsl:when>
  295. <xsl:otherwise>
  296. <xsl:message>
  297. <xsl:text>Unrecognized language on </xsl:text>
  298. <xsl:value-of select="local-name(.)"/>
  299. <xsl:text>: </xsl:text>
  300. <xsl:value-of select="$language"/>
  301. </xsl:message>
  302. <xsl:apply-templates select=".">
  303. <xsl:with-param name="language"
  304. select="$default-classsynopsis-language"/>
  305. </xsl:apply-templates>
  306. </xsl:otherwise>
  307. </xsl:choose>
  308. </xsl:template>
  309. <xsl:template name="synop-break">
  310. <xsl:if test="parent::classsynopsis
  311. or (following-sibling::fieldsynopsis
  312. |following-sibling::methodsynopsis
  313. |following-sibling::constructorsynopsis
  314. |following-sibling::destructorsynopsis)">
  315. <fo:inline>&RE;</fo:inline>
  316. </xsl:if>
  317. </xsl:template>
  318. <!-- ===== Java ======================================================== -->
  319. <xsl:template match="classsynopsis" mode="java">
  320. <fo:block wrap-option='no-wrap'
  321. white-space-collapse='false'
  322. linefeed-treatment="preserve"
  323. xsl:use-attribute-sets="monospace.verbatim.properties">
  324. <xsl:apply-templates select="ooclass[1]" mode="java"/>
  325. <xsl:if test="ooclass[preceding-sibling::*]">
  326. <xsl:text> extends</xsl:text>
  327. <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="java"/>
  328. <xsl:if test="oointerface|ooexception">
  329. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  330. </xsl:if>
  331. </xsl:if>
  332. <xsl:if test="oointerface">
  333. <xsl:text>implements</xsl:text>
  334. <xsl:apply-templates select="oointerface" mode="java"/>
  335. <xsl:if test="ooexception">
  336. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  337. </xsl:if>
  338. </xsl:if>
  339. <xsl:if test="ooexception">
  340. <xsl:text>throws</xsl:text>
  341. <xsl:apply-templates select="ooexception" mode="java"/>
  342. </xsl:if>
  343. <xsl:text>&nbsp;{&RE;</xsl:text>
  344. <xsl:apply-templates select="constructorsynopsis
  345. |destructorsynopsis
  346. |fieldsynopsis
  347. |methodsynopsis
  348. |classsynopsisinfo" mode="java"/>
  349. <xsl:text>}</xsl:text>
  350. </fo:block>
  351. </xsl:template>
  352. <xsl:template match="classsynopsisinfo" mode="java">
  353. <xsl:apply-templates mode="java"/>
  354. </xsl:template>
  355. <xsl:template match="ooclass|oointerface|ooexception" mode="java">
  356. <xsl:choose>
  357. <xsl:when test="preceding-sibling::*">
  358. <xsl:text>, </xsl:text>
  359. </xsl:when>
  360. <xsl:otherwise>
  361. <xsl:text> </xsl:text>
  362. </xsl:otherwise>
  363. </xsl:choose>
  364. <xsl:apply-templates mode="java"/>
  365. </xsl:template>
  366. <xsl:template match="modifier|package" mode="java">
  367. <xsl:apply-templates mode="java"/>
  368. <xsl:if test="following-sibling::*">
  369. <xsl:text>&nbsp;</xsl:text>
  370. </xsl:if>
  371. </xsl:template>
  372. <xsl:template match="classname" mode="java">
  373. <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
  374. <xsl:text>, </xsl:text>
  375. </xsl:if>
  376. <xsl:apply-templates mode="java"/>
  377. </xsl:template>
  378. <xsl:template match="interfacename" mode="java">
  379. <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
  380. <xsl:text>, </xsl:text>
  381. </xsl:if>
  382. <xsl:apply-templates mode="java"/>
  383. </xsl:template>
  384. <xsl:template match="exceptionname" mode="java">
  385. <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
  386. <xsl:text>, </xsl:text>
  387. </xsl:if>
  388. <xsl:apply-templates mode="java"/>
  389. </xsl:template>
  390. <xsl:template match="fieldsynopsis" mode="java">
  391. <fo:block wrap-option='no-wrap'
  392. white-space-collapse='false'
  393. linefeed-treatment="preserve"
  394. xsl:use-attribute-sets="monospace.verbatim.properties">
  395. <xsl:text>&nbsp;&nbsp;</xsl:text>
  396. <xsl:apply-templates mode="java"/>
  397. <xsl:text>;</xsl:text>
  398. <xsl:call-template name="synop-break"/>
  399. </fo:block>
  400. </xsl:template>
  401. <xsl:template match="type" mode="java">
  402. <xsl:apply-templates mode="java"/>
  403. <xsl:text>&nbsp;</xsl:text>
  404. </xsl:template>
  405. <xsl:template match="varname" mode="java">
  406. <xsl:apply-templates mode="java"/>
  407. <xsl:text>&nbsp;</xsl:text>
  408. </xsl:template>
  409. <xsl:template match="initializer" mode="java">
  410. <xsl:text>=&nbsp;</xsl:text>
  411. <xsl:apply-templates mode="java"/>
  412. </xsl:template>
  413. <xsl:template match="void" mode="java">
  414. <xsl:text>void&nbsp;</xsl:text>
  415. </xsl:template>
  416. <xsl:template match="methodname" mode="java">
  417. <xsl:apply-templates mode="java"/>
  418. </xsl:template>
  419. <xsl:template match="methodparam" mode="java">
  420. <xsl:param name="indent">0</xsl:param>
  421. <xsl:if test="preceding-sibling::methodparam">
  422. <xsl:text>,&RE;</xsl:text>
  423. <xsl:if test="$indent &gt; 0">
  424. <xsl:call-template name="copy-string">
  425. <xsl:with-param name="string">&nbsp;</xsl:with-param>
  426. <xsl:with-param name="count" select="$indent + 1"/>
  427. </xsl:call-template>
  428. </xsl:if>
  429. </xsl:if>
  430. <xsl:apply-templates mode="java"/>
  431. </xsl:template>
  432. <xsl:template match="parameter" mode="java">
  433. <xsl:apply-templates mode="java"/>
  434. </xsl:template>
  435. <xsl:template mode="java"
  436. match="constructorsynopsis|destructorsynopsis|methodsynopsis">
  437. <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
  438. <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
  439. <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
  440. <xsl:variable name="decl">
  441. <xsl:text> </xsl:text>
  442. <xsl:apply-templates select="$start-modifiers" mode="java"/>
  443. <!-- type -->
  444. <xsl:if test="local-name($notmod[1]) != 'methodname'">
  445. <xsl:apply-templates select="$notmod[1]" mode="java"/>
  446. </xsl:if>
  447. <xsl:apply-templates select="methodname" mode="java"/>
  448. </xsl:variable>
  449. <fo:block wrap-option='no-wrap'
  450. white-space-collapse='false'
  451. linefeed-treatment="preserve"
  452. xsl:use-attribute-sets="monospace.verbatim.properties">
  453. <xsl:copy-of select="$decl"/>
  454. <xsl:text>(</xsl:text>
  455. <xsl:apply-templates select="methodparam" mode="java">
  456. <xsl:with-param name="indent" select="string-length($decl)"/>
  457. </xsl:apply-templates>
  458. <xsl:text>)</xsl:text>
  459. <xsl:if test="exceptionname">
  460. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;throws&nbsp;</xsl:text>
  461. <xsl:apply-templates select="exceptionname" mode="java"/>
  462. </xsl:if>
  463. <xsl:if test="modifier[preceding-sibling::*[local-name(.) != 'modifier']]">
  464. <xsl:text> </xsl:text>
  465. <xsl:apply-templates select="$end-modifiers" mode="java"/>
  466. </xsl:if>
  467. <xsl:text>;</xsl:text>
  468. </fo:block>
  469. <xsl:call-template name="synop-break"/>
  470. </xsl:template>
  471. <!-- ===== C++ ========================================================= -->
  472. <xsl:template match="classsynopsis" mode="cpp">
  473. <fo:block wrap-option='no-wrap'
  474. white-space-collapse='false'
  475. linefeed-treatment="preserve"
  476. xsl:use-attribute-sets="monospace.verbatim.properties">
  477. <xsl:apply-templates select="ooclass[1]" mode="cpp"/>
  478. <xsl:if test="ooclass[preceding-sibling::*]">
  479. <xsl:text>: </xsl:text>
  480. <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="cpp"/>
  481. <xsl:if test="oointerface|ooexception">
  482. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  483. </xsl:if>
  484. </xsl:if>
  485. <xsl:if test="oointerface">
  486. <xsl:text> implements</xsl:text>
  487. <xsl:apply-templates select="oointerface" mode="cpp"/>
  488. <xsl:if test="ooexception">
  489. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  490. </xsl:if>
  491. </xsl:if>
  492. <xsl:if test="ooexception">
  493. <xsl:text> throws</xsl:text>
  494. <xsl:apply-templates select="ooexception" mode="cpp"/>
  495. </xsl:if>
  496. <xsl:text>&nbsp;{&RE;</xsl:text>
  497. <xsl:apply-templates select="constructorsynopsis
  498. |destructorsynopsis
  499. |fieldsynopsis
  500. |methodsynopsis
  501. |classsynopsisinfo" mode="cpp"/>
  502. <xsl:text>}</xsl:text>
  503. </fo:block>
  504. </xsl:template>
  505. <xsl:template match="classsynopsisinfo" mode="cpp">
  506. <xsl:apply-templates mode="cpp"/>
  507. </xsl:template>
  508. <xsl:template match="ooclass|oointerface|ooexception" mode="cpp">
  509. <xsl:if test="preceding-sibling::*">
  510. <xsl:text>, </xsl:text>
  511. </xsl:if>
  512. <xsl:apply-templates mode="cpp"/>
  513. </xsl:template>
  514. <xsl:template match="modifier|package" mode="cpp">
  515. <xsl:apply-templates mode="cpp"/>
  516. <xsl:if test="following-sibling::*">
  517. <xsl:text>&nbsp;</xsl:text>
  518. </xsl:if>
  519. </xsl:template>
  520. <xsl:template match="classname" mode="cpp">
  521. <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
  522. <xsl:text>, </xsl:text>
  523. </xsl:if>
  524. <xsl:apply-templates mode="cpp"/>
  525. </xsl:template>
  526. <xsl:template match="interfacename" mode="cpp">
  527. <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
  528. <xsl:text>, </xsl:text>
  529. </xsl:if>
  530. <xsl:apply-templates mode="cpp"/>
  531. </xsl:template>
  532. <xsl:template match="exceptionname" mode="cpp">
  533. <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
  534. <xsl:text>, </xsl:text>
  535. </xsl:if>
  536. <xsl:apply-templates mode="cpp"/>
  537. </xsl:template>
  538. <xsl:template match="fieldsynopsis" mode="cpp">
  539. <fo:block wrap-option='no-wrap'
  540. white-space-collapse='false'
  541. linefeed-treatment="preserve"
  542. xsl:use-attribute-sets="monospace.verbatim.properties">
  543. <xsl:text>&nbsp;&nbsp;</xsl:text>
  544. <xsl:apply-templates mode="cpp"/>
  545. <xsl:text>;</xsl:text>
  546. </fo:block>
  547. <xsl:call-template name="synop-break"/>
  548. </xsl:template>
  549. <xsl:template match="type" mode="cpp">
  550. <xsl:apply-templates mode="cpp"/>
  551. <xsl:text>&nbsp;</xsl:text>
  552. </xsl:template>
  553. <xsl:template match="varname" mode="cpp">
  554. <xsl:apply-templates mode="cpp"/>
  555. <xsl:text>&nbsp;</xsl:text>
  556. </xsl:template>
  557. <xsl:template match="initializer" mode="cpp">
  558. <xsl:text>=&nbsp;</xsl:text>
  559. <xsl:apply-templates mode="cpp"/>
  560. </xsl:template>
  561. <xsl:template match="void" mode="cpp">
  562. <xsl:text>void&nbsp;</xsl:text>
  563. </xsl:template>
  564. <xsl:template match="methodname" mode="cpp">
  565. <xsl:apply-templates mode="cpp"/>
  566. </xsl:template>
  567. <xsl:template match="methodparam" mode="cpp">
  568. <xsl:if test="preceding-sibling::methodparam">
  569. <xsl:text>, </xsl:text>
  570. </xsl:if>
  571. <xsl:apply-templates mode="cpp"/>
  572. </xsl:template>
  573. <xsl:template match="parameter" mode="cpp">
  574. <xsl:apply-templates mode="cpp"/>
  575. </xsl:template>
  576. <xsl:template mode="cpp"
  577. match="constructorsynopsis|destructorsynopsis|methodsynopsis">
  578. <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
  579. <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
  580. <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
  581. <fo:block wrap-option='no-wrap'
  582. white-space-collapse='false'
  583. linefeed-treatment="preserve"
  584. xsl:use-attribute-sets="monospace.verbatim.properties">
  585. <xsl:text> </xsl:text>
  586. <xsl:apply-templates select="$start-modifiers" mode="cpp"/>
  587. <!-- type -->
  588. <xsl:if test="local-name($notmod[1]) != 'methodname'">
  589. <xsl:apply-templates select="$notmod[1]" mode="cpp"/>
  590. </xsl:if>
  591. <xsl:apply-templates select="methodname" mode="cpp"/>
  592. <xsl:text>(</xsl:text>
  593. <xsl:apply-templates select="methodparam" mode="cpp"/>
  594. <xsl:text>)</xsl:text>
  595. <xsl:if test="exceptionname">
  596. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;throws&nbsp;</xsl:text>
  597. <xsl:apply-templates select="exceptionname" mode="cpp"/>
  598. </xsl:if>
  599. <xsl:if test="modifier[preceding-sibling::*[local-name(.) != 'modifier']]">
  600. <xsl:text> </xsl:text>
  601. <xsl:apply-templates select="$end-modifiers" mode="cpp"/>
  602. </xsl:if>
  603. <xsl:text>;</xsl:text>
  604. </fo:block>
  605. <xsl:call-template name="synop-break"/>
  606. </xsl:template>
  607. <!-- ===== IDL ========================================================= -->
  608. <xsl:template match="classsynopsis" mode="idl">
  609. <fo:block wrap-option='no-wrap'
  610. white-space-collapse='false'
  611. linefeed-treatment="preserve"
  612. xsl:use-attribute-sets="monospace.verbatim.properties">
  613. <xsl:text>interface </xsl:text>
  614. <xsl:apply-templates select="ooclass[1]" mode="idl"/>
  615. <xsl:if test="ooclass[preceding-sibling::*]">
  616. <xsl:text>: </xsl:text>
  617. <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="idl"/>
  618. <xsl:if test="oointerface|ooexception">
  619. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  620. </xsl:if>
  621. </xsl:if>
  622. <xsl:if test="oointerface">
  623. <xsl:text> implements</xsl:text>
  624. <xsl:apply-templates select="oointerface" mode="idl"/>
  625. <xsl:if test="ooexception">
  626. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  627. </xsl:if>
  628. </xsl:if>
  629. <xsl:if test="ooexception">
  630. <xsl:text> throws</xsl:text>
  631. <xsl:apply-templates select="ooexception" mode="idl"/>
  632. </xsl:if>
  633. <xsl:text>&nbsp;{&RE;</xsl:text>
  634. <xsl:apply-templates select="constructorsynopsis
  635. |destructorsynopsis
  636. |fieldsynopsis
  637. |methodsynopsis
  638. |classsynopsisinfo" mode="idl"/>
  639. <xsl:text>}</xsl:text>
  640. </fo:block>
  641. </xsl:template>
  642. <xsl:template match="classsynopsisinfo" mode="idl">
  643. <xsl:apply-templates mode="idl"/>
  644. </xsl:template>
  645. <xsl:template match="ooclass|oointerface|ooexception" mode="idl">
  646. <xsl:if test="preceding-sibling::*">
  647. <xsl:text>, </xsl:text>
  648. </xsl:if>
  649. <xsl:apply-templates mode="idl"/>
  650. </xsl:template>
  651. <xsl:template match="modifier|package" mode="idl">
  652. <xsl:apply-templates mode="idl"/>
  653. <xsl:if test="following-sibling::*">
  654. <xsl:text>&nbsp;</xsl:text>
  655. </xsl:if>
  656. </xsl:template>
  657. <xsl:template match="classname" mode="idl">
  658. <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
  659. <xsl:text>, </xsl:text>
  660. </xsl:if>
  661. <xsl:apply-templates mode="idl"/>
  662. </xsl:template>
  663. <xsl:template match="interfacename" mode="idl">
  664. <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
  665. <xsl:text>, </xsl:text>
  666. </xsl:if>
  667. <xsl:apply-templates mode="idl"/>
  668. </xsl:template>
  669. <xsl:template match="exceptionname" mode="idl">
  670. <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
  671. <xsl:text>, </xsl:text>
  672. </xsl:if>
  673. <xsl:apply-templates mode="idl"/>
  674. </xsl:template>
  675. <xsl:template match="fieldsynopsis" mode="idl">
  676. <fo:block wrap-option='no-wrap'
  677. white-space-collapse='false'
  678. linefeed-treatment="preserve"
  679. xsl:use-attribute-sets="monospace.verbatim.properties">
  680. <xsl:text>&nbsp;&nbsp;</xsl:text>
  681. <xsl:apply-templates mode="idl"/>
  682. <xsl:text>;</xsl:text>
  683. </fo:block>
  684. <xsl:call-template name="synop-break"/>
  685. </xsl:template>
  686. <xsl:template match="type" mode="idl">
  687. <xsl:apply-templates mode="idl"/>
  688. <xsl:text>&nbsp;</xsl:text>
  689. </xsl:template>
  690. <xsl:template match="varname" mode="idl">
  691. <xsl:apply-templates mode="idl"/>
  692. <xsl:text>&nbsp;</xsl:text>
  693. </xsl:template>
  694. <xsl:template match="initializer" mode="idl">
  695. <xsl:text>=&nbsp;</xsl:text>
  696. <xsl:apply-templates mode="idl"/>
  697. </xsl:template>
  698. <xsl:template match="void" mode="idl">
  699. <xsl:text>void&nbsp;</xsl:text>
  700. </xsl:template>
  701. <xsl:template match="methodname" mode="idl">
  702. <xsl:apply-templates mode="idl"/>
  703. </xsl:template>
  704. <xsl:template match="methodparam" mode="idl">
  705. <xsl:if test="preceding-sibling::methodparam">
  706. <xsl:text>, </xsl:text>
  707. </xsl:if>
  708. <xsl:apply-templates mode="idl"/>
  709. </xsl:template>
  710. <xsl:template match="parameter" mode="idl">
  711. <xsl:apply-templates mode="idl"/>
  712. </xsl:template>
  713. <xsl:template mode="idl"
  714. match="constructorsynopsis|destructorsynopsis|methodsynopsis">
  715. <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
  716. <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
  717. <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
  718. <fo:block wrap-option='no-wrap'
  719. white-space-collapse='false'
  720. linefeed-treatment="preserve"
  721. xsl:use-attribute-sets="monospace.verbatim.properties">
  722. <xsl:text> </xsl:text>
  723. <xsl:apply-templates select="$start-modifiers" mode="idl"/>
  724. <!-- type -->
  725. <xsl:if test="local-name($notmod[1]) != 'methodname'">
  726. <xsl:apply-templates select="$notmod[1]" mode="idl"/>
  727. </xsl:if>
  728. <xsl:apply-templates select="methodname" mode="idl"/>
  729. <xsl:text>(</xsl:text>
  730. <xsl:apply-templates select="methodparam" mode="idl"/>
  731. <xsl:text>)</xsl:text>
  732. <xsl:if test="exceptionname">
  733. <xsl:text>&RE;&nbsp;&nbsp;&nbsp;&nbsp;raises(</xsl:text>
  734. <xsl:apply-templates select="exceptionname" mode="idl"/>
  735. <xsl:text>)</xsl:text>
  736. </xsl:if>
  737. <xsl:if test="modifier[preceding-sibling::*[local-name(.) != 'modifier']]">
  738. <xsl:text> </xsl:text>
  739. <xsl:apply-templates select="$end-modifiers" mode="idl"/>
  740. </xsl:if>
  741. <xsl:text>;</xsl:text>
  742. </fo:block>
  743. <xsl:call-template name="synop-break"/>
  744. </xsl:template>
  745. <!-- ===== Perl ======================================================== -->
  746. <xsl:template match="classsynopsis" mode="perl">
  747. <fo:block wrap-option='no-wrap'
  748. white-space-collapse='false'
  749. linefeed-treatment="preserve"
  750. xsl:use-attribute-sets="monospace.verbatim.properties">
  751. <xsl:text>package </xsl:text>
  752. <xsl:apply-templates select="ooclass[1]" mode="perl"/>
  753. <xsl:text>;&RE;</xsl:text>
  754. <xsl:if test="ooclass[preceding-sibling::*]">
  755. <xsl:text>@ISA = (</xsl:text>
  756. <xsl:apply-templates select="ooclass[preceding-sibling::*]" mode="perl"/>
  757. <xsl:text>);&RE;</xsl:text>
  758. </xsl:if>
  759. <xsl:apply-templates select="constructorsynopsis
  760. |destructorsynopsis
  761. |fieldsynopsis
  762. |methodsynopsis
  763. |classsynopsisinfo" mode="perl"/>
  764. </fo:block>
  765. </xsl:template>
  766. <xsl:template match="classsynopsisinfo" mode="perl">
  767. <xsl:apply-templates mode="perl"/>
  768. </xsl:template>
  769. <xsl:template match="ooclass|oointerface|ooexception" mode="perl">
  770. <xsl:if test="preceding-sibling::*">
  771. <xsl:text>, </xsl:text>
  772. </xsl:if>
  773. <xsl:apply-templates mode="perl"/>
  774. </xsl:template>
  775. <xsl:template match="modifier|package" mode="perl">
  776. <xsl:apply-templates mode="perl"/>
  777. <xsl:if test="following-sibling::*">
  778. <xsl:text>&nbsp;</xsl:text>
  779. </xsl:if>
  780. </xsl:template>
  781. <xsl:template match="classname" mode="perl">
  782. <xsl:if test="local-name(preceding-sibling::*[1]) = 'classname'">
  783. <xsl:text>, </xsl:text>
  784. </xsl:if>
  785. <xsl:apply-templates mode="perl"/>
  786. </xsl:template>
  787. <xsl:template match="interfacename" mode="perl">
  788. <xsl:if test="local-name(preceding-sibling::*[1]) = 'interfacename'">
  789. <xsl:text>, </xsl:text>
  790. </xsl:if>
  791. <xsl:apply-templates mode="perl"/>
  792. </xsl:template>
  793. <xsl:template match="exceptionname" mode="perl">
  794. <xsl:if test="local-name(preceding-sibling::*[1]) = 'exceptionname'">
  795. <xsl:text>, </xsl:text>
  796. </xsl:if>
  797. <xsl:apply-templates mode="perl"/>
  798. </xsl:template>
  799. <xsl:template match="fieldsynopsis" mode="perl">
  800. <fo:block wrap-option='no-wrap'
  801. white-space-collapse='false'
  802. linefeed-treatment="preserve"
  803. xsl:use-attribute-sets="monospace.verbatim.properties">
  804. <xsl:text>&nbsp;&nbsp;</xsl:text>
  805. <xsl:apply-templates mode="perl"/>
  806. <xsl:text>;</xsl:text>
  807. </fo:block>
  808. <xsl:call-template name="synop-break"/>
  809. </xsl:template>
  810. <xsl:template match="type" mode="perl">
  811. <xsl:apply-templates mode="perl"/>
  812. <xsl:text>&nbsp;</xsl:text>
  813. </xsl:template>
  814. <xsl:template match="varname" mode="perl">
  815. <xsl:apply-templates mode="perl"/>
  816. <xsl:text>&nbsp;</xsl:text>
  817. </xsl:template>
  818. <xsl:template match="initializer" mode="perl">
  819. <xsl:text>=&nbsp;</xsl:text>
  820. <xsl:apply-templates mode="perl"/>
  821. </xsl:template>
  822. <xsl:template match="void" mode="perl">
  823. <xsl:text>void&nbsp;</xsl:text>
  824. </xsl:template>
  825. <xsl:template match="methodname" mode="perl">
  826. <xsl:apply-templates mode="perl"/>
  827. </xsl:template>
  828. <xsl:template match="methodparam" mode="perl">
  829. <xsl:if test="preceding-sibling::methodparam">
  830. <xsl:text>, </xsl:text>
  831. </xsl:if>
  832. <xsl:apply-templates mode="perl"/>
  833. </xsl:template>
  834. <xsl:template match="parameter" mode="perl">
  835. <xsl:apply-templates mode="perl"/>
  836. </xsl:template>
  837. <xsl:template mode="perl"
  838. match="constructorsynopsis|destructorsynopsis|methodsynopsis">
  839. <xsl:variable name="start-modifiers" select="modifier[following-sibling::*[local-name(.) != 'modifier']]"/>
  840. <xsl:variable name="notmod" select="*[local-name(.) != 'modifier']"/>
  841. <xsl:variable name="end-modifiers" select="modifier[preceding-sibling::*[local-name(.) != 'modifier']]"/>
  842. <fo:block wrap-option='no-wrap'
  843. white-space-collapse='false'
  844. linefeed-treatment="preserve"
  845. xsl:use-attribute-sets="monospace.verbatim.properties">
  846. <xsl:text>sub </xsl:text>
  847. <xsl:apply-templates select="methodname" mode="perl"/>
  848. <xsl:text> { ... };</xsl:text>
  849. <xsl:call-template name="synop-break"/>
  850. </fo:block>
  851. </xsl:template>
  852. <!-- Used when not occurring as a child of classsynopsis -->
  853. <xsl:template match="ooclass|oointerface|ooexception">
  854. <xsl:apply-templates/>
  855. </xsl:template>
  856. <!-- ==================================================================== -->
  857. <!-- * DocBook 5 allows linking elements (link, olink, and xref) -->
  858. <!-- * within the OO *synopsis elements (classsynopsis, fieldsynopsis, -->
  859. <!-- * methodsynopsis, constructorsynopsis, destructorsynopsis) and -->
  860. <!-- * their children. So we need to have mode="java|cpp|idl|perl" -->
  861. <!-- * per-mode matches for those linking elements in order for them -->
  862. <!-- * to be processed as expected. -->
  863. <xsl:template match="link|olink|xref" mode="java">
  864. <xsl:apply-templates select="."/>
  865. </xsl:template>
  866. <xsl:template match="link|olink|xref" mode="cpp">
  867. <xsl:apply-templates select="."/>
  868. </xsl:template>
  869. <xsl:template match="link|olink|xref" mode="idl">
  870. <xsl:apply-templates select="."/>
  871. </xsl:template>
  872. <xsl:template match="link|olink|xref" mode="perl">
  873. <xsl:apply-templates select="."/>
  874. </xsl:template>
  875. </xsl:stylesheet>