You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

synop.xsl 27KB

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