flagging-preprocess_template.xsl 25 KB

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