topic2db.xsl 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!-- This file is part of the DITA Open Toolkit project hosted on
  3. Sourceforge.net. See the accompanying license.txt file for
  4. applicable licenses.-->
  5. <!-- (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved. -->
  6. <xsl:stylesheet version="2.0"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  8. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  9. - TOPIC ORGANIZATION
  10. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  11. <xsl:template match="*[contains(@class,' topic/topic ')]">
  12. <xsl:param name="childrefs"/>
  13. <xsl:param name="element" select="'section'"/>
  14. <xsl:element name="{$element}">
  15. <xsl:call-template name="setStandardAttr">
  16. <xsl:with-param name="IDPrefix" select="'tpc'"/>
  17. </xsl:call-template>
  18. <xsl:apply-templates select="*[contains(@class,' topic/prolog ')]">
  19. <xsl:with-param name="contextType" select="$element"/>
  20. </xsl:apply-templates>
  21. <xsl:apply-templates select="*[not(contains(@class,' topic/prolog '))]"/>
  22. <xsl:if test="$childrefs">
  23. <xsl:apply-templates select="$childrefs"/>
  24. </xsl:if>
  25. </xsl:element>
  26. </xsl:template>
  27. <xsl:template match="*[contains(@class,' topic/title ')]">
  28. <xsl:param name="element" select="'title'"/>
  29. <xsl:param name="IDPrefix" select="'ttl'"/>
  30. <xsl:element name="{$element}">
  31. <xsl:call-template name="setStandardAttr">
  32. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  33. </xsl:call-template>
  34. <xsl:apply-templates/>
  35. </xsl:element>
  36. </xsl:template>
  37. <xsl:template match="*[contains(@class,' topic/titlealts ')]">
  38. <xsl:apply-templates select="*[contains(@class,' topic/searchtitle ')]"/>
  39. <xsl:apply-templates select="*[contains(@class,' topic/navtitle ')]"/>
  40. </xsl:template>
  41. <xsl:template match="*[contains(@class,' topic/navtitle ')]">
  42. <xsl:param name="element" select="'titleabbrev'"/>
  43. <xsl:param name="IDPrefix" select="'ttlabbrv'"/>
  44. <xsl:element name="{$element}">
  45. <xsl:call-template name="setStandardAttr">
  46. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  47. </xsl:call-template>
  48. <xsl:apply-templates/>
  49. </xsl:element>
  50. </xsl:template>
  51. <xsl:template match="*[contains(@class,' topic/searchtitle ')]">
  52. <xsl:param name="element" select="'subtitle'"/>
  53. <xsl:param name="IDPrefix" select="'sbttl'"/>
  54. <xsl:element name="{$element}">
  55. <xsl:call-template name="setStandardAttr">
  56. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  57. </xsl:call-template>
  58. <xsl:apply-templates/>
  59. </xsl:element>
  60. </xsl:template>
  61. <!-- Added for DITA 1.1 "Shortdesc proposal" -->
  62. <xsl:template match="*[contains(@class,' topic/abstract ')]" mode="abstract">
  63. <abstract>
  64. <xsl:call-template name="makePara">
  65. <xsl:with-param name="IDPrefix" select="'shrtdsc'"/>
  66. </xsl:call-template>
  67. </abstract>
  68. </xsl:template>
  69. <!-- Added for DITA 1.1 "Shortdesc proposal" -->
  70. <xsl:template match="*[contains(@class,' topic/abstract ')]">
  71. <xsl:call-template name="makePara">
  72. <xsl:with-param name="IDPrefix" select="'para'"/>
  73. </xsl:call-template>
  74. </xsl:template>
  75. <xsl:template match="*[contains(@class,' topic/shortdesc ')]" mode="abstract">
  76. <abstract>
  77. <xsl:call-template name="makePara">
  78. <xsl:with-param name="IDPrefix" select="'shrtdsc'"/>
  79. </xsl:call-template>
  80. </abstract>
  81. </xsl:template>
  82. <xsl:template match="*[contains(@class,' topic/shortdesc ')]">
  83. <xsl:call-template name="makePara">
  84. <xsl:with-param name="IDPrefix" select="'para'"/>
  85. </xsl:call-template>
  86. </xsl:template>
  87. <xsl:template match="*[contains(@class,' topic/body ')]">
  88. <xsl:apply-templates select="." mode="deflate">
  89. <xsl:with-param name="descendentsOkay" select="true()"/>
  90. </xsl:apply-templates>
  91. </xsl:template>
  92. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  93. - META INFORMATION
  94. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  95. <xsl:template match="*[contains(@class,' topic/prolog ')]">
  96. <xsl:param name="contextType" select="'section'"/>
  97. <xsl:variable name="shortDescNode"
  98. select="../*[contains(@class,' topic/shortdesc ') or contains(@class, ' topic/abstract ')]"/>
  99. <xsl:variable name="prologNodes" select="*"/>
  100. <xsl:if test="$shortDescNode or $prologNodes">
  101. <xsl:variable name="elementName">
  102. <xsl:choose>
  103. <xsl:when test="$contextType='article'">artheader</xsl:when>
  104. <xsl:when test="$contextType='appendix'">docinfo</xsl:when>
  105. <xsl:when test="$contextType='book'">bookinfo</xsl:when>
  106. <xsl:when test="$contextType='chapter'">chapterinfo</xsl:when>
  107. <xsl:when test="$contextType='glossary'">docinfo</xsl:when>
  108. <xsl:when test="$contextType='part'">docinfo</xsl:when>
  109. <xsl:when test="$contextType='section'">sectioninfo</xsl:when>
  110. <xsl:otherwise>
  111. <xsl:message>
  112. <xsl:text>Unknown context type </xsl:text>
  113. <xsl:value-of select="$contextType"/>
  114. </xsl:message>
  115. <xsl:text>sectioninfo</xsl:text>
  116. </xsl:otherwise>
  117. </xsl:choose>
  118. </xsl:variable>
  119. <xsl:element name="{$elementName}">
  120. <xsl:call-template name="setStandardAttr">
  121. <xsl:with-param name="IDPrefix" select="'prlg'"/>
  122. </xsl:call-template>
  123. <xsl:apply-templates select="$shortDescNode" mode="abstract"/>
  124. <xsl:apply-templates select="$prologNodes"/>
  125. </xsl:element>
  126. </xsl:if>
  127. </xsl:template>
  128. <xsl:template match="*[contains(@class,' topic/author ')]">
  129. <author>
  130. <xsl:call-template name="setStandardAttr">
  131. <xsl:with-param name="IDPrefix" select="'athr'"/>
  132. </xsl:call-template>
  133. <othername>
  134. <xsl:apply-templates/>
  135. </othername>
  136. </author>
  137. </xsl:template>
  138. <!-- to do -->
  139. <xsl:template match="*[contains(@class,' topic/source ')]"/>
  140. <xsl:template match="*[contains(@class,' topic/publisher ')]">
  141. <publisher>
  142. <xsl:call-template name="setStandardAttr">
  143. <xsl:with-param name="IDPrefix" select="'pblshr'"/>
  144. </xsl:call-template>
  145. <!-- dhjohnso: publisher must be inside publishername -->
  146. <publishername>
  147. <xsl:apply-templates/>
  148. </publishername>
  149. </publisher>
  150. </xsl:template>
  151. <xsl:template match="*[contains(@class,' topic/copyright ')]">
  152. <copyright>
  153. <xsl:call-template name="setStandardAttr">
  154. <xsl:with-param name="IDPrefix" select="'cprght'"/>
  155. </xsl:call-template>
  156. <xsl:apply-templates/>
  157. </copyright>
  158. </xsl:template>
  159. <xsl:template match="*[contains(@class,' topic/copyrdate ')]">
  160. <year>
  161. <xsl:call-template name="setStandardAttr">
  162. <xsl:with-param name="IDPrefix" select="'cprdt'"/>
  163. </xsl:call-template>
  164. <xsl:apply-templates/>
  165. </year>
  166. </xsl:template>
  167. <xsl:template match="*[contains(@class,' topic/copyrholder ')]">
  168. <holder>
  169. <xsl:call-template name="setStandardAttr">
  170. <xsl:with-param name="IDPrefix" select="'cprhldr'"/>
  171. </xsl:call-template>
  172. <xsl:apply-templates/>
  173. </holder>
  174. </xsl:template>
  175. <!-- dhjohnso: template added for missing year element -->
  176. <xsl:template match="*[contains(@class,' topic/copyryear ')]">
  177. <year>
  178. <xsl:call-template name="setStandardAttr">
  179. <xsl:with-param name="IDPrefix" select="'cpryear'"/>
  180. </xsl:call-template>
  181. <xsl:value-of select="@year" />
  182. </year>
  183. </xsl:template>
  184. <xsl:template match="*[contains(@class,' topic/critdates ')]">
  185. <revhistory>
  186. <xsl:call-template name="setStandardAttr">
  187. <xsl:with-param name="IDPrefix" select="'crtdts'"/>
  188. </xsl:call-template>
  189. <xsl:apply-templates/>
  190. </revhistory>
  191. </xsl:template>
  192. <xsl:template match="*[contains(@class,' topic/created ')]">
  193. <xsl:apply-templates select="@date|@expiry|@golive"/>
  194. </xsl:template>
  195. <xsl:template match="*[contains(@class,' topic/revised ')]">
  196. <xsl:apply-templates select="@expiry|@golive|@modified"/>
  197. </xsl:template>
  198. <xsl:template match="*[contains(@class,' topic/created ')]/@date |
  199. *[contains(@class,' topic/created ')]/@expiry |
  200. *[contains(@class,' topic/created ')]/@golive |
  201. *[contains(@class,' topic/revised ')]/@expiry |
  202. *[contains(@class,' topic/revised ')]/@golive |
  203. *[contains(@class,' topic/revised ')]/@modified">
  204. <revision>
  205. <revnumber/>
  206. <date>
  207. <xsl:value-of select="../@date"/>
  208. </date>
  209. <revremark>
  210. <xsl:choose>
  211. <xsl:when test="parent::*[contains(@class,' topic/created ')] and
  212. local-name(.)='date'">
  213. <xsl:text>created</xsl:text>
  214. </xsl:when>
  215. <xsl:otherwise>
  216. <xsl:value-of select="local-name(.)"/>
  217. </xsl:otherwise>
  218. </xsl:choose>
  219. </revremark>
  220. </revision>
  221. </xsl:template>
  222. <!-- to do -->
  223. <xsl:template match="*[contains(@class,' topic/permissions ')]"/>
  224. <xsl:template match="*[contains(@class,' topic/metadata ')]">
  225. <xsl:variable name="categoryNodes"
  226. select="*[contains(@class,' topic/category ')]"/>
  227. <xsl:if test="$categoryNodes">
  228. <subjectset>
  229. <xsl:apply-templates select="$categoryNodes" mode="metadata"/>
  230. </subjectset>
  231. </xsl:if>
  232. <xsl:apply-templates select="." mode="deflate">
  233. <xsl:with-param name="descendentsOkay" select="true()"/>
  234. </xsl:apply-templates>
  235. </xsl:template>
  236. <!-- to do -->
  237. <xsl:template match="*[contains(@class,' topic/audience ')]"/>
  238. <xsl:template match="*[contains(@class,' topic/category ')]"/>
  239. <xsl:template match="*[contains(@class,' topic/category ')]" mode="metadata">
  240. <subject>
  241. <subjectterm>
  242. <xsl:call-template name="setStandardAttr">
  243. <xsl:with-param name="IDPrefix" select="'ctgry'"/>
  244. </xsl:call-template>
  245. <xsl:apply-templates/>
  246. </subjectterm>
  247. </subject>
  248. </xsl:template>
  249. <xsl:template match="*[contains(@class,' topic/keywords ')]">
  250. <xsl:variable name="keywordNodes"
  251. select="*[contains(@class,' topic/keyword ')]"/>
  252. <xsl:variable name="indextermNodes"
  253. select="*[contains(@class,' topic/indexterm ')]"/>
  254. <xsl:if test="$keywordNodes">
  255. <keywordset>
  256. <xsl:apply-templates select="$keywordNodes" mode="metadata"/>
  257. </keywordset>
  258. </xsl:if>
  259. <xsl:if test="$indextermNodes">
  260. <itermset>
  261. <xsl:apply-templates select="$indextermNodes"/>
  262. </itermset>
  263. </xsl:if>
  264. </xsl:template>
  265. <xsl:template match="*[contains(@class,' topic/keyword ')]" mode="metadata">
  266. <keyword>
  267. <xsl:call-template name="setStandardAttr">
  268. <xsl:with-param name="IDPrefix" select="'kywrd'"/>
  269. </xsl:call-template>
  270. <xsl:value-of select="."/>
  271. </keyword>
  272. </xsl:template>
  273. <xsl:template match="*[contains(@class,' topic/prodinfo ')]">
  274. <xsl:apply-templates select="." mode="deflate">
  275. <xsl:with-param name="descendentsOkay" select="true()"/>
  276. </xsl:apply-templates>
  277. </xsl:template>
  278. <xsl:template match="*[contains(@class,' topic/prodname ')]">
  279. <productname>
  280. <xsl:call-template name="setStandardAttr">
  281. <xsl:with-param name="IDPrefix" select="'prdnm'"/>
  282. </xsl:call-template>
  283. <xsl:apply-templates/>
  284. </productname>
  285. </xsl:template>
  286. <xsl:template match="*[contains(@class,' topic/vrmlist ')]">
  287. <xsl:apply-templates select="." mode="deflate">
  288. <xsl:with-param name="descendentsOkay" select="true()"/>
  289. </xsl:apply-templates>
  290. </xsl:template>
  291. <xsl:template match="*[contains(@class,' topic/vrm ')]">
  292. <productnumber>
  293. <xsl:call-template name="setStandardAttr">
  294. <xsl:with-param name="IDPrefix" select="'vrm'"/>
  295. </xsl:call-template>
  296. <xsl:apply-templates select="@version"/>
  297. <xsl:if test="@version and @release">
  298. <xsl:text>-</xsl:text>
  299. </xsl:if>
  300. <xsl:apply-templates select="@release"/>
  301. <xsl:if test="(@version or @release) and @modification">
  302. <xsl:text>-</xsl:text>
  303. </xsl:if>
  304. <xsl:apply-templates select="@modification"/>
  305. </productnumber>
  306. </xsl:template>
  307. <!-- to do -->
  308. <xsl:template match="*[contains(@class,' topic/brand ')]"/>
  309. <xsl:template match="*[contains(@class,' topic/series ')]"/>
  310. <xsl:template match="*[contains(@class,' topic/platform ')]"/>
  311. <xsl:template match="*[contains(@class,' topic/prognum ')]"/>
  312. <xsl:template match="*[contains(@class,' topic/featnum ')]"/>
  313. <xsl:template match="*[contains(@class,' topic/component ')]"/>
  314. <!-- to do -->
  315. <xsl:template match="*[contains(@class,' topic/othermeta ')]"/>
  316. <!-- to do -->
  317. <xsl:template match="*[contains(@class,' topic/resourceid ')]"/>
  318. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  319. - RELATIONSHIPS
  320. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  321. <xsl:template match="*[contains(@class,' topic/related-links ')]">
  322. <itemizedlist>
  323. <title>Related links</title>
  324. <xsl:apply-templates/>
  325. </itemizedlist>
  326. </xsl:template>
  327. <xsl:template match="*[contains(@class,' topic/linkpool ')]">
  328. <xsl:apply-templates/>
  329. </xsl:template>
  330. <!-- ??? should handle title and linkinfo and desc -->
  331. <xsl:template match="*[contains(@class,' topic/linklist ')]">
  332. <xsl:apply-templates select="*[contains(@class,' topic/desc ')]"/>
  333. <listitem>
  334. <itemizedlist>
  335. <xsl:apply-templates select="*[contains(@class,' topic/linklist ') or
  336. contains(@class,' topic/link ')]"/>
  337. </itemizedlist>
  338. <xsl:apply-templates select="*[contains(@class,' topic/linkinfo ')]"/>
  339. </listitem>
  340. </xsl:template>
  341. <xsl:template match="*[contains(@class,' topic/link ')]">
  342. <listitem>
  343. <para>
  344. <xsl:choose>
  345. <xsl:when test="(not(@format) or @format='dita') and
  346. (not(@scope) or @scope='local') and
  347. @href and (
  348. substring(@href, string-length(@href) - 4) = '.dita' or
  349. contains(@href,'.dita#') or
  350. substring(@href, string-length(@href) - 3) = '.xml' or
  351. contains(@href,'.xml#'))">
  352. <xsl:apply-templates select="." mode="make-xref-from-link"/>
  353. </xsl:when>
  354. <xsl:when test="((@format and @format != 'dita') or
  355. (@scope and @scope!='local') or
  356. (@href and
  357. substring(@href, string-length(@href) - 4) != '.dita' and
  358. not (contains(@href,'.dita#')) and
  359. substring(@href, string-length(@href) - 3) != '.xml') and
  360. not (contains(@href,'.xml#')))">
  361. <xsl:apply-templates select="." mode="make-ulink-from-link"/>
  362. </xsl:when>
  363. <xsl:otherwise>
  364. <xsl:apply-templates select="." mode="make-ulink-from-link"/>
  365. </xsl:otherwise>
  366. </xsl:choose>
  367. </para>
  368. <xsl:apply-templates select="*[contains(@class,' topic/desc ')]"/>
  369. </listitem>
  370. </xsl:template>
  371. <xsl:template match="*" mode="make-ulink-from-link">
  372. <ulink url="{@href}">
  373. <xsl:apply-templates select="*[contains(@class,' topic/linktext ')]"/>
  374. </ulink>
  375. </xsl:template>
  376. <xsl:template match="*" mode="make-xref-from-link">
  377. <xsl:variable name="linkID">
  378. <xsl:call-template name="getLinkID"/>
  379. </xsl:variable>
  380. <xref linkend="{$linkID}">
  381. <xsl:call-template name="setStandardAttr">
  382. <xsl:with-param name="IDPrefix" select="'xref'"/>
  383. </xsl:call-template>
  384. </xref>
  385. </xsl:template>
  386. <!-- Provided by Erik Hennum and dcramer in SF bug report 1385654.
  387. For use with targets already identified as DITA.
  388. Does not yet support linking to sub-topic elements; all links go to topic. -->
  389. <xsl:template name="getLinkID">
  390. <xsl:param name="href" select="@href"/>
  391. <xsl:variable name="hasID" select="contains($href,'#')"/>
  392. <xsl:choose>
  393. <xsl:when test="contains($href,'#') and contains(substring-after($href,'#'),'/')">
  394. <xsl:value-of select="substring-before(substring-after(@href,'#'),'/')"/>
  395. </xsl:when>
  396. <xsl:when test="contains($href,'#')">
  397. <xsl:value-of select="substring-after(@href,'#')"/>
  398. </xsl:when>
  399. <xsl:otherwise>
  400. <xsl:value-of
  401. select="document($href, /)/*[contains(@class,' topic/topic ')]/@id"/>
  402. </xsl:otherwise>
  403. </xsl:choose>
  404. </xsl:template>
  405. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  406. - SECTIONS
  407. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  408. <xsl:template match="*[contains(@class,' topic/section ')]">
  409. <xsl:call-template name="makeBlockCont">
  410. <xsl:with-param name="IDPrefix" select="'sctn'"/>
  411. </xsl:call-template>
  412. </xsl:template>
  413. <xsl:template match="*[contains(@class,' topic/example ')]">
  414. <xsl:choose>
  415. <xsl:when test="title">
  416. <example>
  417. <xsl:call-template name="setStandardAttr">
  418. <xsl:with-param name="IDPrefix" select="'xmp'"/>
  419. </xsl:call-template>
  420. <xsl:apply-templates/>
  421. </example>
  422. </xsl:when>
  423. <xsl:otherwise>
  424. <informalexample>
  425. <xsl:call-template name="setStandardAttr">
  426. <xsl:with-param name="IDPrefix" select="'xmp'"/>
  427. </xsl:call-template>
  428. <xsl:apply-templates/>
  429. </informalexample>
  430. </xsl:otherwise>
  431. </xsl:choose>
  432. </xsl:template>
  433. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  434. - LISTS
  435. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  436. <xsl:template match="*[contains(@class,' topic/ul ')]">
  437. <itemizedlist>
  438. <xsl:call-template name="setStandardAttr">
  439. <xsl:with-param name="IDPrefix" select="'ul'"/>
  440. </xsl:call-template>
  441. <xsl:apply-templates select="@compact" mode="deflate"/>
  442. <xsl:apply-templates/>
  443. </itemizedlist>
  444. </xsl:template>
  445. <xsl:template match="*[contains(@class,' topic/ol ')]">
  446. <orderedlist>
  447. <xsl:call-template name="setStandardAttr">
  448. <xsl:with-param name="IDPrefix" select="'ol'"/>
  449. </xsl:call-template>
  450. <xsl:apply-templates select="@compact" mode="deflate"/>
  451. <xsl:apply-templates/>
  452. </orderedlist>
  453. </xsl:template>
  454. <xsl:template match="*[contains(@class,' topic/li ')]">
  455. <listitem>
  456. <xsl:call-template name="setStandardAttr">
  457. <xsl:with-param name="IDPrefix" select="'li'"/>
  458. </xsl:call-template>
  459. <xsl:call-template name="makeBlock"/>
  460. </listitem>
  461. </xsl:template>
  462. <xsl:template match="*[contains(@class,' topic/itemgroup ')]">
  463. <xsl:variable name="element" select="local-name(.)" />
  464. <xsl:variable name="id" select="concat('elem', generate-id())" />
  465. <xsl:call-template name="deflateElementStart">
  466. <xsl:with-param name="id" select="$id" />
  467. <xsl:with-param name="element" select="$element" />
  468. <xsl:with-param name="parentID" select="''" />
  469. </xsl:call-template>
  470. <xsl:call-template name="makeBlock" />
  471. <xsl:call-template name="deflateElementEnd">
  472. <xsl:with-param name="id" select="$id" />
  473. <xsl:with-param name="element" select="$element" />
  474. </xsl:call-template>
  475. </xsl:template>
  476. <xsl:template match="*[contains(@class,' topic/dl ')]">
  477. <variablelist>
  478. <xsl:call-template name="setStandardAttr">
  479. <xsl:with-param name="IDPrefix" select="'dl'"/>
  480. </xsl:call-template>
  481. <xsl:apply-templates select="@compact" mode="deflate"/>
  482. <xsl:if test="@title">
  483. <title>
  484. <xsl:value-of select="@title"/>
  485. </title>
  486. </xsl:if>
  487. <xsl:apply-templates/>
  488. </variablelist>
  489. </xsl:template>
  490. <xsl:template match="*[contains(@class,' topic/dlhead ')]">
  491. <varlistentry>
  492. <xsl:call-template name="setStandardAttr">
  493. <xsl:with-param name="IDPrefix" select="'dlhd'"/>
  494. </xsl:call-template>
  495. <xsl:variable name="dtheads" select="*[contains(@class,' topic/dthd ')]"/>
  496. <xsl:variable name="ddheads" select="*[contains(@class,' topic/ddhd ')]"/>
  497. <xsl:choose>
  498. <xsl:when test="$dtheads">
  499. <xsl:apply-templates select="$dtheads"/>
  500. </xsl:when>
  501. <xsl:otherwise>
  502. <term/>
  503. </xsl:otherwise>
  504. </xsl:choose>
  505. <xsl:choose>
  506. <xsl:when test="$ddheads">
  507. <xsl:apply-templates select="$ddheads"/>
  508. </xsl:when>
  509. <xsl:otherwise>
  510. <listitem/>
  511. </xsl:otherwise>
  512. </xsl:choose>
  513. </varlistentry>
  514. </xsl:template>
  515. <xsl:template match="*[contains(@class,' topic/dthd ')]">
  516. <term>
  517. <xsl:call-template name="setStandardAttr">
  518. <xsl:with-param name="IDPrefix" select="'dthd'"/>
  519. </xsl:call-template>
  520. <xsl:apply-templates/>
  521. </term>
  522. </xsl:template>
  523. <xsl:template match="*[contains(@class,' topic/ddhd ')]">
  524. <listitem>
  525. <xsl:call-template name="setStandardAttr">
  526. <xsl:with-param name="IDPrefix" select="'ddhd'"/>
  527. </xsl:call-template>
  528. <xsl:call-template name="makeBlock"/>
  529. </listitem>
  530. </xsl:template>
  531. <xsl:template match="*[contains(@class,' topic/dlentry ')]">
  532. <varlistentry>
  533. <xsl:call-template name="setStandardAttr">
  534. <xsl:with-param name="IDPrefix" select="'dle'"/>
  535. </xsl:call-template>
  536. <xsl:choose>
  537. <xsl:when test="*[contains(@class,' topic/dd ')][2]">
  538. <xsl:apply-templates select="*[contains(@class,' topic/dt ')]"/>
  539. <listitem>
  540. <xsl:for-each select="*[contains(@class,' topic/dd ')]">
  541. <orderedlist>
  542. <listitem>
  543. <xsl:call-template name="setStandardAttr">
  544. <xsl:with-param name="IDPrefix" select="'dd'"/>
  545. </xsl:call-template>
  546. <xsl:call-template name="makeBlock"/>
  547. </listitem>
  548. </orderedlist>
  549. </xsl:for-each>
  550. </listitem>
  551. </xsl:when>
  552. <xsl:otherwise>
  553. <xsl:apply-templates/>
  554. </xsl:otherwise>
  555. </xsl:choose>
  556. </varlistentry>
  557. </xsl:template>
  558. <xsl:template match="*[contains(@class,' topic/dt ')]">
  559. <term>
  560. <xsl:call-template name="setStandardAttr">
  561. <xsl:with-param name="IDPrefix" select="'dt'"/>
  562. </xsl:call-template>
  563. <xsl:apply-templates/>
  564. </term>
  565. </xsl:template>
  566. <xsl:template match="*[contains(@class,' topic/dd ')]">
  567. <listitem>
  568. <xsl:call-template name="setStandardAttr">
  569. <xsl:with-param name="IDPrefix" select="'dd'"/>
  570. </xsl:call-template>
  571. <xsl:call-template name="makeBlock"/>
  572. </listitem>
  573. </xsl:template>
  574. <xsl:template match="*[contains(@class,' topic/sl ')]">
  575. <simplelist columns="1" type="vert">
  576. <xsl:call-template name="setStandardAttr">
  577. <xsl:with-param name="IDPrefix" select="'sl'"/>
  578. </xsl:call-template>
  579. <xsl:apply-templates select="@compact" mode="deflate"/>
  580. <xsl:apply-templates/>
  581. </simplelist>
  582. </xsl:template>
  583. <xsl:template match="*[contains(@class,' topic/sli ')]">
  584. <member>
  585. <xsl:call-template name="setStandardAttr">
  586. <xsl:with-param name="IDPrefix" select="'sli'"/>
  587. </xsl:call-template>
  588. <xsl:apply-templates/>
  589. </member>
  590. </xsl:template>
  591. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  592. - VERBATIM BLOCKS
  593. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  594. <xsl:template match="*[contains(@class,' topic/pre ')]">
  595. <xsl:call-template name="wrapTitle">
  596. <xsl:with-param name="wrapElem" select="'example'"/>
  597. <xsl:with-param name="coreElem" select="'programlisting'"/>
  598. <xsl:with-param name="IDPrefix" select="'pre'"/>
  599. </xsl:call-template>
  600. </xsl:template>
  601. <xsl:template match="*[contains(@class,' topic/lines ')]">
  602. <xsl:call-template name="wrapLiteralTitle">
  603. <xsl:with-param name="classAttr" select="'normal'"/>
  604. <xsl:with-param name="IDPrefix" select="'lns'"/>
  605. </xsl:call-template>
  606. </xsl:template>
  607. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  608. - FORMATTING BLOCKS
  609. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  610. <xsl:template match="*[contains(@class,' topic/p ')]">
  611. <xsl:call-template name="makePara">
  612. <xsl:with-param name="IDPrefix" select="'para'"/>
  613. </xsl:call-template>
  614. </xsl:template>
  615. <xsl:template match="*[contains(@class,' topic/lq ')]">
  616. <blockquote>
  617. <xsl:call-template name="setStandardAttr">
  618. <xsl:with-param name="IDPrefix" select="'lq'"/>
  619. </xsl:call-template>
  620. <xsl:call-template name="makeBlock"/>
  621. </blockquote>
  622. </xsl:template>
  623. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  624. - ADMONITION / PERIL BLOCKS
  625. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  626. <xsl:template match="*[contains(@class,' topic/note ') and
  627. (@type='attention' or @type='important' or @type='restriction')]">
  628. <important>
  629. <xsl:call-template name="setStandardAttr">
  630. <xsl:with-param name="IDPrefix" select="'important'"/>
  631. </xsl:call-template>
  632. <xsl:call-template name="makeBlock"/>
  633. </important>
  634. </xsl:template>
  635. <xsl:template match="*[contains(@class,' topic/note ') and
  636. (@type='caution' or @type='remember')]">
  637. <caution>
  638. <xsl:call-template name="setStandardAttr">
  639. <xsl:with-param name="IDPrefix" select="'caution'"/>
  640. </xsl:call-template>
  641. <xsl:call-template name="makeBlock"/>
  642. </caution>
  643. </xsl:template>
  644. <xsl:template match="*[contains(@class,' topic/note ') and @type='danger']">
  645. <warning>
  646. <xsl:call-template name="setStandardAttr">
  647. <xsl:with-param name="IDPrefix" select="'warning'"/>
  648. </xsl:call-template>
  649. <xsl:call-template name="makeBlock"/>
  650. </warning>
  651. </xsl:template>
  652. <xsl:template match="*[contains(@class,' topic/note ') and
  653. (@type='tip' or @type='fastpath')]">
  654. <tip>
  655. <xsl:call-template name="setStandardAttr">
  656. <xsl:with-param name="IDPrefix" select="'warning'"/>
  657. </xsl:call-template>
  658. <xsl:call-template name="makeBlock"/>
  659. </tip>
  660. </xsl:template>
  661. <xsl:template match="*[contains(@class,' topic/note ') and not(@type)]">
  662. <note>
  663. <xsl:call-template name="setStandardAttr">
  664. <xsl:with-param name="IDPrefix" select="'note'"/>
  665. </xsl:call-template>
  666. <xsl:if test="@title">
  667. <title>
  668. <xsl:value-of select="@title"/>
  669. </title>
  670. </xsl:if>
  671. <xsl:call-template name="makeBlock"/>
  672. </note>
  673. </xsl:template>
  674. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  675. - SEMANTIC PHRASES
  676. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  677. <xsl:template match="*[contains(@class,' topic/ph ')]" name="phrase">
  678. <xsl:param name="IDPrefix" select="'phrs'"/>
  679. <xsl:param name="role" select="''"/>
  680. <phrase>
  681. <xsl:if test="$role!=''">
  682. <xsl:attribute name="role">
  683. <xsl:value-of select="$role"/>
  684. </xsl:attribute>
  685. </xsl:if>
  686. <xsl:call-template name="setStandardAttr">
  687. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  688. </xsl:call-template>
  689. <xsl:apply-templates/>
  690. </phrase>
  691. </xsl:template>
  692. <xsl:template match="*[contains(@class,' topic/keyword ')]">
  693. <xsl:call-template name="phrase">
  694. <xsl:with-param name="IDPrefix" select="'kywrd'"/>
  695. </xsl:call-template>
  696. </xsl:template>
  697. <xsl:template match="*[contains(@class,' topic/q ')]">
  698. <quote>
  699. <xsl:call-template name="setStandardAttr">
  700. <xsl:with-param name="IDPrefix" select="'quote'"/>
  701. </xsl:call-template>
  702. <xsl:apply-templates/>
  703. </quote>
  704. </xsl:template>
  705. <xsl:template match="*[contains(@class,' topic/term ')]">
  706. <glossterm>
  707. <xsl:call-template name="setStandardAttr">
  708. <xsl:with-param name="IDPrefix" select="'quote'"/>
  709. </xsl:call-template>
  710. <xsl:apply-templates/>
  711. </glossterm>
  712. </xsl:template>
  713. <!--
  714. DATA-TYPE PHRASES: date time currency char num bin oct dec hex ???
  715. -->
  716. <xsl:template match="*[contains(@class,' topic/boolean ')]"/>
  717. <xsl:template match="*[contains(@class,' topic/state ')]"/>
  718. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  719. - LINKING PHRASES
  720. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  721. <xsl:template match="*[contains(@class,' topic/xref ')]">
  722. <xsl:choose>
  723. <xsl:when test="(not(@format) or @format='dita') and
  724. (not(@scope) or @scope='local') and
  725. @href and (
  726. substring(@href, string-length(@href) - 4) = '.dita' or
  727. contains(@href,'.dita#') or
  728. substring(@href, string-length(@href) - 3) = '.xml' or
  729. contains(@href,'.xml#'))">
  730. <xsl:apply-templates select="." mode="make-xref-from-xref"/>
  731. </xsl:when>
  732. <xsl:when test="((@format and @format != 'dita') or
  733. (@scope and @scope!='local') or
  734. (@href and
  735. substring(@href, string-length(@href) - 4) != '.dita' and
  736. not (contains(@href,'.dita#')) and
  737. substring(@href, string-length(@href) - 3) != '.xml' and
  738. not (contains(@href,'.xml#')) ))">
  739. <xsl:apply-templates select="." mode="make-ulink-from-xref"/>
  740. </xsl:when>
  741. <xsl:otherwise>
  742. <!-- Unable to handle at this time -->
  743. <xsl:apply-templates select="." mode="deflate"/>
  744. </xsl:otherwise>
  745. </xsl:choose>
  746. </xsl:template>
  747. <!--<xsl:template match="*[contains(@class,' topic/xref ') and (
  748. (@format and @format != 'dita') or
  749. (@scope and @scope!='local') or
  750. (@href and
  751. substring(@href, string-length(@href) - 5) != '.dita' and
  752. substring(@href, string-length(@href) - 4) != '.xml'))]">-->
  753. <xsl:template match="*" mode="make-ulink-from-xref">
  754. <ulink url="{@href}" type="{@type}">
  755. <xsl:call-template name="setStandardAttr">
  756. <xsl:with-param name="IDPrefix" select="'link'"/>
  757. </xsl:call-template>
  758. <xsl:apply-templates/>
  759. </ulink>
  760. </xsl:template>
  761. <!--<xsl:template match="*[contains(@class,' topic/xref ') and
  762. (not(@format) or @format='dita') and
  763. (not(@scope) or @scope='local') and
  764. @href and (
  765. substring(@href, string-length(@href) - 5) = '.dita' or
  766. substring(@href, string-length(@href) - 4) = '.xml')]">-->
  767. <xsl:template match="*" mode="make-xref-from-xref">
  768. <xsl:variable name="linkID">
  769. <xsl:call-template name="getLinkID"/>
  770. </xsl:variable>
  771. <xref linkend="{$linkID}">
  772. <xsl:call-template name="setStandardAttr">
  773. <xsl:with-param name="IDPrefix" select="'xref'"/>
  774. </xsl:call-template>
  775. </xref>
  776. </xsl:template>
  777. <xsl:template match="*[contains(@class,' topic/fn ')]" name="footnote">
  778. <xsl:param name="IDPrefix" select="'fn'"/>
  779. <footnote>
  780. <xsl:call-template name="setStandardAttr">
  781. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  782. </xsl:call-template>
  783. <xsl:call-template name="makeBlock"/>
  784. </footnote>
  785. </xsl:template>
  786. <xsl:template match="*[contains(@class,' topic/cite ')]">
  787. <xsl:choose>
  788. <xsl:when test="@ref">
  789. <xref role="cite" linkend="{@ref}">
  790. <xsl:call-template name="setStandardAttr">
  791. <xsl:with-param name="IDPrefix" select="'cite'"/>
  792. </xsl:call-template>
  793. </xref>
  794. </xsl:when>
  795. <xsl:otherwise>
  796. <citation>
  797. <xsl:call-template name="setStandardAttr">
  798. <xsl:with-param name="IDPrefix" select="'cite'"/>
  799. </xsl:call-template>
  800. <xsl:apply-templates/>
  801. </citation>
  802. </xsl:otherwise>
  803. </xsl:choose>
  804. </xsl:template>
  805. <xsl:template match="*[contains(@class,' topic/indexterm ')]">
  806. <indexterm>
  807. <xsl:call-template name="setStandardAttr">
  808. <xsl:with-param name="IDPrefix" select="'indxtrm'"/>
  809. </xsl:call-template>
  810. <primary>
  811. <xsl:apply-templates select="text()"/>
  812. </primary>
  813. <xsl:apply-templates select="*" mode="secondary"/>
  814. </indexterm>
  815. </xsl:template>
  816. <xsl:template match="*[contains(@class,' topic/indexterm ')]" mode="secondary">
  817. <secondary>
  818. <xsl:call-template name="setStandardAttr">
  819. <xsl:with-param name="IDPrefix" select="'indxtrm'"/>
  820. </xsl:call-template>
  821. <xsl:apply-templates select="text()"/>
  822. </secondary>
  823. <xsl:apply-templates select="*" mode="tertiary"/>
  824. </xsl:template>
  825. <xsl:template match="*[contains(@class,' topic/indexterm ')]" mode="tertiary">
  826. <tertiary>
  827. <xsl:call-template name="setStandardAttr">
  828. <xsl:with-param name="IDPrefix" select="'indxtrm'"/>
  829. </xsl:call-template>
  830. <xsl:apply-templates select="text()"/>
  831. </tertiary>
  832. <xsl:apply-templates select="*"/>
  833. </xsl:template>
  834. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  835. - TABLES
  836. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  837. <xsl:template match="*[contains(@class,' topic/table ')]">
  838. <xsl:param name="titleSpec" select="' topic/title '"/>
  839. <xsl:param name="titleNode" select="*[contains(@class,$titleSpec)]"/>
  840. <xsl:variable name="descNode" select="*[contains(@class,' topic/desc ')]"/>
  841. <xsl:variable name="element">
  842. <xsl:choose>
  843. <xsl:when test="$titleNode">
  844. <xsl:text>table</xsl:text>
  845. </xsl:when>
  846. <xsl:otherwise>
  847. <xsl:text>informaltable</xsl:text>
  848. </xsl:otherwise>
  849. </xsl:choose>
  850. </xsl:variable>
  851. <xsl:element name="{$element}">
  852. <xsl:call-template name="setStandardAttr">
  853. <xsl:with-param name="IDPrefix" select="'tbl'"/>
  854. </xsl:call-template>
  855. <xsl:if test="@colsep">
  856. <xsl:copy-of select="@colsep"/>
  857. </xsl:if>
  858. <xsl:if test="@frame">
  859. <xsl:copy-of select="@frame"/>
  860. </xsl:if>
  861. <xsl:if test="@rowsep">
  862. <xsl:copy-of select="@rowsep"/>
  863. </xsl:if>
  864. <xsl:apply-templates select="@rowheader|@scale" mode="deflate"/>
  865. <xsl:if test="$titleNode">
  866. <xsl:apply-templates select="$titleNode"/>
  867. </xsl:if>
  868. <xsl:if test="$descNode">
  869. <xsl:apply-templates select="$descNode"/>
  870. </xsl:if>
  871. <xsl:apply-templates select="*[contains(@class,' topic/tgroup ')]"/>
  872. </xsl:element>
  873. </xsl:template>
  874. <xsl:template match="*[contains(@class,' topic/tgroup ')]">
  875. <xsl:call-template name="copyAs">
  876. <xsl:with-param name="elementName" select="'tgroup'"/>
  877. </xsl:call-template>
  878. </xsl:template>
  879. <xsl:template match="*[contains(@class,' topic/colspec ')]">
  880. <xsl:call-template name="copyAs">
  881. <xsl:with-param name="elementName" select="'colspec'"/>
  882. <xsl:with-param name="hasRemap" select="false()"/>
  883. </xsl:call-template>
  884. </xsl:template>
  885. <xsl:template match="*[contains(@class,' topic/spanspec ')]">
  886. <xsl:call-template name="copyAs">
  887. <xsl:with-param name="elementName" select="'spanspec'"/>
  888. <xsl:with-param name="hasRemap" select="false()"/>
  889. </xsl:call-template>
  890. </xsl:template>
  891. <xsl:template match="*[contains(@class,' topic/thead ')]">
  892. <xsl:call-template name="copyAs">
  893. <xsl:with-param name="elementName" select="'thead'"/>
  894. </xsl:call-template>
  895. </xsl:template>
  896. <xsl:template match="*[contains(@class,' topic/tfoot ')]">
  897. <xsl:call-template name="copyAs">
  898. <xsl:with-param name="elementName" select="'tfoot'"/>
  899. </xsl:call-template>
  900. </xsl:template>
  901. <xsl:template match="*[contains(@class,' topic/tbody ')]">
  902. <xsl:call-template name="copyAs">
  903. <xsl:with-param name="elementName" select="'tbody'"/>
  904. </xsl:call-template>
  905. </xsl:template>
  906. <xsl:template match="*[contains(@class,' topic/row ')]">
  907. <xsl:call-template name="copyAs">
  908. <xsl:with-param name="elementName" select="'row'"/>
  909. </xsl:call-template>
  910. </xsl:template>
  911. <xsl:template match="*[contains(@class,' topic/entry ')]">
  912. <xsl:call-template name="copyAs">
  913. <xsl:with-param name="elementName" select="'entry'"/>
  914. </xsl:call-template>
  915. </xsl:template>
  916. <!-- segmentedlist is a closer match with simpletable
  917. but the content model of set is too restrictive -->
  918. <xsl:template match="*[contains(@class,' topic/simpletable ')]">
  919. <xsl:variable name="colcount">
  920. <xsl:call-template name="maxsemcol">
  921. <xsl:with-param name="rows"
  922. select="*[contains(@class,' topic/strow ')]"/>
  923. </xsl:call-template>
  924. </xsl:variable>
  925. <xsl:variable name="element">
  926. <xsl:choose>
  927. <xsl:when test="@title">
  928. <xsl:text>table</xsl:text>
  929. </xsl:when>
  930. <xsl:otherwise>
  931. <xsl:text>informaltable</xsl:text>
  932. </xsl:otherwise>
  933. </xsl:choose>
  934. </xsl:variable>
  935. <xsl:element name="{$element}">
  936. <xsl:call-template name="setStandardAttr">
  937. <xsl:with-param name="IDPrefix" select="'smtbl'"/>
  938. </xsl:call-template>
  939. <xsl:if test="@title">
  940. <title>
  941. <xsl:value-of select="@title"/>
  942. </title>
  943. </xsl:if>
  944. <tgroup cols="{$colcount}">
  945. <xsl:apply-templates select="*[contains(@class,' topic/sthead ')]"/>
  946. <tbody>
  947. <xsl:apply-templates select="*[contains(@class,' topic/strow ')]"/>
  948. </tbody>
  949. </tgroup>
  950. </xsl:element>
  951. </xsl:template>
  952. <xsl:template match="*[contains(@class,' topic/sthead ')]">
  953. <thead>
  954. <xsl:call-template name="setStandardAttr">
  955. <xsl:with-param name="IDPrefix" select="'sthd'"/>
  956. </xsl:call-template>
  957. <row>
  958. <xsl:apply-templates/>
  959. </row>
  960. </thead>
  961. </xsl:template>
  962. <xsl:template match="*[contains(@class,' topic/strow ')]">
  963. <row>
  964. <xsl:call-template name="setStandardAttr">
  965. <xsl:with-param name="IDPrefix" select="'strw'"/>
  966. </xsl:call-template>
  967. <xsl:apply-templates/>
  968. </row>
  969. </xsl:template>
  970. <xsl:template match="*[contains(@class,' topic/stentry ')]">
  971. <entry>
  972. <xsl:call-template name="setStandardAttr">
  973. <xsl:with-param name="IDPrefix" select="'stent'"/>
  974. </xsl:call-template>
  975. <xsl:if test="@title">
  976. <xsl:attribute name="xreflabel">
  977. <xsl:value-of select="@xreflabel"/>
  978. </xsl:attribute>
  979. </xsl:if>
  980. <xsl:apply-templates/>
  981. </entry>
  982. </xsl:template>
  983. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  984. - FIGURES AND MEDIA OBJECTS
  985. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  986. <xsl:template match="*[contains(@class,' topic/fig ')]">
  987. <xsl:param name="titleSpec" select="' topic/title '"/>
  988. <xsl:param name="titleNode" select="*[contains(@class,$titleSpec)]"/>
  989. <xsl:variable name="descNode" select="*[contains(@class,' topic/desc ')]"/>
  990. <xsl:variable name="contentNode" select="*[not(contains(@class,$titleSpec)
  991. or contains(@class,' topic/desc '))]"/>
  992. <xsl:variable name="element">
  993. <xsl:choose>
  994. <xsl:when test="$titleNode or @title">
  995. <xsl:text>figure</xsl:text>
  996. </xsl:when>
  997. <xsl:otherwise>
  998. <xsl:text>informalfigure</xsl:text>
  999. </xsl:otherwise>
  1000. </xsl:choose>
  1001. </xsl:variable>
  1002. <xsl:element name="{$element}">
  1003. <xsl:call-template name="setStandardAttr">
  1004. <xsl:with-param name="IDPrefix" select="'fig'"/>
  1005. </xsl:call-template>
  1006. <xsl:apply-templates select="@frame|@scale" mode="deflate"/>
  1007. <xsl:choose>
  1008. <xsl:when test="$titleNode">
  1009. <xsl:apply-templates select="$titleNode"/>
  1010. </xsl:when>
  1011. <xsl:when test="@title">
  1012. <title>
  1013. <xsl:value-of select="@title"/>
  1014. </title>
  1015. </xsl:when>
  1016. </xsl:choose>
  1017. <xsl:if test="$descNode">
  1018. <xsl:apply-templates select="$descNode"/>
  1019. </xsl:if>
  1020. <xsl:choose>
  1021. <xsl:when test="contains($contentNode/@class,' topic/figgroup ') and (
  1022. contains($contentNode/*/@class,' topic/dl ') or
  1023. contains($contentNode/*/@class,' topic/gl ') or
  1024. contains($contentNode/*/@class,' topic/note ') or
  1025. contains($contentNode/*/@class,' topic/notelist ') or
  1026. contains($contentNode/*/@class,' topic/ol ') or
  1027. contains($contentNode/*/@class,' topic/p ') or
  1028. contains($contentNode/*/@class,' topic/qalist ') or
  1029. contains($contentNode/*/@class,' topic/ul '))">
  1030. <blockquote remap="CONTAINER">
  1031. <xsl:apply-templates select="$contentNode"/>
  1032. </blockquote>
  1033. </xsl:when>
  1034. <xsl:when test="contains($contentNode/@class,' topic/dl ') or
  1035. contains($contentNode/@class,' topic/gl ') or
  1036. contains($contentNode/@class,' topic/note ') or
  1037. contains($contentNode/@class,' topic/notelist ') or
  1038. contains($contentNode/@class,' topic/ol ') or
  1039. contains($contentNode/@class,' topic/p ') or
  1040. contains($contentNode/@class,' topic/qalist ') or
  1041. contains($contentNode/@class,' topic/ul ')">
  1042. <blockquote remap="CONTAINER">
  1043. <xsl:apply-templates select="$contentNode"/>
  1044. </blockquote>
  1045. </xsl:when>
  1046. <xsl:otherwise>
  1047. <xsl:apply-templates select="$contentNode"/>
  1048. </xsl:otherwise>
  1049. </xsl:choose>
  1050. </xsl:element>
  1051. </xsl:template>
  1052. <xsl:template match="*[contains(@class,' topic/figgroup ')]">
  1053. <xsl:apply-templates select="." mode="deflate">
  1054. <xsl:with-param name="descendentsOkay" select="true()"/>
  1055. </xsl:apply-templates>
  1056. </xsl:template>
  1057. <!-- to do -->
  1058. <xsl:template match="*[contains(@class,' topic/object ')]">
  1059. <mediaobject>
  1060. <xsl:call-template name="setStandardAttr">
  1061. <xsl:with-param name="IDPrefix" select="'obj'"/>
  1062. </xsl:call-template>
  1063. <xsl:apply-templates select="." mode="deflate"/>
  1064. </mediaobject>
  1065. </xsl:template>
  1066. <xsl:template match="*[contains(@class,' topic/textalt ')]">
  1067. <textobject>
  1068. <xsl:call-template name="setStandardAttr">
  1069. <xsl:with-param name="IDPrefix" select="'txtlt'"/>
  1070. </xsl:call-template>
  1071. <xsl:call-template name="makeBlock"/>
  1072. </textobject>
  1073. </xsl:template>
  1074. <!-- to do -->
  1075. <xsl:template match="*[contains(@class,' topic/image ')]">
  1076. <mediaobject>
  1077. <xsl:call-template name="setStandardAttr">
  1078. <xsl:with-param name="IDPrefix" select="'img'"/>
  1079. </xsl:call-template>
  1080. <imageobject>
  1081. <imagedata>
  1082. <xsl:if test="@href">
  1083. <xsl:attribute name="fileref">
  1084. <xsl:value-of select="@href"/>
  1085. </xsl:attribute>
  1086. </xsl:if>
  1087. <xsl:if test="@height">
  1088. <xsl:attribute name="depth">
  1089. <xsl:value-of select="@height"/>
  1090. </xsl:attribute>
  1091. </xsl:if>
  1092. <xsl:if test="@width">
  1093. <xsl:attribute name="width">
  1094. <xsl:value-of select="@width"/>
  1095. </xsl:attribute>
  1096. </xsl:if>
  1097. <xsl:if test="@align">
  1098. <xsl:attribute name="align">
  1099. <xsl:value-of select="@align"/>
  1100. </xsl:attribute>
  1101. </xsl:if>
  1102. <xsl:apply-templates select="@placement" mode="deflate"/>
  1103. </imagedata>
  1104. </imageobject>
  1105. <xsl:if test="@alt or @longdescref">
  1106. <textobject remap="alt_attribute">
  1107. <xsl:if test="@alt">
  1108. <phrase remap="#PCDATA">
  1109. <xsl:value-of select="@alt"/>
  1110. </phrase>
  1111. </xsl:if>
  1112. <xsl:if test="@longdescref">
  1113. <xref linkend="{@href}">
  1114. <xsl:call-template name="setStandardAttr">
  1115. <xsl:with-param name="IDPrefix" select="'xref'"/>
  1116. </xsl:call-template>
  1117. </xref>
  1118. </xsl:if>
  1119. </textobject>
  1120. </xsl:if>
  1121. </mediaobject>
  1122. </xsl:template>
  1123. <!-- to do: imagemap -->
  1124. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1125. - MISCELLANEOUS AND DEFAULT
  1126. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  1127. <xsl:template match="*[contains(@class,' topic/draft-comment ')]">
  1128. <remark>
  1129. <xsl:call-template name="setStandardAttr">
  1130. <xsl:with-param name="IDPrefix" select="'sp'"/>
  1131. </xsl:call-template>
  1132. <xsl:apply-templates/>
  1133. </remark>
  1134. </xsl:template>
  1135. <xsl:template match="*[ not( @class ) ]">
  1136. <xsl:message>
  1137. <xsl:text>No class attribute for </xsl:text>
  1138. <xsl:value-of select="name(.)"/>
  1139. </xsl:message>
  1140. </xsl:template>
  1141. <xsl:template match="*[contains(@class,' topic/no-topic-nesting ')]"/>
  1142. <xsl:template match="*[@conref]">
  1143. <!-- a well-known Docbook hack -->
  1144. <inlinemediaobject role="{@parse}">
  1145. <xsl:call-template name="setStandardAttr">
  1146. <xsl:with-param name="IDPrefix" select="'include'"/>
  1147. </xsl:call-template>
  1148. <imageobject>
  1149. <imagedata format="linespecific" fileref="{@conref}"/>
  1150. </imageobject>
  1151. </inlinemediaobject>
  1152. </xsl:template>
  1153. <!-- default element rule -->
  1154. <xsl:template match="*">
  1155. <!-- to debug, uncomment the following message -->
  1156. <!--
  1157. <xsl:message>
  1158. <xsl:text>unmapped: </xsl:text>
  1159. <xsl:value-of select="local-name(.)"/>
  1160. <xsl:text> spec="</xsl:text>
  1161. <xsl:value-of select="@class"/>
  1162. <xsl:text>"</xsl:text>
  1163. </xsl:message>
  1164. -->
  1165. <xsl:apply-templates select="." mode="deflate"/>
  1166. </xsl:template>
  1167. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1168. - UTILITIES
  1169. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  1170. <xsl:template name="setStandardAttr">
  1171. <xsl:param name="IDPrefix" select="local-name(.)"/>
  1172. <xsl:if test="not( @id )">
  1173. <xsl:attribute name="id">
  1174. <xsl:call-template name="provideID">
  1175. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1176. </xsl:call-template>
  1177. </xsl:attribute>
  1178. </xsl:if>
  1179. <xsl:attribute name="remap">
  1180. <xsl:value-of select="local-name(.)"/>
  1181. </xsl:attribute>
  1182. <xsl:for-each select="@*">
  1183. <xsl:call-template name="testStandardAttr">
  1184. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1185. </xsl:call-template>
  1186. </xsl:for-each>
  1187. </xsl:template>
  1188. <xsl:template name="testStandardAttr">
  1189. <xsl:param name="IDPrefix"/>
  1190. <xsl:param name="attrName" select="local-name(.)"/>
  1191. <xsl:choose>
  1192. <xsl:when test="$attrName='id'">
  1193. <xsl:attribute name="id">
  1194. <xsl:value-of select="."/>
  1195. </xsl:attribute>
  1196. </xsl:when>
  1197. <xsl:when test="$attrName='spec'">
  1198. <xsl:attribute name="remap">
  1199. <xsl:value-of select="."/>
  1200. </xsl:attribute>
  1201. </xsl:when>
  1202. <xsl:when test="$attrName='platform'">
  1203. <xsl:attribute name="arch">
  1204. <xsl:value-of select="."/>
  1205. </xsl:attribute>
  1206. </xsl:when>
  1207. <xsl:when test="$attrName='product'">
  1208. <xsl:attribute name="os">
  1209. <xsl:value-of select="."/>
  1210. </xsl:attribute>
  1211. </xsl:when>
  1212. <xsl:when test="$attrName='version'">
  1213. <xsl:attribute name="revision">
  1214. <xsl:value-of select="."/>
  1215. </xsl:attribute>
  1216. </xsl:when>
  1217. <xsl:when test="$attrName='audience'">
  1218. <xsl:attribute name="userlevel">
  1219. <xsl:value-of select="."/>
  1220. </xsl:attribute>
  1221. </xsl:when>
  1222. <!-- leave non-standard attributes to be handled locally -->
  1223. </xsl:choose>
  1224. </xsl:template>
  1225. <xsl:template name="provideID">
  1226. <xsl:param name="IDPrefix" select="local-name(.)"/>
  1227. <xsl:choose>
  1228. <xsl:when test="@id">
  1229. <xsl:value-of select="@id"/>
  1230. </xsl:when>
  1231. <xsl:otherwise>
  1232. <xsl:value-of select="concat( $IDPrefix, generate-id() )"/>
  1233. </xsl:otherwise>
  1234. </xsl:choose>
  1235. </xsl:template>
  1236. <xsl:template name="copyAs">
  1237. <xsl:param name="elementName" select="local-name(.)"/>
  1238. <xsl:param name="hasRemap" select="true()"/>
  1239. <xsl:element name="{$elementName}">
  1240. <xsl:for-each select="@*">
  1241. <xsl:choose>
  1242. <xsl:when test="local-name(.) = 'spec'">
  1243. <xsl:if test="$hasRemap">
  1244. <xsl:attribute name="remap">
  1245. <xsl:value-of select="."/>
  1246. </xsl:attribute>
  1247. </xsl:if>
  1248. </xsl:when>
  1249. <xsl:when test="local-name(.) = 'class'">
  1250. </xsl:when>
  1251. <xsl:otherwise>
  1252. <xsl:copy/>
  1253. </xsl:otherwise>
  1254. </xsl:choose>
  1255. </xsl:for-each>
  1256. <xsl:apply-templates/>
  1257. </xsl:element>
  1258. </xsl:template>
  1259. <xsl:template name="makeBlock">
  1260. <xsl:param name="node" select="."/>
  1261. <xsl:call-template name="makeBlockList">
  1262. <xsl:with-param name="nodelist" select="$node/*|$node/text()"/>
  1263. </xsl:call-template>
  1264. </xsl:template>
  1265. <xsl:template name="deflateBlock">
  1266. <xsl:param name="id" select="concat('elem', generate-id())"/>
  1267. <xsl:param name="element" select="local-name(.)"/>
  1268. <xsl:param name="nodelist" select="*|text()"/>
  1269. <xsl:call-template name="deflateElementStart">
  1270. <xsl:with-param name="id" select="$id"/>
  1271. <xsl:with-param name="element" select="$element"/>
  1272. </xsl:call-template>
  1273. <xsl:call-template name="makeBlockList">
  1274. <xsl:with-param name="nodelist" select="$nodelist"/>
  1275. </xsl:call-template>
  1276. <xsl:call-template name="deflateElementEnd">
  1277. <xsl:with-param name="id" select="$id"/>
  1278. <xsl:with-param name="element" select="$element"/>
  1279. </xsl:call-template>
  1280. </xsl:template>
  1281. <!-- where block is optional in DITA but required in Docbook,
  1282. wrap PCDATA or phrase elements in para -->
  1283. <xsl:template name="makeBlockList">
  1284. <xsl:param name="currnode" select="1"/>
  1285. <xsl:param name="nodelist"/>
  1286. <!-- default value must match $FindAny variable -->
  1287. <xsl:param name="findTarget" select="1"/>
  1288. <xsl:variable name="FindAny" select="1"/>
  1289. <xsl:variable name="FindBlock" select="2"/>
  1290. <xsl:variable name="FindNonBlock" select="3"/>
  1291. <xsl:if test="count($nodelist)>=$currnode">
  1292. <xsl:variable name="node" select="$nodelist[position()=$currnode]"/>
  1293. <xsl:variable name="isBlock">
  1294. <xsl:call-template name="isBlock">
  1295. <xsl:with-param name="nodelist" select="$node"/>
  1296. </xsl:call-template>
  1297. </xsl:variable>
  1298. <xsl:choose>
  1299. <xsl:when test="$isBlock=1">
  1300. <xsl:if test="$findTarget!=$FindNonBlock">
  1301. <xsl:apply-templates select="$node"/>
  1302. <xsl:call-template name="makeBlockList">
  1303. <xsl:with-param name="nodelist" select="$nodelist"/>
  1304. <xsl:with-param name="currnode" select="$currnode + 1"/>
  1305. <xsl:with-param name="findTarget" select="$FindAny"/>
  1306. </xsl:call-template>
  1307. </xsl:if>
  1308. </xsl:when>
  1309. <xsl:otherwise>
  1310. <xsl:choose>
  1311. <xsl:when test="$findTarget=$FindAny">
  1312. <xsl:variable name="nonblock">
  1313. <xsl:apply-templates select="$node"/>
  1314. <xsl:call-template name="makeBlockList">
  1315. <xsl:with-param name="nodelist" select="$nodelist"/>
  1316. <xsl:with-param name="currnode" select="$currnode + 1"/>
  1317. <xsl:with-param name="findTarget" select="$FindNonBlock"/>
  1318. </xsl:call-template>
  1319. </xsl:variable>
  1320. <xsl:if test="normalize-space(string($nonblock))!=''">
  1321. <para remap="#PCDATA">
  1322. <xsl:copy-of select="$nonblock"/>
  1323. </para>
  1324. </xsl:if>
  1325. <xsl:call-template name="makeBlockList">
  1326. <xsl:with-param name="nodelist" select="$nodelist"/>
  1327. <xsl:with-param name="currnode" select="$currnode + 1"/>
  1328. <xsl:with-param name="findTarget" select="$FindBlock"/>
  1329. </xsl:call-template>
  1330. </xsl:when>
  1331. <xsl:when test="$findTarget=$FindNonBlock">
  1332. <xsl:apply-templates select="$node"/>
  1333. <xsl:call-template name="makeBlockList">
  1334. <xsl:with-param name="nodelist" select="$nodelist"/>
  1335. <xsl:with-param name="currnode" select="$currnode + 1"/>
  1336. <xsl:with-param name="findTarget" select="$FindNonBlock"/>
  1337. </xsl:call-template>
  1338. </xsl:when>
  1339. <xsl:when test="$findTarget=$FindBlock">
  1340. <xsl:call-template name="makeBlockList">
  1341. <xsl:with-param name="nodelist" select="$nodelist"/>
  1342. <xsl:with-param name="currnode" select="$currnode + 1"/>
  1343. <xsl:with-param name="findTarget" select="$FindBlock"/>
  1344. </xsl:call-template>
  1345. </xsl:when>
  1346. <xsl:otherwise>
  1347. <xsl:message>
  1348. <xsl:text>Unknown target type for find: </xsl:text>
  1349. <xsl:value-of select="$findTarget"/>
  1350. </xsl:message>
  1351. </xsl:otherwise>
  1352. </xsl:choose>
  1353. </xsl:otherwise>
  1354. </xsl:choose>
  1355. </xsl:if>
  1356. </xsl:template>
  1357. <xsl:template name="isBlock">
  1358. <xsl:param name="nodelist" select="."/>
  1359. <xsl:choose>
  1360. <xsl:when test="boolean($nodelist[
  1361. contains(@class,' topic/dl ')
  1362. or contains(@class,' topic/fig ')
  1363. or contains(@class,' topic/itemgroup ')
  1364. or contains(@class,' topic/lines ')
  1365. or contains(@class,' topic/lq ')
  1366. or contains(@class,' topic/note ')
  1367. or contains(@class,' topic/ol ')
  1368. or contains(@class,' topic/p ')
  1369. or contains(@class,' topic/pre ')
  1370. or contains(@class,' topic/simpletable ')
  1371. or contains(@class,' topic/table ')
  1372. or contains(@class,' topic/ul ')
  1373. ])">
  1374. <xsl:value-of select="1"/>
  1375. </xsl:when>
  1376. <xsl:otherwise>
  1377. <xsl:value-of select="0"/>
  1378. </xsl:otherwise>
  1379. </xsl:choose>
  1380. </xsl:template>
  1381. <xsl:template name="makeBlockCont">
  1382. <xsl:param name="titleSpec" select="' topic/title '"/>
  1383. <xsl:param name="titleNode" select="*[contains(@class,$titleSpec)]"/>
  1384. <xsl:param name="isContReq" select="false()"/>
  1385. <xsl:param name="IDPrefix"/>
  1386. <xsl:variable name="hasBlocks">
  1387. <xsl:call-template name="isBlock">
  1388. <xsl:with-param name="nodelist" select="*"/>
  1389. </xsl:call-template>
  1390. </xsl:variable>
  1391. <xsl:choose>
  1392. <xsl:when test="$hasBlocks=1">
  1393. <xsl:choose>
  1394. <xsl:when test="$isContReq or $titleNode">
  1395. <xsl:choose>
  1396. <xsl:when test="count(*[not(contains(@class,$titleSpec))]) =
  1397. count(*[contains(@class,' topic/qalist ')])">
  1398. <qandaset>
  1399. <xsl:call-template name="setStandardAttr">
  1400. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1401. </xsl:call-template>
  1402. <xsl:if test="$titleNode">
  1403. <xsl:apply-templates select="$titleNode"/>
  1404. </xsl:if>
  1405. <xsl:apply-templates select="*[contains(@class,' topic/qalist ')]">
  1406. <xsl:with-param name="element" select="'qandadiv'"/>
  1407. </xsl:apply-templates>
  1408. </qandaset>
  1409. </xsl:when>
  1410. <xsl:otherwise>
  1411. <!-- probably need to add other mappings -->
  1412. <xsl:variable name="element">
  1413. <xsl:text>sidebar</xsl:text>
  1414. </xsl:variable>
  1415. <xsl:element name="{$element}">
  1416. <xsl:call-template name="setStandardAttr">
  1417. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1418. </xsl:call-template>
  1419. <xsl:if test="$titleNode">
  1420. <xsl:apply-templates select="$titleNode"/>
  1421. </xsl:if>
  1422. <xsl:call-template name="makeBlockList">
  1423. <xsl:with-param name="nodelist"
  1424. select="*[not(contains(@class,$titleSpec))]|text()"/>
  1425. </xsl:call-template>
  1426. </xsl:element>
  1427. </xsl:otherwise>
  1428. </xsl:choose>
  1429. </xsl:when>
  1430. <xsl:otherwise>
  1431. <xsl:call-template name="deflateBlock">
  1432. <xsl:with-param name="nodelist"
  1433. select="*[not(contains(@class,$titleSpec))]|text()"/>
  1434. </xsl:call-template>
  1435. </xsl:otherwise>
  1436. </xsl:choose>
  1437. </xsl:when>
  1438. <xsl:otherwise>
  1439. <xsl:call-template name="makePara">
  1440. <xsl:with-param name="titleSpec" select="$titleSpec"/>
  1441. <xsl:with-param name="titleNode" select="$titleNode"/>
  1442. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1443. </xsl:call-template>
  1444. </xsl:otherwise>
  1445. </xsl:choose>
  1446. </xsl:template>
  1447. <xsl:template name="makePara">
  1448. <xsl:param name="titleSpec" select="' topic/title '"/>
  1449. <xsl:param name="titleNode" select="*[contains(@class,$titleSpec)]"/>
  1450. <xsl:param name="role" select="''"/>
  1451. <xsl:param name="IDPrefix"/>
  1452. <xsl:choose>
  1453. <xsl:when test="$titleNode or @title">
  1454. <formalpara>
  1455. <xsl:call-template name="setStandardAttr">
  1456. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1457. </xsl:call-template>
  1458. <xsl:choose>
  1459. <xsl:when test="$role!=''">
  1460. <xsl:attribute name="role">
  1461. <xsl:value-of select="$role"/>
  1462. </xsl:attribute>
  1463. </xsl:when>
  1464. </xsl:choose>
  1465. <xsl:choose>
  1466. <xsl:when test="$titleNode">
  1467. <xsl:apply-templates select="@title" mode="deflate"/>
  1468. <title>
  1469. <xsl:apply-templates select="$titleNode/*|$titleNode/text()"/>
  1470. </title>
  1471. </xsl:when>
  1472. <xsl:otherwise>
  1473. <title>
  1474. <xsl:value-of select="@title"/>
  1475. </title>
  1476. </xsl:otherwise>
  1477. </xsl:choose>
  1478. <para>
  1479. <xsl:apply-templates select="*[not(contains(@class,$titleSpec))]"/>
  1480. </para>
  1481. </formalpara>
  1482. </xsl:when>
  1483. <xsl:otherwise>
  1484. <para>
  1485. <xsl:call-template name="setStandardAttr">
  1486. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1487. </xsl:call-template>
  1488. <xsl:apply-templates/>
  1489. </para>
  1490. </xsl:otherwise>
  1491. </xsl:choose>
  1492. </xsl:template>
  1493. <xsl:template name="makeTitle">
  1494. <xsl:param name="elemTitled"/>
  1495. <xsl:param name="elemUntitled" select="$elemTitled"/>
  1496. <xsl:param name="titleSpec" select="' topic/title '"/>
  1497. <xsl:param name="titleNode" select="*[contains(@class,$titleSpec)]"/>
  1498. <xsl:param name="role" select="''"/>
  1499. <xsl:param name="IDPrefix"/>
  1500. <xsl:choose>
  1501. <xsl:when test="$titleNode or @title">
  1502. <xsl:element name="{$elemTitled}">
  1503. <xsl:call-template name="setStandardAttr">
  1504. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1505. </xsl:call-template>
  1506. <xsl:choose>
  1507. <xsl:when test="$role!=''">
  1508. <xsl:attribute name="role">
  1509. <xsl:value-of select="$role"/>
  1510. </xsl:attribute>
  1511. </xsl:when>
  1512. </xsl:choose>
  1513. <xsl:choose>
  1514. <xsl:when test="$titleNode">
  1515. <xsl:apply-templates select="@title" mode="deflate"/>
  1516. <title>
  1517. <xsl:apply-templates select="$titleNode/*|$titleNode/text()"/>
  1518. </title>
  1519. </xsl:when>
  1520. <xsl:otherwise>
  1521. <title>
  1522. <xsl:value-of select="@title"/>
  1523. </title>
  1524. </xsl:otherwise>
  1525. </xsl:choose>
  1526. <xsl:apply-templates select="*[not(contains(@class,$titleSpec))]"/>
  1527. </xsl:element>
  1528. </xsl:when>
  1529. <xsl:otherwise>
  1530. <xsl:element name="{$elemUntitled}">
  1531. <xsl:call-template name="setStandardAttr">
  1532. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1533. </xsl:call-template>
  1534. <xsl:apply-templates/>
  1535. </xsl:element>
  1536. </xsl:otherwise>
  1537. </xsl:choose>
  1538. </xsl:template>
  1539. <xsl:template name="wrapTitle">
  1540. <xsl:param name="wrapElem"/>
  1541. <xsl:param name="coreElem"/>
  1542. <xsl:param name="titleSpec" select="' topic/title '"/>
  1543. <xsl:param name="titleNode" select="*[contains(@class,$titleSpec)]"/>
  1544. <xsl:param name="role" select="''"/>
  1545. <xsl:param name="IDPrefix"/>
  1546. <xsl:choose>
  1547. <xsl:when test="$titleNode or @title">
  1548. <xsl:element name="{$wrapElem}">
  1549. <xsl:call-template name="setStandardAttr">
  1550. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1551. </xsl:call-template>
  1552. <xsl:choose>
  1553. <xsl:when test="$role!=''">
  1554. <xsl:attribute name="role">
  1555. <xsl:value-of select="$role"/>
  1556. </xsl:attribute>
  1557. </xsl:when>
  1558. </xsl:choose>
  1559. <xsl:choose>
  1560. <xsl:when test="$titleNode">
  1561. <xsl:apply-templates select="@title" mode="deflate"/>
  1562. <title>
  1563. <xsl:apply-templates select="$titleNode/*|$titleNode/text()"/>
  1564. </title>
  1565. </xsl:when>
  1566. <xsl:otherwise>
  1567. <title>
  1568. <xsl:value-of select="@title"/>
  1569. </title>
  1570. </xsl:otherwise>
  1571. </xsl:choose>
  1572. <xsl:element name="{$coreElem}">
  1573. <xsl:apply-templates select="*[not(contains(@class,$titleSpec))]"/>
  1574. </xsl:element>
  1575. </xsl:element>
  1576. </xsl:when>
  1577. <xsl:otherwise>
  1578. <xsl:element name="{$coreElem}">
  1579. <xsl:call-template name="setStandardAttr">
  1580. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1581. </xsl:call-template>
  1582. <xsl:apply-templates/>
  1583. </xsl:element>
  1584. </xsl:otherwise>
  1585. </xsl:choose>
  1586. </xsl:template>
  1587. <xsl:template name="wrapLiteralTitle">
  1588. <xsl:param name="classAttr"/>
  1589. <xsl:param name="IDPrefix"/>
  1590. <xsl:choose>
  1591. <xsl:when test="@title">
  1592. <blockquote>
  1593. <xsl:call-template name="setStandardAttr">
  1594. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1595. </xsl:call-template>
  1596. <title>
  1597. <xsl:value-of select="@title"/>
  1598. </title>
  1599. <literallayout class="{$classAttr}">
  1600. <xsl:apply-templates/>
  1601. </literallayout>
  1602. </blockquote>
  1603. </xsl:when>
  1604. <xsl:otherwise>
  1605. <literallayout class="{$classAttr}">
  1606. <xsl:call-template name="setStandardAttr">
  1607. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1608. </xsl:call-template>
  1609. <xsl:apply-templates/>
  1610. </literallayout>
  1611. </xsl:otherwise>
  1612. </xsl:choose>
  1613. </xsl:template>
  1614. <xsl:template name="programtext">
  1615. <xsl:param name="IDPrefix" select="'prgtxt'"/>
  1616. <literal>
  1617. <xsl:call-template name="setStandardAttr">
  1618. <xsl:with-param name="IDPrefix" select="$IDPrefix"/>
  1619. </xsl:call-template>
  1620. <xsl:if test="@optreq">
  1621. <xsl:attribute name="role">
  1622. <xsl:value-of select="@optreq"/>
  1623. </xsl:attribute>
  1624. </xsl:if>
  1625. <xsl:apply-templates select="@convar" mode="deflate"/>
  1626. <xsl:apply-templates/>
  1627. </literal>
  1628. </xsl:template>
  1629. <xsl:template name="countsemcols">
  1630. <xsl:param name="row"/>
  1631. <xsl:variable name="cols" select="$row/*[
  1632. contains(@class,' topic/stentry ') or
  1633. contains(@class,' topic/sthead ')]"/>
  1634. <xsl:value-of select="count($cols)"/>
  1635. </xsl:template>
  1636. <xsl:template name="maxsemcol">
  1637. <xsl:param name="rows"/>
  1638. <xsl:param name="colcount" select="0"/>
  1639. <xsl:variable name="firstcount">
  1640. <xsl:call-template name="countsemcols">
  1641. <xsl:with-param name="row" select="$rows[position() = 1]"/>
  1642. </xsl:call-template>
  1643. </xsl:variable>
  1644. <xsl:variable name="newcount">
  1645. <xsl:choose>
  1646. <xsl:when test="$firstcount > $colcount">
  1647. <xsl:value-of select="$firstcount"/>
  1648. </xsl:when>
  1649. <xsl:otherwise>
  1650. <xsl:value-of select="$colcount"/>
  1651. </xsl:otherwise>
  1652. </xsl:choose>
  1653. </xsl:variable>
  1654. <xsl:variable name="restrows" select="$rows[position() > 1]"/>
  1655. <xsl:choose>
  1656. <xsl:when test="$restrows">
  1657. <xsl:call-template name="maxsemcol">
  1658. <xsl:with-param name="rows" select="$restrows"/>
  1659. <xsl:with-param name="colcount" select="$newcount"/>
  1660. </xsl:call-template>
  1661. </xsl:when>
  1662. <xsl:otherwise>
  1663. <xsl:value-of select="$newcount"/>
  1664. </xsl:otherwise>
  1665. </xsl:choose>
  1666. </xsl:template>
  1667. <!-- Add for "New <data> element (#9)" in DITA 1.1 -->
  1668. <xsl:template match="*[contains(@class,' topic/data ')]"/>
  1669. <!-- Add for "Support foreign content vocabularies such as
  1670. MathML and SVG with <unknown> (#35) " in DITA 1.1 -->
  1671. <xsl:template match="*[contains(@class,' topic/foreign ') or contains(@class,' topic/unknown ')]"/>
  1672. </xsl:stylesheet>