flagging-preprocess.xsl 24 KB

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