dita2rtfImpl.xsl 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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. 2005, 2006 All Rights Reserved. -->
  6. <xsl:stylesheet
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. version="2.0">
  9. <xsl:import href="plugin:org.dita.base:xsl/common/output-message.xsl"/>
  10. <xsl:import href="plugin:org.dita.base:xsl/common/dita-utilities.xsl"/>
  11. <xsl:import href="dita2rtf-utilities.xsl"/>
  12. <xsl:import href="dita2rtf-img.xsl"/>
  13. <xsl:import href="dita2rtf-parms.xsl"/>
  14. <xsl:import href="dita2rtf-table.xsl"/>
  15. <xsl:import href="dita2rtf-lists.xsl"/>
  16. <xsl:import href="hi-d.xsl"/>
  17. <xsl:import href="pr-d.xsl"/>
  18. <xsl:import href="ui-d.xsl"/>
  19. <xsl:import href="sw-d.xsl"/>
  20. <xsl:import href="markup-d.xsl"/>
  21. <xsl:import href="xml-d.xsl"/>
  22. <xsl:import href="dita2rtf-task.xsl"/>
  23. <xsl:output method="text"/>
  24. <xsl:strip-space elements="*"/>
  25. <xsl:param name="DRAFT" select="'no'"/>
  26. <xsl:param name="OUTPUTDIR" select="''"/>
  27. <!-- Deprecated since 2.3 -->
  28. <xsl:variable name="msgprefix">DOTX</xsl:variable>
  29. <xsl:template match="/">
  30. <xsl:call-template name="root"/>
  31. </xsl:template>
  32. <xsl:template match="*[contains(@class,' topic/topic ')]">
  33. <xsl:call-template name="gen-id"/>
  34. <xsl:apply-templates/>
  35. </xsl:template>
  36. <xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]">
  37. <xsl:call-template name="gen-id"/>
  38. <xsl:variable name="depth">
  39. <xsl:value-of select="count(ancestor::*[contains(@class,' topic/topic ')])"/>
  40. </xsl:variable>
  41. <xsl:call-template name="block-title">
  42. <xsl:with-param name="depth" select="$depth"/>
  43. </xsl:call-template>
  44. </xsl:template>
  45. <xsl:template match="*[contains(@class,' topic/section ')]/*[contains(@class,' topic/title ')]">
  46. <xsl:call-template name="gen-id"/>\par \plain\f4\fs36\b <xsl:apply-templates/>
  47. \par \plain\f2\fs24
  48. </xsl:template>
  49. <xsl:template match="synsect">
  50. \par \plain\f4\fs36\b Syntax
  51. \par \plain\f2\fs24
  52. <xsl:apply-templates/>
  53. </xsl:template>
  54. <xsl:template match="*[contains(@class,' topic/section ')]">
  55. <xsl:call-template name="gen-id"/>\par \pard \s0\f2\fs24 <xsl:apply-templates/>
  56. </xsl:template>
  57. <xsl:template match="*[contains(@class,' topic/example ')]">
  58. <xsl:call-template name="gen-id"/>\par \pard \s0\f2\fs24 <xsl:apply-templates/>
  59. </xsl:template>
  60. <xsl:template match="*[contains(@class,' topic/example ')]/*[contains(@class,' topic/title ')]">
  61. <xsl:call-template name="gen-id"/>\plain\f4\fs24\b <xsl:apply-templates/>\par \plain\f2\fs24
  62. </xsl:template>
  63. <!-- =========== block things ============ -->
  64. <xsl:template match="*[contains(@class,' topic/p ')]">
  65. <xsl:call-template name="gen-id"/><xsl:call-template name="block-p"/>
  66. </xsl:template>
  67. <!--xsl:template match="*[contains(@class,' topic/lq ')]">
  68. <xsl:call-template name="gen-id"/><xsl:call-template name="block-lq"/>
  69. </xsl:template-->
  70. <!-- phrases -->
  71. <xsl:template match="*[contains(@class,' hi-d/tt ')]">
  72. <xsl:call-template name="inline-em"/>
  73. </xsl:template>
  74. <xsl:template match="*[contains(@class,' topic/q ')]"><xsl:call-template name="gen-id"/><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'OpenQuote'"/></xsl:call-template><xsl:apply-templates/><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'CloseQuote'"/></xsl:call-template></xsl:template>
  75. <!-- named template library -->
  76. <xsl:template name="br-replace">
  77. <xsl:param name="word"/>
  78. <!-- </xsl:text> on next line on purpose to get newline -->
  79. <xsl:variable name="cr"><xsl:text>\n
  80. </xsl:text></xsl:variable>
  81. <xsl:choose>
  82. <xsl:when test="contains($word,$cr)">
  83. <xsl:value-of select="substring-before($word,$cr)"/>
  84. <br/>
  85. <xsl:call-template name="br-replace">
  86. <xsl:with-param name="word"
  87. select="substring-after($word,$cr)"/>
  88. </xsl:call-template>
  89. </xsl:when>
  90. <xsl:otherwise>
  91. <xsl:value-of select="$word"/>
  92. </xsl:otherwise>
  93. </xsl:choose>
  94. </xsl:template>
  95. <!-- standard RTF library mapped to formatting objects -->
  96. <xsl:template name="root">{\rtf1\ansi\ansicpg<xsl:value-of select="$code-page"/>\deff0\deftab720\deflang1033\deflangfe2052{\fonttbl{\f0\fswiss MS Sans Serif;}
  97. {\f1\froman\fcharset2 Symbol;}
  98. {\f2\froman Times New Roman;}
  99. {\f3\froman Times New Roman;}
  100. {\f4\fswiss Arial;}
  101. {\f5\fmono Courier New;}
  102. {\f10\fnil\fcharset2{\*\panose 05000000000000000000}Wingdings;}
  103. {\f13\fnil\fcharset134 \'cb\'ce\'cc\'e5{\*\falt SimSun};}}
  104. {\colortbl\red0\green0\blue0;\red0\green0\blue255;\red128\green128\blue128;\red255\green0\blue0;\red0\green255\blue0;}
  105. {\stylesheet{\s0 \f2\fs24 Normal;}
  106. {\s1 \f4\fs48\b heading 1;}
  107. {\s2 \f4\fs36\b heading 2;}
  108. {\s3 \f4\fs24\b heading 3;}
  109. {\s4 \f4\fs20\b heading 4;}
  110. {\s5 \f4\fs18\b heading 5;}
  111. {\s6 \f4\fs16\b heading 6;}
  112. {\s7 \f4\fs24\b table header;}
  113. {\s8 \f2\fs24 link;}
  114. {\s9 \f4\fs24\b table title;}}<xsl:call-template name="gen-list-table"/>
  115. <xsl:apply-templates/>}</xsl:template>
  116. <xsl:template name="block-title">
  117. <xsl:param name="depth"/>
  118. <xsl:choose>
  119. <xsl:when test="$depth='1'">
  120. <xsl:call-template name="block-title-h1"/>
  121. </xsl:when>
  122. <xsl:when test="$depth='2'">
  123. <xsl:call-template name="block-title-h2"/>
  124. </xsl:when>
  125. <xsl:when test="$depth='3'">
  126. <xsl:call-template name="block-title-h3"/>
  127. </xsl:when>
  128. <xsl:when test="$depth='4'">
  129. <xsl:call-template name="block-title-h4"/>
  130. </xsl:when>
  131. <xsl:when test="$depth='5'">
  132. <xsl:call-template name="block-title-h5"/>
  133. </xsl:when>
  134. <xsl:otherwise>
  135. <xsl:call-template name="block-title-h6"/>
  136. </xsl:otherwise>
  137. </xsl:choose>
  138. </xsl:template>
  139. <!-- font-size="24pt"
  140. font-weight="bold"
  141. space-before.optimum="16pt"
  142. space-after.optimum="12pt" -->
  143. <xsl:template name="block-title-h1">
  144. \par \pard\plain\s1\f4\fs48\b <xsl:apply-templates/>
  145. \par \plain\f2\fs24
  146. </xsl:template>
  147. <!-- font-size="16pt"
  148. font-weight="bold"
  149. space-before.optimum="14pt"
  150. space-after.optimum="14pt" \pard\li720\fi-360-->
  151. <xsl:template name="block-title-h2">
  152. \par \plain\s2\f4\fs36\b <xsl:apply-templates/>
  153. \par \plain\f2\fs24
  154. </xsl:template>
  155. <xsl:template name="block-title-h3">
  156. \par \plain\s3\f4\fs24\b <xsl:apply-templates/>
  157. \par \plain\f2\fs24
  158. </xsl:template>
  159. <xsl:template name="block-title-h4">
  160. \par \plain\s4\f4\fs20\b <xsl:apply-templates/>
  161. \par \plain\f2\fs24
  162. </xsl:template>
  163. <xsl:template name="block-title-h5">
  164. \par \plain\s5\f4\fs18\b <xsl:apply-templates/>
  165. \par \plain\f2\fs24
  166. </xsl:template>
  167. <xsl:template name="block-title-h6">
  168. \par \plain\s6\f4\fs16\b <xsl:apply-templates/>
  169. \par \plain\f2\fs24
  170. </xsl:template>
  171. <!-- space-before.optimum="8pt"
  172. space-after.optimum="8pt" -->
  173. <xsl:template name="block-p">
  174. <!-- Tagsmiths: Suppress \par \pard when the context is first p in li -->
  175. <xsl:choose>
  176. <xsl:when test="parent::*[contains(@class,' topic/li ')] and position() = 1">
  177. <!-- Tagsmiths: this next line resets the style, font, and size to
  178. the same values used in by p in other contexts. -->
  179. <xsl:text>\s0\f2\fs24 </xsl:text>
  180. </xsl:when>
  181. <xsl:otherwise>
  182. <!-- Tagsmiths: this next line used to appear unconditionally -->
  183. <xsl:text>\par \pard \s0\f2\fs24</xsl:text>
  184. </xsl:otherwise>
  185. </xsl:choose>
  186. <xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl</xsl:if>
  187. <!-- Tagsmiths: make the inserted space conditional, suppressing it for first p in li -->
  188. <xsl:if test="parent::*[not(contains(@class,' topic/li '))] or position() != 1">
  189. <xsl:text> </xsl:text>
  190. </xsl:if><xsl:apply-templates/>
  191. <!-- Tagsmiths: make the next rtf string conditional, suppressing it for first p in li -->
  192. <xsl:if test="parent::*[not(contains(@class,' topic/li '))] or position() != 1">
  193. <xsl:text>\par</xsl:text>
  194. </xsl:if>
  195. </xsl:template>
  196. <xsl:template name="block-lq">
  197. \par \pard\li720\fi-360\plain\f2\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if>
  198. <xsl:apply-templates/>
  199. \par
  200. </xsl:template>
  201. <xsl:template match="*[contains(@class,' topic/lq ')]" name="topic.lq">
  202. <xsl:variable name="samefile">
  203. <xsl:choose>
  204. <xsl:when test="@href and starts-with(@href,'#')">
  205. <xsl:value-of select="'true'"/>
  206. </xsl:when>
  207. <xsl:otherwise>
  208. <xsl:value-of select="'false'"/>
  209. </xsl:otherwise>
  210. </xsl:choose>
  211. </xsl:variable>
  212. <xsl:variable name="href-value">
  213. <xsl:choose>
  214. <xsl:when test="@href and starts-with(@href,'#')">
  215. <xsl:choose>
  216. <xsl:when test="contains(@href,'/')">
  217. <xsl:value-of select="substring-after(@href,'/')"/>
  218. </xsl:when>
  219. <xsl:otherwise>
  220. <xsl:value-of select="substring-after(@href,'#')"/>
  221. </xsl:otherwise>
  222. </xsl:choose>
  223. </xsl:when>
  224. <xsl:when test="@href and contains(@href,'#')">
  225. <xsl:value-of select="substring-before(@href,'#')"/>
  226. </xsl:when>
  227. <xsl:when test="@href and not(@href='')">
  228. <xsl:value-of select="@href"/>
  229. </xsl:when>
  230. </xsl:choose>
  231. </xsl:variable>
  232. <xsl:apply-templates/>
  233. <xsl:choose>
  234. <xsl:when test="@href and not(@href='')"> <!-- Insert citation as link, use @href as-is -->
  235. \par\pard\plain\qr\f2\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or
  236. contains(@class,' topic/simpletable ')]">\intbl </xsl:if>{\field{\*\fldinst {\s8 \f2\fs24\ul\cf1
  237. HYPERLINK <xsl:if test="$samefile='true'">\\l</xsl:if> "<xsl:value-of
  238. select="$href-value"/>"}}{\fldrslt {\s8 \f2\fs24\ul\cf1 <xsl:choose><xsl:when
  239. test="@reftitle"><xsl:value-of
  240. select="@reftitle"/></xsl:when><xsl:otherwise><xsl:value-of select="@href"/></xsl:otherwise></xsl:choose>\s8 \f2\fs24\ul\cf1}}}\par\pard\ql\f2\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if>
  241. </xsl:when>
  242. <xsl:when test="@reftitle and not(@reftitle='')"> <!-- Insert citation text -->
  243. \par\pard\plain\qr\f2\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or
  244. contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:value-of select="@reftitle"/>\par\pard\ql\f2\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if></xsl:when>
  245. <xsl:otherwise><!--nop - do nothing--></xsl:otherwise>
  246. </xsl:choose>
  247. </xsl:template>
  248. <!-- font-weight="bold" -->
  249. <xsl:template name="inline-em">{\b <xsl:apply-templates/>}</xsl:template>
  250. <!-- link-like -->
  251. <xsl:template name="inline-link">\plain\f2\fs24\cf1\ul <xsl:apply-templates/>\plain\f2\fs24 </xsl:template>
  252. <xsl:template name="gen-id">
  253. <xsl:choose>
  254. <xsl:when test="@id and not(id='')">
  255. <xsl:call-template name="gen-bookmark">
  256. <xsl:with-param name="name" select="@id"/>
  257. </xsl:call-template>
  258. </xsl:when>
  259. </xsl:choose>
  260. </xsl:template>
  261. <xsl:template name="gen-bookmark">
  262. <xsl:param name="name"><xsl:value-of select="."/></xsl:param>
  263. {\bkmkstart <xsl:value-of select="$name"/>}{\bkmkend <xsl:value-of select="$name"/>}
  264. </xsl:template>
  265. <xsl:template match="*[contains(@class,' topic/xref ')]|*[contains(@class,' topic/link ')]">
  266. <xsl:variable name="samefile">
  267. <xsl:choose>
  268. <xsl:when test="@href and starts-with(@href,'#')">
  269. <xsl:value-of select="'true'"/>
  270. </xsl:when>
  271. <xsl:otherwise>
  272. <xsl:value-of select="'false'"/>
  273. </xsl:otherwise>
  274. </xsl:choose>
  275. </xsl:variable>
  276. <xsl:variable name="href-value">
  277. <xsl:choose>
  278. <xsl:when test="@href and starts-with(@href,'#')">
  279. <xsl:choose>
  280. <xsl:when test="contains(@href,'/')">
  281. <xsl:value-of select="substring-after(@href,'/')"/>
  282. </xsl:when>
  283. <xsl:otherwise>
  284. <xsl:value-of select="substring-after(@href,'#')"/>
  285. </xsl:otherwise>
  286. </xsl:choose>
  287. </xsl:when>
  288. <xsl:when test="@href and contains(@href,'#')">
  289. <xsl:value-of select="substring-before(@href,'#')"/>
  290. </xsl:when>
  291. <xsl:when test="@href and not(@href='')">
  292. <xsl:value-of select="@href"/>
  293. </xsl:when>
  294. </xsl:choose>
  295. </xsl:variable>
  296. <xsl:call-template name="gen-id"/>
  297. <xsl:choose>
  298. <xsl:when test="@href and not(@href='')"><xsl:if test="not(preceding-sibling::*[contains(@class,' topic/link ')]) and contains(@class,' topic/link ')">\par </xsl:if>
  299. {\field{\*\fldinst {\s8 \f2\fs24\ul\cf1 HYPERLINK <xsl:if test="$samefile='true'">\\l</xsl:if>
  300. "<xsl:value-of select="$href-value"/>"}}{\fldrslt {\s8 \f2\fs24\ul\cf1 <xsl:call-template
  301. name="gen-linktxt"/>\s8 \f2\fs24\ul\cf1}}}\s8
  302. <xsl:if test="contains(@class,' topic/link ')"><xsl:apply-templates select="*[contains(@class,' topic/desc ')]"/>\par </xsl:if>
  303. </xsl:when>
  304. <xsl:otherwise>
  305. <xsl:call-template name="output-message">
  306. <xsl:with-param name="id" select="'DOTX028E'"/>
  307. </xsl:call-template>
  308. </xsl:otherwise>
  309. </xsl:choose>
  310. </xsl:template>
  311. <xsl:template match="*[contains(@class,' topic/cite ')]">
  312. <xsl:text>{\i </xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text>
  313. </xsl:template>
  314. <xsl:template match="*[contains(@class,' topic/desc ')]">
  315. <xsl:if test="../@role='child'">\par \plain\s0\f4\fs24 <xsl:apply-templates/>
  316. \plain\s0\f2\fs24 </xsl:if>
  317. </xsl:template>
  318. <xsl:template name="gen-linktxt">
  319. <xsl:choose>
  320. <xsl:when test="contains(@class,' topic/xref ')">
  321. <xsl:choose>
  322. <xsl:when test="text() or *">
  323. <xsl:apply-templates/>
  324. </xsl:when>
  325. <xsl:otherwise>
  326. <xsl:value-of select="@href"/>
  327. </xsl:otherwise>
  328. </xsl:choose>
  329. </xsl:when>
  330. <xsl:when test="contains(@class,' topic/link ')">
  331. <xsl:choose>
  332. <xsl:when test="*[contains(@class,' topic/linktext ')]">
  333. <xsl:value-of select="*[contains(@class,' topic/linktext ')]"/>
  334. </xsl:when>
  335. <xsl:when test="text()">
  336. <xsl:value-of select="text()"/>
  337. </xsl:when>
  338. <xsl:otherwise>
  339. <xsl:value-of select="@href"/>
  340. </xsl:otherwise>
  341. </xsl:choose>
  342. </xsl:when>
  343. </xsl:choose>
  344. </xsl:template>
  345. <xsl:template match="*[contains(@class,' topic/prolog ')]"/>
  346. <xsl:template match="*[contains(@class,' topic/titlealts ')]"/>
  347. <!-- Added for DITA 1.1 "Shortdesc proposal" -->
  348. <xsl:template match="*[contains(@class,' topic/abstract ')]">
  349. <xsl:apply-templates/>\par
  350. </xsl:template>
  351. <xsl:template match="*[contains(@class,' topic/shortdesc ')]">
  352. <xsl:apply-templates/>\par
  353. </xsl:template>
  354. <xsl:template match="*[contains(@class,' topic/note ')]" name="topic.note">
  355. <xsl:choose>
  356. <xsl:when test="@type='note'">
  357. \par \plain\s0\f4\fs24\b <xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'Note'"/></xsl:call-template><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text>\pard \plain\s0\f4\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:apply-templates/>
  358. \par \plain\s0\f2\fs24
  359. </xsl:when>
  360. <xsl:when test="@type='tip'">
  361. \par \plain\s0\f4\fs24\b <xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'Tip'"/></xsl:call-template><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text>\pard \plain\s0\f4\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:apply-templates/>
  362. \par \plain\s0\f2\fs24
  363. </xsl:when>
  364. <xsl:when test="@type='fastpath'">
  365. \par \plain\s0\f4\fs24\b <xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'Fastpath'"/></xsl:call-template><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text>\pard \plain\s0\f4\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:apply-templates/>
  366. \par \plain\s0\f2\fs24
  367. </xsl:when>
  368. <xsl:when test="@type='important'">
  369. \par \plain\s0\f4\fs24\b <xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'Important'"/></xsl:call-template><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text>\pard \plain\s0\f4\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:apply-templates/>
  370. \par \plain\s0\f2\fs24
  371. </xsl:when>
  372. <xsl:when test="@type='remember'">
  373. \par \plain\s0\f4\fs24\b <xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'Remember'"/></xsl:call-template><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text>\pard \plain\s0\f4\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:apply-templates/>
  374. \par \plain\s0\f2\fs24
  375. </xsl:when>
  376. <xsl:when test="@type='restriction'">
  377. \par \plain\s0\f4\fs24\b <xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'Restriction'"/></xsl:call-template><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text>\pard \plain\s0\f4\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:apply-templates/>
  378. \par \plain\s0\f2\fs24
  379. </xsl:when>
  380. <xsl:when test="@type='attention'">
  381. \par \plain\s0\f4\fs24\b <xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'Attention'"/></xsl:call-template><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text>\pard \plain\s0\f4\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:apply-templates/>
  382. \par \plain\s0\f2\fs24
  383. </xsl:when>
  384. <xsl:when test="@type='caution'">
  385. \par \plain\s0\f4\fs24\b <xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'Caution'"/></xsl:call-template><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text>\pard \plain\s0\f4\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:apply-templates/>
  386. \par \plain\s0\f2\fs24
  387. </xsl:when>
  388. <xsl:when test="@type='danger'">
  389. \par \plain\s0\f4\fs24\b <xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'Danger'"/></xsl:call-template><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text>\pard \plain\s0\f4\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:apply-templates/>
  390. \par \plain\s0\f2\fs24
  391. </xsl:when>
  392. <xsl:when test="@type='trouble'">
  393. \par \plain\s0\f4\fs24\b <xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'Trouble'"/></xsl:call-template><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text>\pard \plain\s0\f4\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:apply-templates/>
  394. \par \plain\s0\f2\fs24
  395. </xsl:when>
  396. <xsl:when test="@type='other'">
  397. \par \plain\s0\f4\fs24\b <xsl:choose><xsl:when test="@othertype and
  398. not(@othertype='')"><xsl:value-of select="@othertype"/></xsl:when><xsl:otherwise><xsl:text>[other]</xsl:text></xsl:otherwise></xsl:choose><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text>\pard \plain\s0\f4\fs24<xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl </xsl:if><xsl:apply-templates/>
  399. \par \plain\s0\f2\fs24
  400. </xsl:when>
  401. <xsl:otherwise>
  402. <xsl:apply-templates/>
  403. </xsl:otherwise>
  404. </xsl:choose>
  405. </xsl:template>
  406. <xsl:template match="text()[contains(.,'\') or contains(.,'{') or contains(.,'}')]">
  407. <xsl:variable name="gentext">
  408. <xsl:call-template name="gen-txt1">
  409. <xsl:with-param name="txt" select="."/>
  410. </xsl:call-template>
  411. </xsl:variable>
  412. <xsl:choose>
  413. <xsl:when test="ancestor::*[contains(@class,' topic/pre ')] or ancestor::*[contains(@class,' topic/lines ')]">
  414. <xsl:value-of select="$gentext"/>
  415. </xsl:when>
  416. <xsl:otherwise>
  417. <xsl:if test="starts-with($gentext,' ')"><xsl:text> </xsl:text></xsl:if><xsl:value-of select="normalize-space($gentext)"/><xsl:if test="substring($gentext,string-length($gentext))=' '"><xsl:text> </xsl:text></xsl:if>
  418. </xsl:otherwise>
  419. </xsl:choose>
  420. </xsl:template>
  421. <xsl:template name="gen-txt1">
  422. <xsl:param name="txt"/>
  423. <xsl:choose>
  424. <xsl:when test="not(contains($txt,'\'))">
  425. <xsl:call-template name="gen-txt2">
  426. <xsl:with-param name="txt" select="$txt"/>
  427. </xsl:call-template>
  428. </xsl:when>
  429. <xsl:otherwise>
  430. <xsl:call-template name="gen-txt2">
  431. <xsl:with-param name="txt" select="substring-before($txt,'\')"/>
  432. </xsl:call-template>
  433. <xsl:text>\\</xsl:text>
  434. <xsl:call-template name="gen-txt1">
  435. <xsl:with-param name="txt" select="substring-after($txt,'\')"/>
  436. </xsl:call-template>
  437. </xsl:otherwise>
  438. </xsl:choose>
  439. </xsl:template>
  440. <xsl:template name="gen-txt2">
  441. <xsl:param name="txt"/>
  442. <xsl:choose>
  443. <xsl:when test="not(contains($txt,'{'))">
  444. <xsl:call-template name="gen-txt3">
  445. <xsl:with-param name="txt" select="$txt"/>
  446. </xsl:call-template>
  447. </xsl:when>
  448. <xsl:otherwise>
  449. <xsl:call-template name="gen-txt3">
  450. <xsl:with-param name="txt" select="substring-before($txt,'{')"/>
  451. </xsl:call-template>
  452. <xsl:text>\{</xsl:text>
  453. <xsl:call-template name="gen-txt2">
  454. <xsl:with-param name="txt" select="substring-after($txt,'{')"/>
  455. </xsl:call-template>
  456. </xsl:otherwise>
  457. </xsl:choose>
  458. </xsl:template>
  459. <xsl:template name="gen-txt3">
  460. <xsl:param name="txt"/>
  461. <xsl:choose>
  462. <xsl:when test="not(contains($txt,'}'))">
  463. <xsl:call-template name="gen-txt">
  464. <xsl:with-param name="txt" select="$txt"/>
  465. </xsl:call-template>
  466. </xsl:when>
  467. <xsl:otherwise>
  468. <xsl:call-template name="gen-txt">
  469. <xsl:with-param name="txt" select="substring-before($txt,'}')"/>
  470. </xsl:call-template>
  471. <xsl:text>\}</xsl:text>
  472. <xsl:call-template name="gen-txt3">
  473. <xsl:with-param name="txt" select="substring-after($txt,'}')"/>
  474. </xsl:call-template>
  475. </xsl:otherwise>
  476. </xsl:choose>
  477. </xsl:template>
  478. <xsl:template name="gen-txt">
  479. <xsl:param name="txt"/>
  480. <xsl:variable name="newline"><xsl:text>
  481. </xsl:text></xsl:variable>
  482. <xsl:choose>
  483. <xsl:when test="ancestor::*[contains(@class,' topic/pre ')] or ancestor::*[contains(@class,' topic/lines ')]">
  484. <xsl:choose>
  485. <xsl:when test="contains($txt,$newline)">
  486. <xsl:value-of select="substring-before($txt,$newline)"/><xsl:text>\par </xsl:text><xsl:call-template name="gen-txt"><xsl:with-param name="txt" select="substring-after($txt,$newline)"/></xsl:call-template>
  487. </xsl:when>
  488. <xsl:otherwise>
  489. <xsl:value-of select="$txt"/>
  490. </xsl:otherwise>
  491. </xsl:choose>
  492. </xsl:when>
  493. <xsl:otherwise>
  494. <xsl:value-of select="$txt"/>
  495. </xsl:otherwise>
  496. </xsl:choose>
  497. </xsl:template>
  498. <xsl:template match="text()">
  499. <xsl:choose>
  500. <xsl:when test="ancestor::*[contains(@class,' topic/pre ')] or ancestor::*[contains(@class,' topic/lines ')]">
  501. <xsl:call-template name="gen-txt"><xsl:with-param name="txt" select="."/></xsl:call-template>
  502. </xsl:when>
  503. <xsl:otherwise>
  504. <xsl:if test="normalize-space(substring(., 1, 1))='' and not(normalize-space(.)='')"><xsl:text> </xsl:text></xsl:if>
  505. <xsl:value-of select="normalize-space(.)"/>
  506. <xsl:if test="normalize-space(substring(.,
  507. string-length(.), 1))='' and not(normalize-space(.)='')"><xsl:text> </xsl:text></xsl:if>
  508. </xsl:otherwise>
  509. </xsl:choose>
  510. </xsl:template>
  511. <xsl:template match="*[contains(@class,' topic/draft-comment ')]">
  512. <xsl:if test="$DRAFT='yes'">
  513. <xsl:text>\par \plain\s0\f4\fs24\cb3\b </xsl:text><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'Draft comment'"/></xsl:call-template><xsl:call-template name="getStringRTF"><xsl:with-param name="stringName" select="'ColonSymbol'"/></xsl:call-template><xsl:text> </xsl:text><xsl:text>\pard \plain\s0\f4\fs24\cb3</xsl:text><xsl:if test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">\intbl</xsl:if><xsl:text> </xsl:text><xsl:apply-templates/><xsl:text>\par \plain\s0\f2\fs24</xsl:text>
  514. </xsl:if>
  515. </xsl:template>
  516. <xsl:template match="*[contains(@class,' topic/boolean ')]">
  517. <xsl:text>{\plain\s0\f4\fs24\cf4 boolean: </xsl:text><xsl:value-of select="@state"/><xsl:text>}</xsl:text>
  518. </xsl:template>
  519. <xsl:template match="*[contains(@class,' topic/state ')]">
  520. <xsl:text>{\plain\s0\f4\fs24\cf3 </xsl:text>
  521. <xsl:value-of select="name()"/><xsl:text>: </xsl:text><xsl:value-of select="@name"/><xsl:text>=</xsl:text><xsl:value-of select="@value"/>
  522. <xsl:text>}</xsl:text>
  523. </xsl:template>
  524. <xsl:template match="*[contains(@class,' topic/tm ')]">
  525. <xsl:text>{\plain\s0\f4\fs24 </xsl:text><xsl:apply-templates/>
  526. <xsl:choose>
  527. <xsl:when test="@tmtype='tm'">
  528. <xsl:text>{\super (TM)}</xsl:text>
  529. </xsl:when>
  530. <xsl:when test="@tmtype='service'">
  531. <xsl:text>{\super (SM)}</xsl:text>
  532. </xsl:when>
  533. <xsl:when test="@tmtype='reg'">
  534. <xsl:text>{\super (R)}</xsl:text>
  535. </xsl:when>
  536. </xsl:choose>
  537. <xsl:text>}</xsl:text>
  538. </xsl:template>
  539. <xsl:template
  540. match="*[contains(@class,' topic/required-cleanup ')]">
  541. <xsl:if test="$DRAFT='yes'">
  542. <xsl:text>\par \plain\s0\f4\fs24\cb3\b</xsl:text>
  543. <xsl:call-template name="getStringRTF">
  544. <xsl:with-param name="stringName" select="'Required cleanup'" />
  545. </xsl:call-template>
  546. <xsl:call-template name="getStringRTF">
  547. <xsl:with-param name="stringName" select="'ColonSymbol'" />
  548. </xsl:call-template>
  549. <xsl:text></xsl:text>
  550. <xsl:text>\pard \plain\s0\f4\fs24\cb3</xsl:text>
  551. <xsl:if
  552. test="ancestor::*[contains(@class,' topic/table ') or contains(@class,' topic/simpletable ')]">
  553. \intbl
  554. </xsl:if>
  555. <xsl:apply-templates />
  556. <xsl:text>\par \plain\s0\f2\fs24</xsl:text>
  557. </xsl:if>
  558. </xsl:template>
  559. <!-- Add for "New <data> element (#9)" in DITA 1.1 -->
  560. <xsl:template match="*[contains(@class,' topic/data ')]" />
  561. <!-- Add for "Support foreign content vocabularies such as
  562. MathML and SVG with <unknown> (#35) " in DITA 1.1 -->
  563. <xsl:template match="*[contains(@class,' topic/foreign ') or contains(@class,' topic/unknown ')]" />
  564. </xsl:stylesheet>