flagging-preprocess_template.xsl 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!-- Deprecated since 2.2 -->
  3. <!--
  4. This file is part of the DITA Open Toolkit project.
  5. Copyright 2011 Reuven Weiser
  6. See the accompanying LICENSE file for applicable license.
  7. -->
  8. <xsl:stylesheet
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  10. xmlns:opentopic-func="http://www.idiominc.com/opentopic/exsl/function"
  11. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  12. exclude-result-prefixes="xsl opentopic-func xs"
  13. xmlns:suitesol="http://suite-sol.com/namespaces/mapcounts"
  14. version="2.0">
  15. <xsl:import href="plugin:org.dita.pdf2:xsl/fo/flag-rules.xsl"/>
  16. <xsl:import href="plugin:org.dita.base:xsl/common/dita-utilities.xsl"/>
  17. <xsl:import href="plugin:org.dita.base:xsl/common/output-message.xsl"/>
  18. <dita:extension id="dita.xsl.xslfo.flagging-preprocess"
  19. behavior="org.dita.dost.platform.ImportXSLAction"
  20. xmlns:dita="http://dita-ot.sourceforge.net"
  21. />
  22. <!--preserve the doctype-->
  23. <xsl:output method="xml" encoding="UTF-8" indent="no"></xsl:output>
  24. <xsl:param name="filterFile" select="''"/>
  25. <!-- The document tree of filterfile returned by document($FILTERFILE,/)-->
  26. <!-- Define the error message prefix identifier -->
  27. <!-- Deprecated since 2.3 -->
  28. <xsl:variable name="msgprefix">DOTX</xsl:variable>
  29. <xsl:variable name="FILTERFILEURL">
  30. <xsl:choose>
  31. <xsl:when test="not($filterFile)"/>
  32. <!-- If no filterFile leave empty -->
  33. <xsl:when test="starts-with($filterFile,'file:')">
  34. <xsl:value-of select="$filterFile"/>
  35. </xsl:when>
  36. <xsl:otherwise>
  37. <xsl:choose>
  38. <xsl:when test="starts-with($filterFile,'/')">
  39. <xsl:text>file://</xsl:text>
  40. <xsl:value-of select="$filterFile"/>
  41. </xsl:when>
  42. <xsl:otherwise>
  43. <xsl:text>file:/</xsl:text>
  44. <xsl:value-of select="$filterFile"/>
  45. </xsl:otherwise>
  46. </xsl:choose>
  47. </xsl:otherwise>
  48. </xsl:choose>
  49. </xsl:variable>
  50. <xsl:variable name="flagsParams" select="document($FILTERFILEURL,/)"/>
  51. <xsl:template match="*" mode="flagging">
  52. <xsl:param name="pi-name"/>
  53. <xsl:param name="id"/>
  54. <xsl:param name="flagrules" />
  55. <xsl:if test="$flagrules">
  56. <xsl:variable name="conflictexist">
  57. <xsl:apply-templates select="." mode="conflict-check">
  58. <xsl:with-param name="flagrules" select="$flagrules"/>
  59. </xsl:apply-templates>
  60. </xsl:variable>
  61. <xsl:variable name="style">
  62. <xsl:call-template name="gen-style">
  63. <xsl:with-param name="conflictexist" select="$conflictexist"></xsl:with-param>
  64. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  65. </xsl:call-template>
  66. </xsl:variable>
  67. <xsl:if test="string-length($style) &gt; 0">
  68. <xsl:element name="suitesol:{$pi-name}">
  69. <xsl:attribute name="id">
  70. <xsl:value-of select="$id"/>
  71. </xsl:attribute>
  72. <xsl:attribute name="style">
  73. <xsl:value-of select="$style"/>
  74. </xsl:attribute>
  75. </xsl:element>
  76. </xsl:if>
  77. </xsl:if>
  78. </xsl:template>
  79. <xsl:template match="*" mode="changebar">
  80. <xsl:param name="pi-name"/>
  81. <xsl:param name="id"/>
  82. <xsl:param name="flagrules" />
  83. <xsl:if test="$flagrules">
  84. <xsl:for-each select="$flagrules/*[@changebar]">
  85. <xsl:element name="{concat('suitesol:changebar-',$pi-name)}">
  86. <xsl:attribute name="id">
  87. <xsl:value-of select="concat($id,'_',count(preceding::*))"/>
  88. </xsl:attribute>
  89. <xsl:if test="$pi-name='start'">
  90. <xsl:attribute name="changebar">
  91. <xsl:value-of select="@changebar"/>
  92. </xsl:attribute>
  93. </xsl:if>
  94. </xsl:element>
  95. </xsl:for-each>
  96. </xsl:if>
  97. </xsl:template>
  98. <xsl:template match="*" mode="copy-contents">
  99. <xsl:param name="id"/>
  100. <xsl:param name="flagrules" />
  101. <xsl:call-template name="start-flagit">
  102. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  103. </xsl:call-template>
  104. <xsl:copy>
  105. <xsl:apply-templates select="@*"/>
  106. <xsl:apply-templates/>
  107. </xsl:copy>
  108. <xsl:call-template name="end-flagit">
  109. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  110. </xsl:call-template>
  111. </xsl:template>
  112. <!-- Don't flag topics, just like in the HTML output -->
  113. <xsl:template match="*[contains(@class, ' topic/topic ')]"
  114. priority="50">
  115. <xsl:copy>
  116. <xsl:apply-templates select="@*"/>
  117. <xsl:apply-templates/>
  118. </xsl:copy>
  119. </xsl:template>
  120. <!-- For these elements, the flagging style can be applied directly to the fo element
  121. already being created by the default DITA-OT processing -->
  122. <xsl:template match="*[contains(@class, ' topic/image ') or
  123. contains(@class, ' svg-d/svgref ') or
  124. contains(@class,' topic/table ') or
  125. contains(@class, ' topic/ol ') or
  126. contains(@class, ' topic/ul ') or contains(@class, ' topic/sl ')]"
  127. priority="50">
  128. <xsl:variable name="id" select="generate-id(.)" as="xs:string"/>
  129. <xsl:variable name="flagrules">
  130. <xsl:apply-templates select="." mode="getrules">
  131. </xsl:apply-templates>
  132. </xsl:variable>
  133. <xsl:apply-templates select="." mode="changebar">
  134. <xsl:with-param name="pi-name">start</xsl:with-param>
  135. <xsl:with-param name="id" select="$id" />
  136. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  137. </xsl:apply-templates>
  138. <xsl:call-template name="start-flagit">
  139. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  140. </xsl:call-template>
  141. <xsl:copy>
  142. <xsl:apply-templates select="@*"/>
  143. <xsl:apply-templates select="." mode="flagging">
  144. <xsl:with-param name="pi-name">flagging-inside</xsl:with-param>
  145. <xsl:with-param name="id" select="$id" />
  146. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  147. </xsl:apply-templates>
  148. <xsl:apply-templates/>
  149. </xsl:copy>
  150. <xsl:call-template name="end-flagit">
  151. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  152. </xsl:call-template>
  153. <xsl:apply-templates select="." mode="changebar">
  154. <xsl:with-param name="pi-name">end</xsl:with-param>
  155. <xsl:with-param name="id" select="$id" />
  156. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  157. </xsl:apply-templates>
  158. </xsl:template>
  159. <!-- For these elements, the flagging style must be applied to a new fo:block around the element,
  160. which for now is place-held by the suitesol:flagging-outside element -->
  161. <xsl:template match="*[contains(@class, ' topic/simpletable ') or contains(@class, ' topic/dl ') or contains(@class, ' topic/note ') or contains(@class, ' pr-d/codeblock ') or contains(@class, ' ui-d/screen ')]"
  162. priority="40">
  163. <xsl:variable name="id" select="generate-id(.)" as="xs:string"/>
  164. <xsl:variable name="flagrules">
  165. <xsl:apply-templates select="." mode="getrules">
  166. </xsl:apply-templates>
  167. </xsl:variable>
  168. <xsl:apply-templates select="." mode="changebar">
  169. <xsl:with-param name="pi-name">start</xsl:with-param>
  170. <xsl:with-param name="id" select="$id" />
  171. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  172. </xsl:apply-templates>
  173. <xsl:variable name="style">
  174. <xsl:if test="$flagrules">
  175. <xsl:variable name="conflictexist">
  176. <xsl:apply-templates select="." mode="conflict-check">
  177. <xsl:with-param name="flagrules" select="$flagrules"/>
  178. </xsl:apply-templates>
  179. </xsl:variable>
  180. <xsl:call-template name="gen-style">
  181. <xsl:with-param name="conflictexist" select="$conflictexist"></xsl:with-param>
  182. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  183. </xsl:call-template>
  184. </xsl:if>
  185. </xsl:variable>
  186. <xsl:choose>
  187. <xsl:when test="string-length(normalize-space($style)) &gt; 0">
  188. <suitesol:flagging-outside style="{$style}">
  189. <xsl:apply-templates select="." mode="copy-contents">
  190. <xsl:with-param name="id" select="$id" />
  191. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  192. </xsl:apply-templates>
  193. </suitesol:flagging-outside>
  194. </xsl:when>
  195. <!-- If there's no style, don't bother creating the surrounding block -->
  196. <xsl:otherwise>
  197. <xsl:apply-templates select="." mode="copy-contents">
  198. <xsl:with-param name="id" select="$id" />
  199. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  200. </xsl:apply-templates>
  201. </xsl:otherwise>
  202. </xsl:choose>
  203. <xsl:apply-templates select="." mode="changebar">
  204. <xsl:with-param name="pi-name">end</xsl:with-param>
  205. <xsl:with-param name="id">
  206. <xsl:value-of select="$id"/>
  207. </xsl:with-param>
  208. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  209. </xsl:apply-templates>
  210. </xsl:template>
  211. <!-- For these elements, the flagging style must be applied to a new fo:inline around the element,
  212. which for now is place-held by the suitesol:flagging-outside-inline element -->
  213. <xsl:template match="*[contains(@class, ' topic/xref ') or contains(@class, ' topic/link ')]"
  214. priority="40">
  215. <xsl:variable name="id" select="generate-id(.)" as="xs:string"/>
  216. <xsl:variable name="flagrules">
  217. <xsl:apply-templates select="." mode="getrules">
  218. </xsl:apply-templates>
  219. </xsl:variable>
  220. <xsl:apply-templates select="." mode="changebar">
  221. <xsl:with-param name="pi-name">start</xsl:with-param>
  222. <xsl:with-param name="id" select="$id" />
  223. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  224. </xsl:apply-templates>
  225. <xsl:variable name="style">
  226. <xsl:if test="$flagrules">
  227. <xsl:variable name="conflictexist">
  228. <xsl:apply-templates select="." mode="conflict-check">
  229. <xsl:with-param name="flagrules" select="$flagrules"/>
  230. </xsl:apply-templates>
  231. </xsl:variable>
  232. <xsl:call-template name="gen-style">
  233. <xsl:with-param name="conflictexist" select="$conflictexist"></xsl:with-param>
  234. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  235. </xsl:call-template>
  236. </xsl:if>
  237. </xsl:variable>
  238. <xsl:choose>
  239. <xsl:when test="string-length(normalize-space($style)) &gt; 0">
  240. <suitesol:flagging-outside-inline style="{$style}">
  241. <xsl:apply-templates select="." mode="copy-contents">
  242. <xsl:with-param name="id" select="$id" />
  243. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  244. </xsl:apply-templates>
  245. </suitesol:flagging-outside-inline>
  246. </xsl:when>
  247. <xsl:otherwise>
  248. <xsl:apply-templates select="." mode="copy-contents">
  249. <xsl:with-param name="id" select="$id" />
  250. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  251. </xsl:apply-templates>
  252. </xsl:otherwise>
  253. </xsl:choose>
  254. <xsl:apply-templates select="." mode="changebar">
  255. <xsl:with-param name="pi-name">end</xsl:with-param>
  256. <xsl:with-param name="id">
  257. <xsl:value-of select="$id"/>
  258. </xsl:with-param>
  259. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  260. </xsl:apply-templates>
  261. </xsl:template>
  262. <!-- For these elements, the flagging style can be applied directly to the fo element
  263. already being created by the default DITA-OT processing, but now the startflag and endflag images
  264. are placed inside the element rather than before and after it -->
  265. <xsl:template match="*[contains(@class,' topic/entry ') or contains(@class, ' topic/stentry ') or
  266. contains(@class, ' topic/dd ') or contains(@class, ' topic/dt ') or
  267. contains(@class, ' topic/ddhd ') or contains(@class, ' topic/dthd ')]"
  268. priority="30">
  269. <xsl:variable name="id" select="generate-id(.)" as="xs:string"/>
  270. <xsl:variable name="flagrules">
  271. <xsl:apply-templates select=". | parent::*" mode="getrules">
  272. </xsl:apply-templates>
  273. </xsl:variable>
  274. <xsl:apply-templates select="." mode="changebar">
  275. <xsl:with-param name="pi-name">start</xsl:with-param>
  276. <xsl:with-param name="id" select="$id" />
  277. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  278. </xsl:apply-templates>
  279. <xsl:copy>
  280. <xsl:apply-templates select="@*"/>
  281. <!-- copy attributes from parents -->
  282. <xsl:apply-templates select="." mode="flagging">
  283. <xsl:with-param name="pi-name">flagging-inside</xsl:with-param>
  284. <xsl:with-param name="id" select="$id" />
  285. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  286. </xsl:apply-templates>
  287. <xsl:call-template name="start-flagit">
  288. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  289. </xsl:call-template>
  290. <xsl:apply-templates/>
  291. <xsl:call-template name="end-flagit">
  292. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  293. </xsl:call-template>
  294. </xsl:copy>
  295. <xsl:apply-templates select="." mode="changebar">
  296. <xsl:with-param name="pi-name">end</xsl:with-param>
  297. <xsl:with-param name="id" select="$id" />
  298. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  299. </xsl:apply-templates>
  300. </xsl:template>
  301. <!-- For these elements, the flagging style can be applied directly to the fo element
  302. already being created by the default DITA-OT processing,
  303. but startflag and endflag images are not supported (where would they go?) -->
  304. <xsl:template match="*[contains(@class,' topic/tgroup ') or contains(@class, ' topic/thead ') or
  305. contains(@class,' topic/tfoot ') or contains(@class,' topic/tbody ') or contains(@class,' topic/row ') or contains(@class, ' topic/strow ') or
  306. contains(@class, ' topic/dlentry ') or contains(@class, ' topic/dlhead ') or
  307. contains(@class, ' topic/sthead ')]"
  308. priority="20">
  309. <xsl:variable name="id" select="generate-id(.)" as="xs:string"/>
  310. <xsl:variable name="flagrules">
  311. <xsl:apply-templates select="." mode="getrules">
  312. </xsl:apply-templates>
  313. </xsl:variable>
  314. <xsl:apply-templates select="." mode="changebar">
  315. <xsl:with-param name="pi-name">start</xsl:with-param>
  316. <xsl:with-param name="id" select="$id" />
  317. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  318. </xsl:apply-templates>
  319. <xsl:copy>
  320. <xsl:apply-templates select="@*"/>
  321. <xsl:apply-templates select="." mode="flagging">
  322. <xsl:with-param name="pi-name">flagging-inside</xsl:with-param>
  323. <xsl:with-param name="id" select="$id" />
  324. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  325. </xsl:apply-templates>
  326. <xsl:apply-templates/>
  327. </xsl:copy>
  328. <xsl:apply-templates select="." mode="changebar">
  329. <xsl:with-param name="pi-name">end</xsl:with-param>
  330. <xsl:with-param name="id" select="$id" />
  331. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  332. </xsl:apply-templates>
  333. </xsl:template>
  334. <!-- For all other elements, we try to apply the flagging style directly to the fo element
  335. already being created by the default DITA-OT processing, and place the startflag and endflag images
  336. inside the element -->
  337. <xsl:template match="*" priority="-1">
  338. <xsl:variable name="id" select="generate-id(.)" as="xs:string"/>
  339. <xsl:variable name="flagrules">
  340. <xsl:apply-templates select="." mode="getrules">
  341. </xsl:apply-templates>
  342. </xsl:variable>
  343. <xsl:apply-templates select="." mode="changebar">
  344. <xsl:with-param name="pi-name">start</xsl:with-param>
  345. <xsl:with-param name="id" select="$id" />
  346. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  347. </xsl:apply-templates>
  348. <xsl:copy>
  349. <xsl:apply-templates select="@*"/>
  350. <xsl:apply-templates select="." mode="flagging">
  351. <xsl:with-param name="pi-name">flagging-inside</xsl:with-param>
  352. <xsl:with-param name="id" select="$id" />
  353. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  354. </xsl:apply-templates>
  355. <xsl:call-template name="start-flagit">
  356. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  357. </xsl:call-template>
  358. <xsl:apply-templates/>
  359. <xsl:call-template name="end-flagit">
  360. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  361. </xsl:call-template>
  362. </xsl:copy>
  363. <xsl:apply-templates select="." mode="changebar">
  364. <xsl:with-param name="pi-name">end</xsl:with-param>
  365. <xsl:with-param name="id" select="$id" />
  366. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  367. </xsl:apply-templates>
  368. </xsl:template>
  369. <xsl:template match="@*" priority="-1">
  370. <xsl:copy-of select="."/>
  371. </xsl:template>
  372. <!-- copy over all comments so that <a> won't be empty -->
  373. <xsl:template match="comment() | processing-instruction() | text()">
  374. <xsl:copy-of select="."/>
  375. </xsl:template>
  376. <xsl:template name="gen-style">
  377. <xsl:param name="conflictexist" select="'false'"/>
  378. <xsl:param name="flagrules"/>
  379. <xsl:variable name="colorprop">
  380. <xsl:choose>
  381. <xsl:when test="contains(@class, ' topic/image ') or contains(@class, ' svg-d/svgref ')">
  382. <xsl:text>border-style:solid;border-width:1pt;border-color:</xsl:text>
  383. </xsl:when>
  384. <xsl:otherwise>color:</xsl:otherwise>
  385. </xsl:choose>
  386. </xsl:variable>
  387. <xsl:variable name="back-colorprop">
  388. <xsl:choose>
  389. <xsl:when test="contains(@class, ' topic/image ') or contains(@class, ' svg-d/svgref ')">
  390. <xsl:text>border-style:solid;border-width:3pt;border-color:</xsl:text>
  391. </xsl:when>
  392. <xsl:otherwise>background-color:</xsl:otherwise>
  393. </xsl:choose>
  394. </xsl:variable>
  395. <xsl:choose>
  396. <xsl:when test="$conflictexist='true' and $flagsParams/val/style-conflict[@foreground-conflict-color or @background-conflict-color]">
  397. <xsl:call-template name="output-message">
  398. <xsl:with-param name="id" select="'DOTX054W'"/>
  399. </xsl:call-template>
  400. <xsl:if test="$flagsParams/val/style-conflict[@foreground-conflict-color]">
  401. <xsl:value-of select="$colorprop"/>
  402. <xsl:value-of select="$flagsParams/val/style-conflict/@foreground-conflict-color"/>
  403. <xsl:text>;</xsl:text>
  404. </xsl:if>
  405. <xsl:if test="$flagsParams/val/style-conflict[@background-conflict-color]">
  406. <xsl:value-of select="$back-colorprop"/>
  407. <xsl:value-of select="$flagsParams/val/style-conflict/@background-conflict-color"/>
  408. <xsl:text>;</xsl:text>
  409. </xsl:if>
  410. </xsl:when>
  411. <xsl:when test="$conflictexist='false' and $flagrules/*[@color or @backcolor]">
  412. <xsl:if test="$flagrules/*[@color]">
  413. <xsl:value-of select="$colorprop"/>
  414. <xsl:value-of select="$flagrules/*[@color]/@color"/>
  415. <xsl:text>;</xsl:text>
  416. </xsl:if>
  417. <xsl:if test="$flagrules/*[@backcolor]">
  418. <xsl:value-of select="$back-colorprop"/>
  419. <xsl:value-of select="$flagrules/*[@backcolor]/@backcolor"/>
  420. <xsl:text>;</xsl:text>
  421. </xsl:if>
  422. </xsl:when>
  423. </xsl:choose>
  424. <xsl:for-each select="$flagrules/*[@style]">
  425. <xsl:choose>
  426. <xsl:when test="./@style='bold'">
  427. <xsl:text>font-weight:</xsl:text>
  428. </xsl:when>
  429. <xsl:when test="./@style='italics' or ./@style='italic'">
  430. <xsl:text>font-style:</xsl:text>
  431. </xsl:when>
  432. <xsl:otherwise>
  433. <xsl:text>text-decoration:</xsl:text>
  434. </xsl:otherwise>
  435. </xsl:choose>
  436. <xsl:choose>
  437. <xsl:when test="./@style='double-underline'">
  438. <xsl:text>underline</xsl:text>
  439. </xsl:when>
  440. <xsl:when test="./@style='italics'">
  441. <xsl:text>italic</xsl:text>
  442. </xsl:when>
  443. <xsl:otherwise>
  444. <xsl:value-of select="./@style"/>
  445. </xsl:otherwise>
  446. </xsl:choose>
  447. <xsl:text>;</xsl:text>
  448. </xsl:for-each>
  449. </xsl:template>
  450. <xsl:template name="start-flagit">
  451. <xsl:param name="flagrules" />
  452. <xsl:apply-templates select="$flagrules/*[1]" mode="start-flagit"/>
  453. </xsl:template>
  454. <xsl:template match="prop|revprop" mode="start-flagit">
  455. <xsl:choose>
  456. <!-- Ensure there's an image to get, otherwise don't insert anything -->
  457. <xsl:when test="startflag/@imageref">
  458. <xsl:variable name="imgsrc" select="startflag/@imageref"/>
  459. <image class="- topic/image " placement="inline">
  460. <xsl:attribute name="href">
  461. <xsl:value-of select="$imgsrc"/>
  462. </xsl:attribute>
  463. <xsl:if test="startflag/alt-text">
  464. <xsl:attribute name="alt">
  465. <xsl:value-of select="startflag/alt-text"/>
  466. </xsl:attribute>
  467. </xsl:if>
  468. </image>
  469. </xsl:when>
  470. <xsl:when test="startflag/alt-text">
  471. <xsl:value-of select="startflag/alt-text"/>
  472. </xsl:when>
  473. <xsl:when test="@img">
  474. <!-- output the flag -->
  475. <image class="- topic/image " placement="inline">
  476. <xsl:attribute name="href">
  477. <xsl:value-of select="@img"/>
  478. </xsl:attribute>
  479. </image>
  480. </xsl:when>
  481. <xsl:otherwise/>
  482. <!-- that flag not active -->
  483. </xsl:choose>
  484. <xsl:apply-templates select="following-sibling::*[1]" mode="start-flagit"/>
  485. </xsl:template>
  486. <xsl:template name="end-flagit">
  487. <xsl:param name="flagrules">
  488. <!--xsl:call-template name="getrules"/-->
  489. </xsl:param>
  490. <xsl:apply-templates select="$flagrules/*[last()]" mode="end-flagit"/>
  491. </xsl:template>
  492. <xsl:template match="prop|revprop" mode="end-flagit">
  493. <xsl:choose>
  494. <!-- Ensure there's an image to get, otherwise don't insert anything -->
  495. <xsl:when test="endflag/@imageref">
  496. <xsl:variable name="imgsrc" select="endflag/@imageref"/>
  497. <image class="- topic/image " placement="inline">
  498. <xsl:attribute name="href">
  499. <xsl:value-of select="$imgsrc"/>
  500. </xsl:attribute>
  501. <xsl:if test="endflag/alt-text">
  502. <xsl:attribute name="alt">
  503. <xsl:value-of select="endflag/alt-text"/>
  504. </xsl:attribute>
  505. </xsl:if>
  506. </image>
  507. </xsl:when>
  508. <xsl:when test="endflag/alt-text">
  509. <xsl:value-of select="endflag/alt-text"/>
  510. </xsl:when>
  511. <!-- not necessary to add logic for @img. original ditaval does not support end flag. -->
  512. <xsl:otherwise/>
  513. <!-- that flag not active -->
  514. </xsl:choose>
  515. <xsl:apply-templates select="preceding-sibling::*[1]" mode="end-flagit"/>
  516. </xsl:template>
  517. </xsl:stylesheet>