flagging-preprocess.xsl 24 KB

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