pr-d.xsl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!-- This file is part of the DITA Open Toolkit project.
  3. See the accompanying license.txt file for applicable licenses. -->
  4. <!-- (c) Copyright IBM Corp. 2005 All Rights Reserved. -->
  5. <xsl:stylesheet
  6. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  8. xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  9. xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  10. xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  11. xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  12. xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  13. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/"
  14. xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  15. xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
  16. xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  17. xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  18. xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  19. xmlns:math="http://www.w3.org/1998/Math/MathML"
  20. xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  21. xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  22. xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms"
  23. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  24. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  25. xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
  26. xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
  27. xmlns:prodtools="http://www.ibm.com/xmlns/prodtools"
  28. version="2.0">
  29. <xsl:template match="*[contains(@class,' pr-d/codeph ')]">
  30. <xsl:choose>
  31. <xsl:when test="parent::*[contains(@class, ' topic/li ')] or parent::*[contains(@class, ' topic/sli ')]">
  32. <text:p>
  33. <text:span text:style-name="Courier_New">
  34. <text:span>
  35. <!-- start add rev flagging styles -->
  36. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  37. <xsl:apply-templates/>
  38. <!-- end add rev flagging styles -->
  39. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  40. </text:span>
  41. </text:span>
  42. </text:p>
  43. </xsl:when>
  44. <!-- nested by entry -->
  45. <xsl:when test="parent::*[contains(@class, ' topic/entry ')]">
  46. <!-- create p tag -->
  47. <text:p>
  48. <!-- alignment styles -->
  49. <xsl:if test="parent::*[contains(@class, ' topic/entry ')]/@align">
  50. <xsl:call-template name="set_align_value"/>
  51. </xsl:if>
  52. <!-- cell belongs to thead -->
  53. <xsl:choose>
  54. <xsl:when test="parent::*[contains(@class, ' topic/entry ')] /parent::*[contains(@class, ' topic/row ')]/parent::*[contains(@class, ' topic/thead ')]">
  55. <text:span text:style-name="bold">
  56. <text:span text:style-name="Courier_New">
  57. <text:span>
  58. <!-- start add rev flagging styles -->
  59. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  60. <xsl:apply-templates/>
  61. <!-- end add rev flagging styles -->
  62. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  63. </text:span>
  64. </text:span>
  65. </text:span>
  66. </xsl:when>
  67. <xsl:otherwise>
  68. <text:span text:style-name="Courier_New">
  69. <text:span>
  70. <!-- start add rev flagging styles -->
  71. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  72. <xsl:apply-templates/>
  73. <!-- end add rev flagging styles -->
  74. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  75. </text:span>
  76. </text:span>
  77. </xsl:otherwise>
  78. </xsl:choose>
  79. </text:p>
  80. </xsl:when>
  81. <!-- nested by stentry -->
  82. <xsl:when test="parent::*[contains(@class, ' topic/stentry ')]">
  83. <text:p>
  84. <!-- cell belongs to sthead -->
  85. <xsl:choose>
  86. <xsl:when test="parent::*[contains(@class, ' topic/stentry ')]/ parent::*[contains(@class, ' topic/sthead ')]">
  87. <text:span text:style-name="bold">
  88. <text:span text:style-name="Courier_New">
  89. <text:span>
  90. <!-- start add rev flagging styles -->
  91. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  92. <xsl:apply-templates/>
  93. <!-- end add rev flagging styles -->
  94. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  95. </text:span>
  96. </text:span>
  97. </text:span>
  98. </xsl:when>
  99. <xsl:otherwise>
  100. <text:span text:style-name="Courier_New">
  101. <text:span>
  102. <!-- start add rev flagging styles -->
  103. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  104. <xsl:apply-templates/>
  105. <!-- end add rev flagging styles -->
  106. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  107. </text:span>
  108. </text:span>
  109. </xsl:otherwise>
  110. </xsl:choose>
  111. </text:p>
  112. </xsl:when>
  113. <!-- nested by other tags -->
  114. <xsl:otherwise>
  115. <text:span text:style-name="Courier_New">
  116. <text:span>
  117. <!-- start add rev flagging styles -->
  118. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  119. <xsl:apply-templates/>
  120. <!-- end add rev flagging styles -->
  121. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  122. </text:span>
  123. </text:span>
  124. </xsl:otherwise>
  125. </xsl:choose>
  126. </xsl:template>
  127. <xsl:template match="*[contains(@class,' pr-d/codeblock ')]" name="create_codeblock">
  128. <xsl:choose>
  129. <xsl:when test="parent::*[contains(@class, ' topic/itemgroup ')]">
  130. <text:span>
  131. <!-- start add flagging styles -->
  132. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  133. <xsl:call-template name="create_spec_title"/>
  134. <xsl:apply-templates/>
  135. <!-- end add flagging styles -->
  136. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  137. </text:span>
  138. <text:line-break/>
  139. </xsl:when>
  140. <xsl:when test="parent::*[contains(@class, ' topic/li ')] or parent::*[contains(@class, ' topic/sli ')]">
  141. <text:p text:style-name="Code_Style_Paragraph">
  142. <text:span>
  143. <!-- start add flagging styles -->
  144. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  145. <xsl:call-template name="create_spec_title"/>
  146. <xsl:apply-templates/>
  147. <!-- end add flagging styles -->
  148. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  149. </text:span>
  150. </text:p>
  151. </xsl:when>
  152. <xsl:when test="parent::*[contains(@class, ' topic/body ')]">
  153. <text:p text:style-name="Code_Style_Paragraph">
  154. <text:span>
  155. <!-- start add flagging styles -->
  156. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  157. <xsl:call-template name="create_spec_title"/>
  158. <xsl:apply-templates/>
  159. <!-- end add flagging styles -->
  160. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  161. </text:span>
  162. </text:p>
  163. </xsl:when>
  164. <!-- nested by entry -->
  165. <xsl:when test="parent::*[contains(@class, ' topic/entry ')]">
  166. <!-- create p tag -->
  167. <text:p>
  168. <!-- alignment styles -->
  169. <xsl:if test="parent::*[contains(@class, ' topic/entry ')]/@align">
  170. <xsl:call-template name="set_align_value"/>
  171. </xsl:if>
  172. <!-- cell belongs to thead -->
  173. <xsl:choose>
  174. <xsl:when test="parent::*[contains(@class, ' topic/entry ')] /parent::*[contains(@class, ' topic/row ')]/parent::*[contains(@class, ' topic/thead ')]">
  175. <text:span text:style-name="bold">
  176. <text:span>
  177. <!-- start add flagging styles -->
  178. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  179. <xsl:call-template name="create_spec_title"/>
  180. <xsl:apply-templates/>
  181. <!-- end add flagging styles -->
  182. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  183. </text:span>
  184. </text:span>
  185. </xsl:when>
  186. <xsl:otherwise>
  187. <text:span text:style-name="Code_Text">
  188. <text:span>
  189. <!-- start add flagging styles -->
  190. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  191. <xsl:call-template name="create_spec_title"/>
  192. <xsl:apply-templates/>
  193. <!-- end add flagging styles -->
  194. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  195. </text:span>
  196. </text:span>
  197. </xsl:otherwise>
  198. </xsl:choose>
  199. </text:p>
  200. </xsl:when>
  201. <!-- nested by stentry -->
  202. <xsl:when test="parent::*[contains(@class, ' topic/stentry ')]">
  203. <text:p text:style-name="indent_paragraph_style">
  204. <!-- cell belongs to sthead -->
  205. <xsl:choose>
  206. <xsl:when test="parent::*[contains(@class, ' topic/stentry ')]/ parent::*[contains(@class, ' topic/sthead ')]">
  207. <text:span text:style-name="bold">
  208. <text:span>
  209. <!-- start add flagging styles -->
  210. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  211. <xsl:call-template name="create_spec_title"/>
  212. <xsl:apply-templates/>
  213. <!-- end add flagging styles -->
  214. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  215. </text:span>
  216. </text:span>
  217. </xsl:when>
  218. <xsl:otherwise>
  219. <text:span text:style-name="Code_Text">
  220. <text:span>
  221. <!-- start add flagging styles -->
  222. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  223. <xsl:call-template name="create_spec_title"/>
  224. <xsl:apply-templates/>
  225. <!-- end add flagging styles -->
  226. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  227. </text:span>
  228. </text:span>
  229. </xsl:otherwise>
  230. </xsl:choose>
  231. </text:p>
  232. </xsl:when>
  233. <!-- other tags -->
  234. <xsl:otherwise>
  235. <text:span text:style-name="Code_Text">
  236. <text:span>
  237. <!-- start add flagging styles -->
  238. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  239. <xsl:call-template name="create_spec_title"/>
  240. <xsl:apply-templates/>
  241. <!-- end add flagging styles -->
  242. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  243. </text:span>
  244. </text:span>
  245. <text:line-break/>
  246. </xsl:otherwise>
  247. </xsl:choose>
  248. </xsl:template>
  249. <xsl:template name="create_spec_title">
  250. <xsl:if test="@spectitle and not(@spectitle='')">
  251. <text:line-break/>
  252. <text:span text:style-name="bold">
  253. <xsl:value-of select="@spectitle"/>
  254. </text:span>
  255. </xsl:if>
  256. </xsl:template>
  257. <xsl:template match="*[contains(@class,' pr-d/var ')]">
  258. <text:span text:style-name="italic">
  259. <text:span>
  260. <!-- start add rev flagging styles -->
  261. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  262. <xsl:apply-templates/>
  263. <!-- end add rev flagging styles -->
  264. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  265. </text:span>
  266. </text:span>
  267. </xsl:template>
  268. <xsl:template match="*[contains(@class,' pr-d/syntaxdiagram ')]/*[contains(@class,' topic/title ')]">
  269. <text:span text:style-name="center">
  270. <text:span text:style-name="bold">
  271. <xsl:value-of select="."/>
  272. </text:span>
  273. </text:span>
  274. <text:line-break/>
  275. </xsl:template>
  276. <xsl:template match="*[contains(@class,' pr-d/kwd ')]">
  277. <text:span>
  278. <!-- start add rev flagging styles -->
  279. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  280. <xsl:if test="parent::*[contains(@class,' pr-d/groupchoice ')]">
  281. <xsl:if test="count(preceding-sibling::*)!=0"> | </xsl:if>
  282. </xsl:if>
  283. <xsl:if test="@importance='optional'"> [</xsl:if>
  284. <xsl:value-of select="."/>
  285. <xsl:if test="@importance='optional'">] </xsl:if>
  286. <!-- end add rev flagging styles -->
  287. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  288. </text:span>
  289. </xsl:template>
  290. <xsl:template match="*[contains(@class, ' pr-d/groupchoice ' )]">
  291. <xsl:call-template name="makeGroup"/>
  292. <text:line-break/>
  293. </xsl:template>
  294. <xsl:template name="makeGroup">
  295. <text:span>
  296. <text:span>
  297. <!-- start add flagging styles -->
  298. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  299. <xsl:if test="parent::*[contains(@class,' pr-d/groupchoice ')]">
  300. <xsl:if test="count(preceding-sibling::*)!=0"> | </xsl:if>
  301. </xsl:if>
  302. <xsl:if test="@importance='optional'">[</xsl:if>
  303. <xsl:if test="name()='groupchoice'">{</xsl:if>
  304. <xsl:text> </xsl:text>
  305. <xsl:apply-templates/>
  306. <xsl:text> </xsl:text>
  307. <!-- repid processed here before -->
  308. <xsl:if test="name()='groupchoice'">}</xsl:if>
  309. <xsl:if test="@importance='optional'">]</xsl:if>
  310. <!-- end add flagging styles -->
  311. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  312. </text:span>
  313. </text:span>
  314. </xsl:template>
  315. <xsl:template match="*[contains(@class,' pr-d/parmname ')]">
  316. <text:span text:style-name="bold">
  317. <text:span>
  318. <!-- start add rev flagging styles -->
  319. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  320. <xsl:apply-templates/>
  321. <!-- end add rev flagging styles -->
  322. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  323. </text:span>
  324. </text:span>
  325. </xsl:template>
  326. <xsl:template match="*[contains(@class, ' pr-d/apiname ')]|*[contains(@class, ' pr-d/option ')]| *[contains(@class, ' pr-d/cmdname ')]">
  327. <xsl:choose>
  328. <xsl:when test="parent::*[contains(@class, ' topic/li ')] or parent::*[contains(@class, ' topic/sli ')]">
  329. <text:p>
  330. <text:span>
  331. <!-- start add rev flagging styles -->
  332. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  333. <xsl:apply-templates/>
  334. <!-- end add rev flagging styles -->
  335. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  336. </text:span>
  337. </text:p>
  338. </xsl:when>
  339. <!-- nested by entry -->
  340. <xsl:when test="parent::*[contains(@class, ' topic/entry ')]">
  341. <!-- create p tag -->
  342. <text:p>
  343. <!-- alignment styles -->
  344. <xsl:if test="parent::*[contains(@class, ' topic/entry ')]/@align">
  345. <xsl:call-template name="set_align_value"/>
  346. </xsl:if>
  347. <text:span>
  348. <!-- start add rev flagging styles -->
  349. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  350. <xsl:apply-templates/>
  351. <!-- end add rev flagging styles -->
  352. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  353. </text:span>
  354. </text:p>
  355. </xsl:when>
  356. <!-- nested by stentry -->
  357. <xsl:when test="parent::*[contains(@class, ' topic/stentry ')]">
  358. <text:p>
  359. <text:span>
  360. <!-- start add rev flagging styles -->
  361. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  362. <xsl:apply-templates/>
  363. <!-- end add rev flagging styles -->
  364. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  365. </text:span>
  366. </text:p>
  367. </xsl:when>
  368. <xsl:otherwise>
  369. <text:span>
  370. <!-- start add rev flagging styles -->
  371. <xsl:apply-templates select="." mode="start-add-odt-revflags"/>
  372. <xsl:apply-templates/>
  373. <!-- end add rev flagging styles -->
  374. <xsl:apply-templates select="." mode="end-add-odt-revflags"/>
  375. </text:span>
  376. </xsl:otherwise>
  377. </xsl:choose>
  378. </xsl:template>
  379. <xsl:template match="*[contains(@class,' pr-d/syntaxdiagram ')]">
  380. <xsl:choose>
  381. <!-- parent is body, li... -->
  382. <xsl:when test="parent::*[contains(@class, ' topic/body ')] or parent::*[contains(@class, ' topic/li ')] or parent::*[contains(@class, ' topic/sli ')]">
  383. <text:p text:style-name="syntaxdiagram_paragraph">
  384. <text:span>
  385. <!-- start add flagging styles -->
  386. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  387. <xsl:apply-templates/>
  388. <!-- end add flagging styles -->
  389. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  390. </text:span>
  391. </text:p>
  392. </xsl:when>
  393. <!-- nested by entry -->
  394. <xsl:when test="parent::*[contains(@class, ' topic/entry ')]">
  395. <!-- create p tag -->
  396. <text:p>
  397. <!-- alignment styles -->
  398. <xsl:if test="parent::*[contains(@class, ' topic/entry ')]/@align">
  399. <xsl:call-template name="set_align_value"/>
  400. </xsl:if>
  401. <!-- cell belongs to thead -->
  402. <xsl:choose>
  403. <xsl:when test="parent::*[contains(@class, ' topic/entry ')] /parent::*[contains(@class, ' topic/row ')]/parent::*[contains(@class, ' topic/thead ')]">
  404. <text:span text:style-name="bold">
  405. <text:span>
  406. <!-- start add flagging styles -->
  407. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  408. <xsl:apply-templates/>
  409. <!-- end add flagging styles -->
  410. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  411. </text:span>
  412. </text:span>
  413. </xsl:when>
  414. <xsl:otherwise>
  415. <text:span>
  416. <!-- start add flagging styles -->
  417. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  418. <xsl:apply-templates/>
  419. <!-- end add flagging styles -->
  420. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  421. </text:span>
  422. </xsl:otherwise>
  423. </xsl:choose>
  424. </text:p>
  425. </xsl:when>
  426. <!-- nested by stentry -->
  427. <xsl:when test="parent::*[contains(@class, ' topic/stentry ')]">
  428. <text:p>
  429. <!-- cell belongs to sthead -->
  430. <xsl:choose>
  431. <xsl:when test="parent::*[contains(@class, ' topic/stentry ')]/ parent::*[contains(@class, ' topic/sthead ')]">
  432. <text:span text:style-name="bold">
  433. <text:span>
  434. <!-- start add flagging styles -->
  435. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  436. <xsl:apply-templates/>
  437. <!-- end add flagging styles -->
  438. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  439. </text:span>
  440. </text:span>
  441. </xsl:when>
  442. <xsl:otherwise>
  443. <text:span>
  444. <!-- start add flagging styles -->
  445. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  446. <xsl:apply-templates/>
  447. <!-- end add flagging styles -->
  448. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  449. </text:span>
  450. </xsl:otherwise>
  451. </xsl:choose>
  452. </text:p>
  453. </xsl:when>
  454. <!-- other tags -->
  455. <xsl:otherwise>
  456. <text:span>
  457. <text:span>
  458. <!-- start add flagging styles -->
  459. <xsl:apply-templates select="." mode="start-add-odt-flags"/>
  460. <xsl:apply-templates/>
  461. <!-- end add flagging styles -->
  462. <xsl:apply-templates select="." mode="end-add-odt-flags"/>
  463. </text:span>
  464. </text:span>
  465. </xsl:otherwise>
  466. </xsl:choose>
  467. </xsl:template>
  468. </xsl:stylesheet>