dita2odt-flagging.xsl 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- This file is part of the DITA Open Toolkit project.
  3. See the accompanying license.txt file for applicable licenses. -->
  4. <!-- (c) Copyright IBM Corp. 2006 All Rights Reserved. -->
  5. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  6. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  7. version="2.0"
  8. xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  9. xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  10. xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  11. xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  12. xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
  13. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  14. xmlns:styleUtils="org.dita.dost.util.StyleUtils"
  15. xmlns:imgUtils="org.dita.dost.util.ImgUtils"
  16. exclude-result-prefixes="xs dita-ot ditamsg styleUtils imgUtils">
  17. <!-- =========== TEMPLATES FOR ODT FLAGGING =========== -->
  18. <xsl:template name="create_flagging_styles">
  19. <xsl:apply-templates select="$FILTERDOC/val/prop[@action='flag']" mode="create_flagging_styles"/>
  20. <xsl:apply-templates select="$FILTERDOC/val/revprop[@action='flag']" mode="create_flagging_styles">
  21. <xsl:with-param name="att" select="'rev'"/>
  22. </xsl:apply-templates>
  23. <xsl:apply-templates select="$FILTERDOC/val/style-conflict" mode="create_conflict_flagging_styles"/>
  24. </xsl:template>
  25. <xsl:template match="prop[@action='flag']|revprop[@action='flag']" mode="create_flagging_styles">
  26. <xsl:param name="att" select="@att"/>
  27. <xsl:param name="val" select="@val"/>
  28. <xsl:variable name="styleName" select="styleUtils:insertFlagStyleName(concat($att, $val))"/>
  29. <!-- text/p flagging style -->
  30. <style:style style:name="{$styleName}" style:family="text">
  31. <xsl:choose>
  32. <xsl:when test="@style = 'underline'">
  33. <xsl:attribute name="style:parent-style-name">underline</xsl:attribute>
  34. </xsl:when>
  35. <xsl:when test="@style = 'bold'">
  36. <xsl:attribute name="style:parent-style-name">bold</xsl:attribute>
  37. </xsl:when>
  38. <xsl:when test="@style = 'italics'">
  39. <xsl:attribute name="style:parent-style-name">italic</xsl:attribute>
  40. </xsl:when>
  41. <xsl:when test="@style = 'double-underline'">
  42. <xsl:attribute name="style:parent-style-name">double-underline</xsl:attribute>
  43. </xsl:when>
  44. <xsl:when test="@style = 'overline'">
  45. <xsl:attribute name="style:parent-style-name">overline</xsl:attribute>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <xsl:attribute name="style:parent-style-name">indent_text_style</xsl:attribute>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. <style:text-properties>
  52. <xsl:if test="@backcolor and not(@backcolor = '')">
  53. <xsl:attribute name="fo:background-color">
  54. <xsl:value-of select="dita-ot:getColor(@backcolor)"/>
  55. </xsl:attribute>
  56. </xsl:if>
  57. <xsl:if test="@color and not(@color = '')">
  58. <xsl:attribute name="fo:color">
  59. <xsl:value-of select="dita-ot:getColor(@color)"/>
  60. </xsl:attribute>
  61. </xsl:if>
  62. </style:text-properties>
  63. </style:style>
  64. <!-- table flagging style -->
  65. <style:style style:name="{concat($styleName, '_table_attr')}" style:family="table">
  66. <style:table-properties>
  67. <xsl:if test="@backcolor and not(@backcolor = '')">
  68. <xsl:attribute name="fo:background-color">
  69. <xsl:value-of select="dita-ot:getColor(@backcolor)"/>
  70. </xsl:attribute>
  71. </xsl:if>
  72. <xsl:if test="@color and not(@color = '')">
  73. <xsl:attribute name="fo:color">
  74. <xsl:value-of select="dita-ot:getColor(@color)"/>
  75. </xsl:attribute>
  76. </xsl:if>
  77. </style:table-properties>
  78. </style:style>
  79. <!-- for subject schema -->
  80. <!-- get the location of schemekeydef.xml -->
  81. <xsl:variable name="KEYDEF-FILE" select="concat($WORKDIR,$PATH2PROJ,'schemekeydef.xml')"/>
  82. <!--keydef.xml contains the val -->
  83. <xsl:if test="(document($KEYDEF-FILE, /)//*[@keys=$val])">
  84. <xsl:apply-templates select="(document($KEYDEF-FILE, /)//*[@keys=$val])" mode="create_subject_scheme_style">
  85. <xsl:with-param name="att" select="$att"/>
  86. <xsl:with-param name="val" select="$val"/>
  87. <xsl:with-param name="prop" select="."/>
  88. </xsl:apply-templates>
  89. </xsl:if>
  90. </xsl:template>
  91. <xsl:template match="style-conflict" mode="create_conflict_flagging_styles">
  92. <!-- common styles -->
  93. <style:style style:name="{'conflict_style'}" style:family="text" style:parent-style-name="indent_text_style">
  94. <style:text-properties>
  95. <xsl:if test="@background-conflict-color and not(@background-conflict-color = '')">
  96. <xsl:attribute name="fo:background-color">
  97. <xsl:value-of select="dita-ot:getColor(@background-conflict-color)"/>
  98. </xsl:attribute>
  99. </xsl:if>
  100. <xsl:if test="@foreground-conflict-color and not(@foreground-conflict-color = '')">
  101. <xsl:attribute name="fo:color">
  102. <xsl:value-of select="dita-ot:getColor(@foreground-conflict-color)"/>
  103. </xsl:attribute>
  104. </xsl:if>
  105. </style:text-properties>
  106. </style:style>
  107. <!-- table styles -->
  108. <style:style style:name="{'conflict_style_table'}" style:family="table">
  109. <style:table-properties>
  110. <xsl:if test="@background-conflict-color and not(@background-conflict-color = '')">
  111. <xsl:attribute name="fo:background-color">
  112. <xsl:value-of select="dita-ot:getColor(@background-conflict-color)"/>
  113. </xsl:attribute>
  114. </xsl:if>
  115. <xsl:if test="@foreground-conflict-color and not(@foreground-conflict-color = '')">
  116. <xsl:attribute name="fo:color">
  117. <xsl:value-of select="dita-ot:getColor(@foreground-conflict-color)"/>
  118. </xsl:attribute>
  119. </xsl:if>
  120. </style:table-properties>
  121. </style:style>
  122. </xsl:template>
  123. <xsl:template match="*" mode="create_subject_scheme_style">
  124. <xsl:param name="att"/>
  125. <xsl:param name="val"/>
  126. <xsl:param name="prop"/>
  127. <xsl:param name="cvffilename" select="@source"/>
  128. <!--get the location of subject_scheme.dictionary-->
  129. <xsl:variable name="INITIAL-PROPERTIES-FILE" select="translate(concat($WORKDIR , $PATH2PROJ , 'subject_scheme.dictionary'), '\', '/')"/>
  130. <xsl:variable name="PROPERTIES-FILE">
  131. <xsl:choose>
  132. <xsl:when test="starts-with($INITIAL-PROPERTIES-FILE,'/')">
  133. <xsl:text>file://</xsl:text><xsl:value-of select="$INITIAL-PROPERTIES-FILE"/>
  134. </xsl:when>
  135. <xsl:otherwise>
  136. <xsl:text>file:/</xsl:text><xsl:value-of select="$INITIAL-PROPERTIES-FILE"/>
  137. </xsl:otherwise>
  138. </xsl:choose>
  139. </xsl:variable>
  140. <!-- get the scheme list -->
  141. <!-- check CURRENT File -->
  142. <xsl:variable name="editedFileName">
  143. <xsl:call-template name="checkFile">
  144. <xsl:with-param name="in" select="$CURRENTFILE"/>
  145. </xsl:call-template>
  146. </xsl:variable>
  147. <xsl:variable name="schemeList">
  148. <xsl:apply-templates select="document($PROPERTIES-FILE,/)//*[@key=$editedFileName]" mode="check"/>
  149. </xsl:variable>
  150. <xsl:if test="contains($schemeList, $cvffilename)">
  151. <!-- get the path of scheme file -->
  152. <xsl:variable name="submfile">
  153. <xsl:value-of select="$cvffilename"/><xsl:text>.subm</xsl:text>
  154. </xsl:variable>
  155. <xsl:variable name="cvffilepath" select="concat($WORKDIR,$PATH2PROJ,$submfile)"/>
  156. <xsl:if test="document($cvffilepath,/)//*[@keys=$val]">
  157. <!-- copy the child node for flag and just copy the first element whose keys=$flag-->
  158. <!--xsl:for-each select="document($cvffilepath,/)//*[@keys=$value]/*"-->
  159. <xsl:for-each select="document($cvffilepath,/)//*[@keys=$val]//*">
  160. <xsl:variable name="styleName" select="styleUtils:insertFlagStyleName(concat($att, @keys))"/>
  161. <!-- text/p flagging style -->
  162. <style:style style:name="{$styleName}" style:family="text">
  163. <xsl:choose>
  164. <xsl:when test="$prop/@style = 'underline'">
  165. <xsl:attribute name="style:parent-style-name">underline</xsl:attribute>
  166. </xsl:when>
  167. <xsl:when test="$prop/@style = 'bold'">
  168. <xsl:attribute name="style:parent-style-name">bold</xsl:attribute>
  169. </xsl:when>
  170. <xsl:when test="$prop/@style = 'italics'">
  171. <xsl:attribute name="style:parent-style-name">italic</xsl:attribute>
  172. </xsl:when>
  173. <xsl:when test="$prop/@style = 'double-underline'">
  174. <xsl:attribute name="style:parent-style-name">double-underline</xsl:attribute>
  175. </xsl:when>
  176. <xsl:when test="$prop/@style = 'overline'">
  177. <xsl:attribute name="style:parent-style-name">overline</xsl:attribute>
  178. </xsl:when>
  179. <xsl:otherwise>
  180. <xsl:attribute name="style:parent-style-name">indent_text_style</xsl:attribute>
  181. </xsl:otherwise>
  182. </xsl:choose>
  183. <style:text-properties>
  184. <xsl:if test="$prop/@backcolor and not($prop/@backcolor = '')">
  185. <xsl:attribute name="fo:background-color">
  186. <xsl:value-of select="dita-ot:getColor($prop/@backcolor)"/>
  187. </xsl:attribute>
  188. </xsl:if>
  189. <xsl:if test="$prop/@color and not($prop/@color = '')">
  190. <xsl:attribute name="fo:color">
  191. <xsl:value-of select="dita-ot:getColor($prop/@color)"/>
  192. </xsl:attribute>
  193. </xsl:if>
  194. </style:text-properties>
  195. </style:style>
  196. <!-- table flagging style -->
  197. <style:style style:name="{concat($styleName, '_table_attr')}" style:family="table">
  198. <style:table-properties>
  199. <xsl:if test="$prop/@backcolor and not($prop/@backcolor = '')">
  200. <xsl:attribute name="fo:background-color">
  201. <xsl:value-of select="dita-ot:getColor($prop/@backcolor)"/>
  202. </xsl:attribute>
  203. </xsl:if>
  204. <xsl:if test="$prop/@color and not($prop/@color = '')">
  205. <xsl:attribute name="fo:color">
  206. <xsl:value-of select="dita-ot:getColor($prop/@color)"/>
  207. </xsl:attribute>
  208. </xsl:if>
  209. </style:table-properties>
  210. </style:style>
  211. </xsl:for-each>
  212. </xsl:if>
  213. </xsl:if>
  214. </xsl:template>
  215. <!-- get flagging style name -->
  216. <xsl:template name="getFlagStyleName">
  217. <xsl:variable name="domains" select="normalize-space(ancestor-or-self::*[contains(@class,' topic/topic ')][1]/@domains)"/>
  218. <xsl:variable name="tmp_props">
  219. <xsl:call-template name="getExtProps">
  220. <xsl:with-param name="domains" select="$domains"/>
  221. </xsl:call-template>
  222. </xsl:variable>
  223. <xsl:variable name="props" select="substring-after($tmp_props, ',')"/>
  224. <!-- Test for the flagging attributes. If found, call 'gen-prop' with the values to use. Otherwise return -->
  225. <xsl:if test="@audience and not($FILTERFILE='')">
  226. <xsl:value-of select="styleUtils:getFlagStyleName(concat('audience', @audience))"/>
  227. </xsl:if>
  228. <xsl:if test="@platform and not($FILTERFILE='')">
  229. <xsl:value-of select="styleUtils:getFlagStyleName(concat('platform', @platform))"/>
  230. </xsl:if>
  231. <xsl:if test="@product and not($FILTERFILE='')">
  232. <xsl:value-of select="styleUtils:getFlagStyleName(concat('product', @product))"/>
  233. </xsl:if>
  234. <xsl:if test="@otherprops and not($FILTERFILE='')">
  235. <xsl:value-of select="styleUtils:getFlagStyleName(concat('otherprops', @otherprops))"/>
  236. </xsl:if>
  237. <xsl:if test="@rev and not($FILTERFILE='')">
  238. <xsl:value-of select="styleUtils:getFlagStyleName(concat('rev', @rev))"/>
  239. </xsl:if>
  240. <xsl:if test="not($props='') and not($FILTERFILE='')">
  241. <xsl:call-template name="ext-getFlagStyleName">
  242. <xsl:with-param name="props" select="$props"/>
  243. </xsl:call-template>
  244. </xsl:if>
  245. </xsl:template>
  246. <xsl:template name="ext-getFlagStyleName">
  247. <xsl:param name="props"/>
  248. <xsl:choose>
  249. <xsl:when test="contains($props,',')">
  250. <xsl:variable name="propsValue">
  251. <xsl:call-template name="getPropsValue">
  252. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  253. </xsl:call-template>
  254. </xsl:variable>
  255. <xsl:variable name="propName">
  256. <xsl:call-template name="getLastPropName">
  257. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  258. </xsl:call-template>
  259. </xsl:variable>
  260. <xsl:if test="not($propsValue='')">
  261. <xsl:value-of select="styleUtils:getFlagStyleName(concat($propName, $propsValue))"/>
  262. </xsl:if>
  263. <xsl:call-template name="ext-getFlagStyleName">
  264. <xsl:with-param name="props" select="substring-after($props,',')"/>
  265. </xsl:call-template>
  266. </xsl:when>
  267. <xsl:otherwise>
  268. <xsl:variable name="propsValue">
  269. <xsl:call-template name="getPropsValue">
  270. <xsl:with-param name="propsPath" select="$props"/>
  271. </xsl:call-template>
  272. </xsl:variable>
  273. <xsl:variable name="propName">
  274. <xsl:call-template name="getLastPropName">
  275. <xsl:with-param name="propsPath" select="$props"/>
  276. </xsl:call-template>
  277. </xsl:variable>
  278. <xsl:if test="not($propsValue='')">
  279. <xsl:value-of select="styleUtils:getFlagStyleName(concat($propName, $propsValue))"/>
  280. </xsl:if>
  281. </xsl:otherwise>
  282. </xsl:choose>
  283. </xsl:template>
  284. <!-- add flagging images, rev images and flagging styles -->
  285. <xsl:template match="*" mode="start-add-odt-flags">
  286. <!-- param for table background color -->
  287. <xsl:param name="family" select="''"/>
  288. <!-- param for text under list/entry tags -->
  289. <xsl:param name="type" select="''"/>
  290. <!-- get flagging style name. -->
  291. <xsl:variable name="flagStyleName">
  292. <xsl:apply-templates select="." mode="getFlaggingStyleName"/>
  293. <!--
  294. <xsl:call-template name="getFlagStyleName"/>
  295. -->
  296. </xsl:variable>
  297. <!-- get style rules -->
  298. <xsl:variable name="flagrules">
  299. <xsl:apply-templates select="." mode="getFlaggingRules"/>
  300. <!--
  301. <xsl:call-template name="getrules"/>
  302. -->
  303. </xsl:variable>
  304. <!-- check style conflict -->
  305. <xsl:variable name="conflictexist">
  306. <xsl:call-template name="conflict-check">
  307. <xsl:with-param name="flagrules" select="$flagrules"/>
  308. </xsl:call-template>
  309. </xsl:variable>
  310. <!-- ordinary tag(not list, or render table background color) -->
  311. <xsl:if test="$family = '' or $family = '_table_attr'">
  312. <!-- add flagging styles -->
  313. <xsl:choose>
  314. <!-- no conflict -->
  315. <xsl:when test="$conflictexist = 'false' and $flagStyleName != ''">
  316. <xsl:choose>
  317. <!-- ordinary style -->
  318. <xsl:when test="$family = ''">
  319. <xsl:attribute name="text:style-name">
  320. <xsl:value-of select="concat($flagStyleName, $family)"/>
  321. </xsl:attribute>
  322. </xsl:when>
  323. <!-- table background style -->
  324. <xsl:otherwise>
  325. <xsl:attribute name="table:style-name">
  326. <xsl:value-of select="concat($flagStyleName, $family)"/>
  327. </xsl:attribute>
  328. </xsl:otherwise>
  329. </xsl:choose>
  330. </xsl:when>
  331. <!-- there are conflict -->
  332. <xsl:when test="$conflictexist = 'true'">
  333. <xsl:apply-templates select="." mode="ditamsg:conflict-text-style-applied"/>
  334. <xsl:choose>
  335. <!-- ordinary conflict style -->
  336. <xsl:when test="$family = ''">
  337. <xsl:attribute name="text:style-name">
  338. <xsl:value-of select="'conflict_style'"/>
  339. </xsl:attribute>
  340. </xsl:when>
  341. <!-- table conflict style -->
  342. <xsl:otherwise>
  343. <xsl:attribute name="text:style-name">
  344. <xsl:value-of select="'conflict_style_table'"/>
  345. </xsl:attribute>
  346. </xsl:otherwise>
  347. </xsl:choose>
  348. </xsl:when>
  349. </xsl:choose>
  350. </xsl:if>
  351. <xsl:variable name="revtest">
  352. <xsl:call-template name="find-active-rev-flag">
  353. <xsl:with-param name="allrevs" select="@rev"/>
  354. </xsl:call-template>
  355. </xsl:variable>
  356. <xsl:variable name="flagRulesOfCurrentNode">
  357. <xsl:call-template name="getrules"/>
  358. </xsl:variable>
  359. <!-- current node has flagging attribute add images-->
  360. <xsl:if test="$flagRulesOfCurrentNode">
  361. <!-- for table/list flagging styles images should be rendered in p tag-->
  362. <xsl:if test="$family != '' and $family != '_table_attr' and
  363. ($flagrules/prop[1]/startflag/@imageref or $revtest = 1)">
  364. <!-- render p and span tag -->
  365. <xsl:text disable-output-escaping="yes">&lt;text:p&gt;</xsl:text>
  366. </xsl:if>
  367. <!-- avoid text under li/entry and table attr styles-->
  368. <xsl:if test="($type = '' or $type = 'note' or $type = 'keyword') and $family != '_table_attr'">
  369. <!-- add images -->
  370. <!-- keyword do not have flagging images -->
  371. <xsl:if test="$type != 'keyword'">
  372. <xsl:call-template name="start-flagit">
  373. <xsl:with-param name="flagrules" select="$flagrules"/>
  374. </xsl:call-template>
  375. </xsl:if>
  376. <!-- add rev style -->
  377. <!-- note tag is specail -->
  378. <xsl:if test="$type != 'note'">
  379. <xsl:call-template name="start-add-odt-revflags">
  380. <xsl:with-param name="flagrules" select="$flagrules"/>
  381. </xsl:call-template>
  382. </xsl:if>
  383. </xsl:if>
  384. <!-- for table/list flagging styles images should be rendered in p tag-->
  385. <xsl:if test="$family != '' and $family != '_table_attr' and
  386. ($flagrules/prop[1]/startflag/@imageref or $revtest = 1)">
  387. <xsl:text disable-output-escaping="yes">&lt;/text:p&gt;</xsl:text>
  388. </xsl:if>
  389. </xsl:if>
  390. </xsl:template>
  391. <xsl:template match="*" mode="end-add-odt-flags">
  392. <xsl:param name="family" select="''"/>
  393. <xsl:param name="type" select="''"/>
  394. <!-- get style rules -->
  395. <xsl:variable name="flagrules">
  396. <xsl:call-template name="getrules"/>
  397. </xsl:variable>
  398. <xsl:variable name="revtest">
  399. <xsl:call-template name="find-active-rev-flag">
  400. <xsl:with-param name="allrevs" select="@rev"/>
  401. </xsl:call-template>
  402. </xsl:variable>
  403. <!-- for table/list flagging styles -->
  404. <xsl:if test="$family != '' and ($flagrules/prop[last()]/endflag/@imageref or $revtest = 1)">
  405. <!-- render p and span tag -->
  406. <xsl:text disable-output-escaping="yes">&lt;text:p&gt;</xsl:text>
  407. </xsl:if>
  408. <!-- avoid text under li/entry-->
  409. <xsl:if test="$type = '' or $type = 'note' or $type = 'keyword'">
  410. <!-- add rev style -->
  411. <!-- note tag is special -->
  412. <xsl:if test="$type != 'note'">
  413. <xsl:call-template name="end-add-odt-revflags">
  414. <xsl:with-param name="flagrules" select="$flagrules"/>
  415. </xsl:call-template>
  416. </xsl:if>
  417. <!-- add images -->
  418. <!-- keyword do not have flagging images -->
  419. <xsl:if test="$type != 'keyword'">
  420. <xsl:call-template name="end-flagit">
  421. <xsl:with-param name="flagrules" select="$flagrules"/>
  422. </xsl:call-template>
  423. </xsl:if>
  424. </xsl:if>
  425. <!-- for table/list flagging styles -->
  426. <xsl:if test="$family != '' and ($flagrules/prop[last()]/endflag/@imageref or $revtest = 1)">
  427. <xsl:text disable-output-escaping="yes">&lt;/text:p&gt;</xsl:text>
  428. </xsl:if>
  429. </xsl:template>
  430. <!-- add flagging images and rev images in a seperate paragraph -->
  431. <xsl:template match="*" mode="start-add-odt-imgrevflags">
  432. <!-- get style rules -->
  433. <xsl:variable name="flagrules">
  434. <xsl:call-template name="getrules"/>
  435. </xsl:variable>
  436. <xsl:variable name="revtest">
  437. <xsl:call-template name="find-active-rev-flag">
  438. <xsl:with-param name="allrevs" select="@rev"/>
  439. </xsl:call-template>
  440. </xsl:variable>
  441. <!-- for table/list flagging styles -->
  442. <xsl:if test="($flagrules/prop[1]/startflag/@imageref or $revtest = 1)">
  443. <!-- render p and span tag -->
  444. <xsl:text disable-output-escaping="yes">&lt;text:p&gt;</xsl:text>
  445. </xsl:if>
  446. <!-- add images -->
  447. <xsl:call-template name="start-flagit">
  448. <xsl:with-param name="flagrules" select="$flagrules"/>
  449. </xsl:call-template>
  450. <!-- add rev style -->
  451. <xsl:call-template name="start-add-odt-revflags">
  452. <xsl:with-param name="flagrules" select="$flagrules"/>
  453. </xsl:call-template>
  454. <!-- for table/list flagging styles -->
  455. <xsl:if test="($flagrules/prop[1]/startflag/@imageref or $revtest = 1)">
  456. <xsl:text disable-output-escaping="yes">&lt;/text:p&gt;</xsl:text>
  457. </xsl:if>
  458. </xsl:template>
  459. <xsl:template match="*" mode="end-add-odt-imgrevflags">
  460. <!-- get style rules -->
  461. <xsl:variable name="flagrules">
  462. <xsl:call-template name="getrules"/>
  463. </xsl:variable>
  464. <xsl:variable name="revtest">
  465. <xsl:call-template name="find-active-rev-flag">
  466. <xsl:with-param name="allrevs" select="@rev"/>
  467. </xsl:call-template>
  468. </xsl:variable>
  469. <!-- for table/list flagging styles -->
  470. <xsl:if test="($flagrules/prop[last()]/endflag/@imageref or $revtest = 1)">
  471. <!-- render p and span tag -->
  472. <xsl:text disable-output-escaping="yes">&lt;text:p&gt;</xsl:text>
  473. </xsl:if>
  474. <!-- add rev style -->
  475. <xsl:call-template name="end-add-odt-revflags">
  476. <xsl:with-param name="flagrules" select="$flagrules"/>
  477. </xsl:call-template>
  478. <!-- add images -->
  479. <xsl:call-template name="end-flagit">
  480. <xsl:with-param name="flagrules" select="$flagrules"/>
  481. </xsl:call-template>
  482. <!-- for table/list flagging styles -->
  483. <xsl:if test="($flagrules/prop[last()]/endflag/@imageref or $revtest = 1)">
  484. <xsl:text disable-output-escaping="yes">&lt;/text:p&gt;</xsl:text>
  485. </xsl:if>
  486. </xsl:template>
  487. <!-- only add flagging styles -->
  488. <xsl:template match="*" mode="add-odt-flagging">
  489. <!-- get flagging style name. -->
  490. <xsl:variable name="flagStyleName">
  491. <xsl:call-template name="getFlagStyleName"/>
  492. </xsl:variable>
  493. <!-- get style rules -->
  494. <xsl:variable name="flagrules">
  495. <xsl:call-template name="getrules"/>
  496. </xsl:variable>
  497. <!-- check style conflict -->
  498. <xsl:variable name="conflictexist">
  499. <xsl:call-template name="conflict-check">
  500. <xsl:with-param name="flagrules" select="$flagrules"/>
  501. </xsl:call-template>
  502. </xsl:variable>
  503. <!-- add flagging styles -->
  504. <xsl:choose>
  505. <!-- no conflict -->
  506. <xsl:when test="$conflictexist = 'false' and $flagStyleName != ''">
  507. <!-- ordinary style -->
  508. <xsl:attribute name="text:style-name">
  509. <xsl:value-of select="$flagStyleName"/>
  510. </xsl:attribute>
  511. </xsl:when>
  512. <!-- there are conflict -->
  513. <xsl:when test="$conflictexist = 'true'">
  514. <xsl:apply-templates select="." mode="ditamsg:conflict-text-style-applied"/>
  515. <xsl:attribute name="text:style-name">
  516. <xsl:value-of select="'conflict_style'"/>
  517. </xsl:attribute>
  518. </xsl:when>
  519. </xsl:choose>
  520. </xsl:template>
  521. <!-- only add rev images -->
  522. <xsl:template match="*" mode="start-add-odt-revflags" name="start-add-odt-revflags">
  523. <xsl:param name="flagrules">
  524. <xsl:call-template name="getrules"/>
  525. </xsl:param>
  526. <!-- add rev style -->
  527. <xsl:choose>
  528. <!-- draft rev mode, add div w/ rev attr value -->
  529. <xsl:when test="@rev and not($FILTERFILE='') and ($DRAFT='yes')">
  530. <xsl:variable name="revtest">
  531. <xsl:call-template name="find-active-rev-flag">
  532. <xsl:with-param name="allrevs" select="@rev"/>
  533. </xsl:call-template>
  534. </xsl:variable>
  535. <xsl:choose>
  536. <xsl:when test="$revtest=1">
  537. <xsl:call-template name="start-mark-rev">
  538. <xsl:with-param name="revvalue" select="@rev"/>
  539. <xsl:with-param name="flagrules" select="$flagrules"/>
  540. </xsl:call-template>
  541. </xsl:when>
  542. <xsl:otherwise/>
  543. </xsl:choose>
  544. </xsl:when>
  545. <xsl:when test="@rev and not($FILTERFILE='')"> <!-- normal rev mode -->
  546. <xsl:call-template name="start-mark-rev">
  547. <xsl:with-param name="revvalue" select="@rev"/>
  548. <xsl:with-param name="flagrules" select="$flagrules"/>
  549. </xsl:call-template>
  550. </xsl:when>
  551. <xsl:otherwise/>
  552. </xsl:choose>
  553. </xsl:template>
  554. <xsl:template match="*" mode="end-add-odt-revflags" name="end-add-odt-revflags">
  555. <xsl:param name="flagrules">
  556. <xsl:call-template name="getrules"/>
  557. </xsl:param>
  558. <!-- add rev style -->
  559. <xsl:choose>
  560. <!-- draft rev mode, add div w/ rev attr value -->
  561. <xsl:when test="@rev and not($FILTERFILE='') and ($DRAFT='yes')">
  562. <xsl:variable name="revtest">
  563. <xsl:call-template name="find-active-rev-flag">
  564. <xsl:with-param name="allrevs" select="@rev"/>
  565. </xsl:call-template>
  566. </xsl:variable>
  567. <xsl:choose>
  568. <xsl:when test="$revtest=1">
  569. <xsl:call-template name="end-mark-rev">
  570. <xsl:with-param name="revvalue" select="@rev"/>
  571. <xsl:with-param name="flagrules" select="$flagrules"/>
  572. </xsl:call-template>
  573. </xsl:when>
  574. <xsl:otherwise/>
  575. </xsl:choose>
  576. </xsl:when>
  577. <xsl:when test="@rev and not($FILTERFILE='')"> <!-- normal rev mode -->
  578. <xsl:call-template name="end-mark-rev">
  579. <xsl:with-param name="revvalue" select="@rev"/>
  580. <xsl:with-param name="flagrules" select="$flagrules"/>
  581. </xsl:call-template>
  582. </xsl:when>
  583. <xsl:otherwise/>
  584. </xsl:choose>
  585. </xsl:template>
  586. <xsl:template match="prop" mode="start-flagit">
  587. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  588. <xsl:when test="startflag/@imageref">
  589. <xsl:variable name="imgsrc" select="startflag/@imageref"/>
  590. <xsl:variable name="height">
  591. <xsl:choose>
  592. <xsl:when test="not(contains($imgsrc,'://'))">
  593. <xsl:value-of select="number(imgUtils:getHeight($OUTPUTDIR, string($imgsrc)) div 96)"/>
  594. </xsl:when>
  595. <xsl:otherwise/>
  596. </xsl:choose>
  597. </xsl:variable>
  598. <xsl:variable name="width">
  599. <xsl:choose>
  600. <xsl:when test="not(contains($imgsrc,'://'))">
  601. <xsl:value-of select="number(imgUtils:getWidth($OUTPUTDIR, string($imgsrc)) div 96)"/>
  602. </xsl:when>
  603. <xsl:otherwise/>
  604. </xsl:choose>
  605. </xsl:variable>
  606. <xsl:call-template name="draw_image_odt">
  607. <xsl:with-param name="height" select="$height"/>
  608. <xsl:with-param name="width" select="$width"/>
  609. <xsl:with-param name="imgsrc" select="$imgsrc"/>
  610. <xsl:with-param name="alttext" select="startflag/alt-text"/>
  611. </xsl:call-template>
  612. </xsl:when>
  613. <xsl:when test="startflag/alt-text">
  614. <xsl:value-of select="startflag/alt-text"/>
  615. </xsl:when>
  616. <xsl:otherwise/> <!-- that flag not active -->
  617. </xsl:choose>
  618. <xsl:apply-templates select="following-sibling::prop[1]" mode="start-flagit"/>
  619. </xsl:template>
  620. <xsl:template match="prop" mode="end-flagit">
  621. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  622. <xsl:when test="endflag/@imageref">
  623. <xsl:variable name="imgsrc" select="endflag/@imageref"/>
  624. <xsl:variable name="height">
  625. <xsl:choose>
  626. <xsl:when test="not(contains($imgsrc,'://'))">
  627. <xsl:value-of select="number(imgUtils:getHeight($OUTPUTDIR, string($imgsrc)) div 96)"/>
  628. </xsl:when>
  629. <xsl:otherwise/>
  630. </xsl:choose>
  631. </xsl:variable>
  632. <xsl:variable name="width">
  633. <xsl:choose>
  634. <xsl:when test="not(contains($imgsrc,'://'))">
  635. <xsl:value-of select="number(imgUtils:getWidth($OUTPUTDIR, string($imgsrc)) div 96)"/>
  636. </xsl:when>
  637. <xsl:otherwise/>
  638. </xsl:choose>
  639. </xsl:variable>
  640. <xsl:call-template name="draw_image_odt">
  641. <xsl:with-param name="height" select="$height"/>
  642. <xsl:with-param name="width" select="$width"/>
  643. <xsl:with-param name="imgsrc" select="$imgsrc"/>
  644. <xsl:with-param name="alttext" select="endflag/alt-text"/>
  645. </xsl:call-template>
  646. </xsl:when>
  647. <xsl:when test="endflag/alt-text">
  648. <xsl:value-of select="endflag/alt-text"/>
  649. </xsl:when>
  650. <!-- not necessary to add logic for @img. original ditaval does not support end flag. -->
  651. <xsl:otherwise/> <!-- that flag not active -->
  652. </xsl:choose>
  653. <xsl:apply-templates select="preceding-sibling::prop[1]" mode="end-flagit"/>
  654. </xsl:template>
  655. <xsl:template name="start-revflagit">
  656. <xsl:param name="flagrules">
  657. <xsl:call-template name="getrules"/>
  658. </xsl:param>
  659. <xsl:apply-templates select="$flagrules/revprop[1]" mode="start-revflagit"/>
  660. </xsl:template>
  661. <xsl:template match="revprop" mode="start-revflagit">
  662. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  663. <xsl:when test="startflag/@imageref">
  664. <xsl:variable name="imgsrc" select="startflag/@imageref"/>
  665. <xsl:variable name="height">
  666. <xsl:choose>
  667. <xsl:when test="not(contains($imgsrc,'://'))">
  668. <xsl:value-of select="number(imgUtils:getHeight($OUTPUTDIR, string($imgsrc)) div 96)"/>
  669. </xsl:when>
  670. <xsl:otherwise/>
  671. </xsl:choose>
  672. </xsl:variable>
  673. <xsl:variable name="width">
  674. <xsl:choose>
  675. <xsl:when test="not(contains($imgsrc,'://'))">
  676. <xsl:value-of select="number(imgUtils:getWidth($OUTPUTDIR, string($imgsrc)) div 96)"/>
  677. </xsl:when>
  678. <xsl:otherwise/>
  679. </xsl:choose>
  680. </xsl:variable>
  681. <xsl:call-template name="draw_image_odt">
  682. <xsl:with-param name="height" select="$height"/>
  683. <xsl:with-param name="width" select="$width"/>
  684. <xsl:with-param name="imgsrc" select="$imgsrc"/>
  685. <xsl:with-param name="alttext" select="startflag/alt-text"/>
  686. </xsl:call-template>
  687. </xsl:when>
  688. <xsl:when test="startflag/alt-text">
  689. <xsl:value-of select="startflag/alt-text"/>
  690. </xsl:when>
  691. <xsl:otherwise/> <!-- that flag not active -->
  692. </xsl:choose>
  693. <xsl:apply-templates select="following-sibling::revprop[1]" mode="start-revflagit"/>
  694. </xsl:template>
  695. <!-- output the beginning revision graphic & ALT text -->
  696. <xsl:template name="start-rev-art">
  697. <xsl:param name="deltaname"/>
  698. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  699. <xsl:when test="$deltaname">
  700. <xsl:variable name="imgsrc" select="$deltaname"/>
  701. <xsl:variable name="height">
  702. <xsl:choose>
  703. <xsl:when test="not(contains($imgsrc,'://'))">
  704. <xsl:value-of select="number(imgUtils:getHeight($OUTPUTDIR, string($imgsrc)) div 96)"/>
  705. </xsl:when>
  706. <xsl:otherwise/>
  707. </xsl:choose>
  708. </xsl:variable>
  709. <xsl:variable name="width">
  710. <xsl:choose>
  711. <xsl:when test="not(contains($imgsrc,'://'))">
  712. <xsl:value-of select="number(imgUtils:getWidth($OUTPUTDIR, string($imgsrc)) div 96)"/>
  713. </xsl:when>
  714. <xsl:otherwise/>
  715. </xsl:choose>
  716. </xsl:variable>
  717. <xsl:call-template name="draw_image_odt">
  718. <xsl:with-param name="height" select="$height"/>
  719. <xsl:with-param name="width" select="$width"/>
  720. <xsl:with-param name="imgsrc" select="$imgsrc"/>
  721. <xsl:with-param name="alttext" select="'Start of change'"/>
  722. </xsl:call-template>
  723. </xsl:when>
  724. <xsl:otherwise>
  725. <xsl:call-template name="getVariable">
  726. <xsl:with-param name="id" select="'Start of change'"/>
  727. </xsl:call-template>
  728. </xsl:otherwise>
  729. </xsl:choose>
  730. </xsl:template>
  731. <xsl:template match="revprop" mode="end-revflagit">
  732. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  733. <xsl:when test="endflag/@imageref">
  734. <xsl:variable name="imgsrc" select="endflag/@imageref"/>
  735. <xsl:variable name="height">
  736. <xsl:choose>
  737. <xsl:when test="not(contains($imgsrc,'://'))">
  738. <xsl:value-of select="number(imgUtils:getHeight($OUTPUTDIR, string($imgsrc)) div 96)"/>
  739. </xsl:when>
  740. <xsl:otherwise/>
  741. </xsl:choose>
  742. </xsl:variable>
  743. <xsl:variable name="width">
  744. <xsl:choose>
  745. <xsl:when test="not(contains($imgsrc,'://'))">
  746. <xsl:value-of select="number(imgUtils:getWidth($OUTPUTDIR, string($imgsrc)) div 96)"/>
  747. </xsl:when>
  748. <xsl:otherwise/>
  749. </xsl:choose>
  750. </xsl:variable>
  751. <xsl:call-template name="draw_image_odt">
  752. <xsl:with-param name="height" select="$height"/>
  753. <xsl:with-param name="width" select="$width"/>
  754. <xsl:with-param name="imgsrc" select="$imgsrc"/>
  755. <xsl:with-param name="alttext" select="endflag/alt-text"/>
  756. </xsl:call-template>
  757. </xsl:when>
  758. <xsl:when test="endflag/alt-text">
  759. <xsl:value-of select="endflag/alt-text"/>
  760. </xsl:when>
  761. <xsl:otherwise/> <!-- that flag not active -->
  762. </xsl:choose>
  763. <xsl:apply-templates select="preceding-sibling::revprop[1]" mode="end-revflagit"/>
  764. </xsl:template>
  765. <!-- output the ending revision graphic & ALT text -->
  766. <xsl:template name="end-rev-art">
  767. <xsl:param name="deltaname"/>
  768. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  769. <xsl:when test="$deltaname">
  770. <xsl:variable name="imgsrc" select="$deltaname"/>
  771. <xsl:variable name="height">
  772. <xsl:choose>
  773. <xsl:when test="not(contains($imgsrc,'://'))">
  774. <xsl:value-of select="number(imgUtils:getHeight($OUTPUTDIR, string($imgsrc)) div 96)"/>
  775. </xsl:when>
  776. <xsl:otherwise/>
  777. </xsl:choose>
  778. </xsl:variable>
  779. <xsl:variable name="width">
  780. <xsl:choose>
  781. <xsl:when test="not(contains($imgsrc,'://'))">
  782. <xsl:value-of select="number(imgUtils:getWidth($OUTPUTDIR, string($imgsrc)) div 96)"/>
  783. </xsl:when>
  784. <xsl:otherwise/>
  785. </xsl:choose>
  786. </xsl:variable>
  787. <xsl:call-template name="draw_image_odt">
  788. <xsl:with-param name="height" select="$height"/>
  789. <xsl:with-param name="width" select="$width"/>
  790. <xsl:with-param name="imgsrc" select="$imgsrc"/>
  791. <xsl:with-param name="alttext" select="'End of change'"/>
  792. </xsl:call-template>
  793. </xsl:when>
  794. <xsl:otherwise>
  795. <xsl:call-template name="getVariable">
  796. <xsl:with-param name="id" select="'End of change'"/>
  797. </xsl:call-template>
  798. </xsl:otherwise>
  799. </xsl:choose>
  800. </xsl:template>
  801. <xsl:template name="start_flagging_text_of_table_or_list">
  802. <xsl:variable name="ul_depth" select="count(ancestor::*[contains(@class, ' topic/ul ')][1]/ancestor::*)"/>
  803. <xsl:variable name="ol_depth" select="count(ancestor::*[contains(@class, ' topic/ol ')][1]/ancestor::*)"/>
  804. <xsl:variable name="sl_depth" select="count(ancestor::*[contains(@class, ' topic/sl ')][1]/ancestor::*)"/>
  805. <xsl:variable name="dl_depth" select="count(ancestor::*[contains(@class, ' topic/dl ')][1]/ancestor::*)"/>
  806. <xsl:variable name="table_depth" select="count(ancestor::*[contains(@class, ' topic/table ')][1]/ancestor::*)"/>
  807. <xsl:variable name="stable_depth" select="count(ancestor::*[contains(@class, ' topic/simpletable ')][1]/ancestor::*)"/>
  808. <!-- get closest tag -->
  809. <xsl:variable name="max_depth" select="max(($ul_depth, $ol_depth, $sl_depth, $dl_depth, $table_depth, $stable_depth))"/>
  810. <xsl:if test="$max_depth != 0 ">
  811. <xsl:choose>
  812. <!-- closest tag is ul -->
  813. <xsl:when test="$max_depth = $ul_depth">
  814. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/ul ')][1]"
  815. mode="start-add-odt-flags">
  816. <xsl:with-param name="type" select="'list'"/>
  817. </xsl:apply-templates>
  818. </xsl:when>
  819. <!-- closest tag is ol -->
  820. <xsl:when test="$max_depth = $ol_depth">
  821. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/ol ')][1]"
  822. mode="start-add-odt-flags">
  823. <xsl:with-param name="type" select="'list'"/>
  824. </xsl:apply-templates>
  825. </xsl:when>
  826. <!-- closest tag is sl -->
  827. <xsl:when test="$max_depth = $sl_depth">
  828. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/sl ')][1]"
  829. mode="start-add-odt-flags">
  830. <xsl:with-param name="type" select="'list'"/>
  831. </xsl:apply-templates>
  832. </xsl:when>
  833. <!-- closest tag is dl -->
  834. <xsl:when test="$max_depth = $dl_depth">
  835. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/dl ')][1]"
  836. mode="start-add-odt-flags">
  837. <xsl:with-param name="type" select="'list'"/>
  838. </xsl:apply-templates>
  839. </xsl:when>
  840. <!-- closest tag is table -->
  841. <xsl:when test="$max_depth = $table_depth">
  842. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/table ')][1]"
  843. mode="start-add-odt-flags">
  844. <xsl:with-param name="type" select="'table'"/>
  845. </xsl:apply-templates>
  846. </xsl:when>
  847. <!-- closest tag is stable -->
  848. <xsl:when test="$max_depth = $stable_depth">
  849. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/simpletable ')][1]"
  850. mode="start-add-odt-flags">
  851. <xsl:with-param name="type" select="'stable'"/>
  852. </xsl:apply-templates>
  853. </xsl:when>
  854. </xsl:choose>
  855. </xsl:if>
  856. </xsl:template>
  857. <!-- flagging text in the table cell or list item
  858. e.g
  859. <ul>
  860. <li>text</li>
  861. </ul>
  862. -->
  863. <xsl:template name="end_flagging_text_of_table_or_list">
  864. <xsl:variable name="ul_depth" select="count(ancestor::*[contains(@class, ' topic/ul ')][1]/ancestor::*)"/>
  865. <xsl:variable name="ol_depth" select="count(ancestor::*[contains(@class, ' topic/ol ')][1]/ancestor::*)"/>
  866. <xsl:variable name="sl_depth" select="count(ancestor::*[contains(@class, ' topic/sl ')][1]/ancestor::*)"/>
  867. <xsl:variable name="dl_depth" select="count(ancestor::*[contains(@class, ' topic/dl ')][1]/ancestor::*)"/>
  868. <xsl:variable name="table_depth" select="count(ancestor::*[contains(@class, ' topic/table ')][1]/ancestor::*)"/>
  869. <xsl:variable name="stable_depth" select="count(ancestor::*[contains(@class, ' topic/simpletable ')][1]/ancestor::*)"/>
  870. <!-- get closest tag -->
  871. <xsl:variable name="max_depth" select="max(($ul_depth, $ol_depth, $sl_depth, $dl_depth, $table_depth, $stable_depth))"/>
  872. <xsl:if test="$max_depth != 0 ">
  873. <xsl:choose>
  874. <!-- closest tag is ul -->
  875. <xsl:when test="$max_depth = $ul_depth">
  876. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/ul ')][1]"
  877. mode="end-add-odt-flags">
  878. <xsl:with-param name="type" select="'list'"/>
  879. </xsl:apply-templates>
  880. </xsl:when>
  881. <!-- closest tag is ol -->
  882. <xsl:when test="$max_depth = $ol_depth">
  883. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/ol ')][1]"
  884. mode="end-add-odt-flags">
  885. <xsl:with-param name="type" select="'list'"/>
  886. </xsl:apply-templates>
  887. </xsl:when>
  888. <!-- closest tag is sl -->
  889. <xsl:when test="$max_depth = $sl_depth">
  890. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/sl ')][1]"
  891. mode="end-add-odt-flags">
  892. <xsl:with-param name="type" select="'list'"/>
  893. </xsl:apply-templates>
  894. </xsl:when>
  895. <!-- closest tag is dl -->
  896. <xsl:when test="$max_depth = $dl_depth">
  897. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/dl ')][1]"
  898. mode="end-add-odt-flags">
  899. <xsl:with-param name="type" select="'list'"/>
  900. </xsl:apply-templates>
  901. </xsl:when>
  902. <!-- closest tag is table -->
  903. <xsl:when test="$max_depth = $table_depth">
  904. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/table ')][1]"
  905. mode="end-add-odt-flags">
  906. <xsl:with-param name="type" select="'table'"/>
  907. </xsl:apply-templates>
  908. </xsl:when>
  909. <!-- closest tag is stable -->
  910. <xsl:when test="$max_depth = $stable_depth">
  911. <xsl:apply-templates select="ancestor::*[contains(@class, ' topic/simpletable ')][1]"
  912. mode="end-add-odt-flags">
  913. <xsl:with-param name="type" select="'stable'"/>
  914. </xsl:apply-templates>
  915. </xsl:when>
  916. </xsl:choose>
  917. </xsl:if>
  918. </xsl:template>
  919. <!-- recusive template to get flagging rules -->
  920. <xsl:template match="*" mode="getFlaggingRules" name="getFlaggingRules">
  921. <xsl:variable name="flaggingRules">
  922. <xsl:call-template name="getrules"/>
  923. </xsl:variable>
  924. <xsl:choose>
  925. <xsl:when test="$flaggingRules or not(parent::*)">
  926. <xsl:copy-of select="$flaggingRules"/>
  927. </xsl:when>
  928. <xsl:otherwise>
  929. <xsl:apply-templates select="parent::*" mode="getFlaggingRules"/>
  930. </xsl:otherwise>
  931. </xsl:choose>
  932. </xsl:template>
  933. <!-- recusive template to get flagging name -->
  934. <xsl:template match="*" name="getFlaggingStyleName" mode="getFlaggingStyleName">
  935. <xsl:variable name="flaggingStyleName">
  936. <xsl:call-template name="getFlagStyleName"/>
  937. </xsl:variable>
  938. <xsl:choose>
  939. <xsl:when test="$flaggingStyleName != '' or not(parent::*)">
  940. <xsl:value-of select="$flaggingStyleName"/>
  941. </xsl:when>
  942. <xsl:otherwise>
  943. <xsl:apply-templates select="parent::*" mode="getFlaggingStyleName"/>
  944. </xsl:otherwise>
  945. </xsl:choose>
  946. </xsl:template>
  947. <xsl:function name="dita-ot:getColor" as="xs:string">
  948. <xsl:param name="color"/>
  949. <xsl:choose>
  950. <xsl:when test="$color = 'aliceblue'">#f0f8ff</xsl:when>
  951. <xsl:when test="$color = 'antiquewhite'">#faebd7</xsl:when>
  952. <xsl:when test="$color = 'aqua'">#00ffff</xsl:when>
  953. <xsl:when test="$color = 'aquamarine'">#7fffd4</xsl:when>
  954. <xsl:when test="$color = 'azure'">#f0ffff</xsl:when>
  955. <xsl:when test="$color = 'beige'">#f5f5dc</xsl:when>
  956. <xsl:when test="$color = 'bisque'">#ffe4c4</xsl:when>
  957. <xsl:when test="$color = 'black'">#000000</xsl:when>
  958. <xsl:when test="$color = 'blanchedalmond'">#ffebcd</xsl:when>
  959. <xsl:when test="$color = 'blue'">#0000ff</xsl:when>
  960. <xsl:when test="$color = 'blueviolet'">#8a2be2</xsl:when>
  961. <xsl:when test="$color = 'brown'">#a52a2a</xsl:when>
  962. <xsl:when test="$color = 'burlywood'">#deb887</xsl:when>
  963. <xsl:when test="$color = 'cadetblue'">#5f9ea0</xsl:when>
  964. <xsl:when test="$color = 'chartreuse'">#7fff00</xsl:when>
  965. <xsl:when test="$color = 'chocolate'">#d2691e</xsl:when>
  966. <xsl:when test="$color = 'coral'">#ff7f50</xsl:when>
  967. <xsl:when test="$color = 'cornflowerblue'">#6495ed</xsl:when>
  968. <xsl:when test="$color = 'cornsilk'">#fff8dc</xsl:when>
  969. <xsl:when test="$color = 'crimson'">#dc143c</xsl:when>
  970. <xsl:when test="$color = 'cyan'">#00ffff</xsl:when>
  971. <xsl:when test="$color = 'darkblue'">#00008b</xsl:when>
  972. <xsl:when test="$color = 'darkcyan'">#008b8b</xsl:when>
  973. <xsl:when test="$color = 'darkgoldenrod'">#b8860b</xsl:when>
  974. <xsl:when test="$color = 'darkgray'">#a9a9a9</xsl:when>
  975. <xsl:when test="$color = 'darkgreen'">#006400</xsl:when>
  976. <xsl:when test="$color = 'darkkhaki'">#bdb76b</xsl:when>
  977. <xsl:when test="$color = 'darkmagenta'">#8b008b</xsl:when>
  978. <xsl:when test="$color = 'darkolivegreen'">#556b2f</xsl:when>
  979. <xsl:when test="$color = 'darkorange'">#ff8c00</xsl:when>
  980. <xsl:when test="$color = 'darkorchid'">#9932cc</xsl:when>
  981. <xsl:when test="$color = 'darkred'">#8b0000</xsl:when>
  982. <xsl:when test="$color = 'darksalmon'">#e9967a</xsl:when>
  983. <xsl:when test="$color = 'darkseagreen'">#8fbc8f</xsl:when>
  984. <xsl:when test="$color = 'darkslateblue'">#483d8b</xsl:when>
  985. <xsl:when test="$color = 'darkslategray'">#2f4f4f</xsl:when>
  986. <xsl:when test="$color = 'darkturquoise'">#00ced1</xsl:when>
  987. <xsl:when test="$color = 'darkviolet'">#9400d3</xsl:when>
  988. <xsl:when test="$color = 'deeppink'">#ff1493</xsl:when>
  989. <xsl:when test="$color = 'deepskyblue'">#00bfff</xsl:when>
  990. <xsl:when test="$color = 'dimgray'">#696969</xsl:when>
  991. <xsl:when test="$color = 'dodgerblue'">#1e90ff</xsl:when>
  992. <xsl:when test="$color = 'firebrick'">#b22222</xsl:when>
  993. <xsl:when test="$color = 'floralwhite'">#fffaf0</xsl:when>
  994. <xsl:when test="$color = 'forestgreen'">#228b22</xsl:when>
  995. <xsl:when test="$color = 'fuchsia'">#ff00ff</xsl:when>
  996. <xsl:when test="$color = 'gainsboro'">#dcdcdc</xsl:when>
  997. <xsl:when test="$color = 'ghostwhite'">#f8f8ff</xsl:when>
  998. <xsl:when test="$color = 'gold'">#ffd700</xsl:when>
  999. <xsl:when test="$color = 'goldenrod'">#daa520</xsl:when>
  1000. <xsl:when test="$color = 'gray'">#808080</xsl:when>
  1001. <xsl:when test="$color = 'green'">#008000</xsl:when>
  1002. <xsl:when test="$color = 'greenyellow'">#adff2f</xsl:when>
  1003. <xsl:when test="$color = 'honeydew'">#f0fff0</xsl:when>
  1004. <xsl:when test="$color = 'hotpink'">#ff69b4</xsl:when>
  1005. <xsl:when test="$color = 'indianred'">#cd5c5c</xsl:when>
  1006. <xsl:when test="$color = 'indigo'">#4b0082</xsl:when>
  1007. <xsl:when test="$color = 'ivory'">#fffff0</xsl:when>
  1008. <xsl:when test="$color = 'khaki'">#f0e68c</xsl:when>
  1009. <xsl:when test="$color = 'lavender'">#e6e6fa</xsl:when>
  1010. <xsl:when test="$color = 'lavenderblush'">#fff0f5</xsl:when>
  1011. <xsl:when test="$color = 'lawngreen'">#7cfc00</xsl:when>
  1012. <xsl:when test="$color = 'lemonchiffon'">#fffacd</xsl:when>
  1013. <xsl:when test="$color = 'lightblue'">#add8e6</xsl:when>
  1014. <xsl:when test="$color = 'lightcoral'">#f08080</xsl:when>
  1015. <xsl:when test="$color = 'lightcyan'">#e0ffff</xsl:when>
  1016. <xsl:when test="$color = 'lightgoldenrodyellow'">#fafad2</xsl:when>
  1017. <xsl:when test="$color = 'lightgrey'">#d3d3d3</xsl:when>
  1018. <xsl:when test="$color = 'lightgreen'">#90ee90</xsl:when>
  1019. <xsl:when test="$color = 'lightpink'">#ffb6c1</xsl:when>
  1020. <xsl:when test="$color = 'lightsalmon'">#ffa07a</xsl:when>
  1021. <xsl:when test="$color = 'lightseagreen'">#20b2aa</xsl:when>
  1022. <xsl:when test="$color = 'lightskyblue'">#87cefa</xsl:when>
  1023. <xsl:when test="$color = 'lightslategray'">#778899</xsl:when>
  1024. <xsl:when test="$color = 'lightsteelblue'">#b0c4de</xsl:when>
  1025. <xsl:when test="$color = 'lightyellow'">#ffffe0</xsl:when>
  1026. <xsl:when test="$color = 'lime'">#00ff00</xsl:when>
  1027. <xsl:when test="$color = 'limegreen'">#32cd32</xsl:when>
  1028. <xsl:when test="$color = 'linen'">#faf0e6</xsl:when>
  1029. <xsl:when test="$color = 'magenta'">#ff00ff</xsl:when>
  1030. <xsl:when test="$color = 'maroon'">#800000</xsl:when>
  1031. <xsl:when test="$color = 'mediumaquamarine'">#66cdaa</xsl:when>
  1032. <xsl:when test="$color = 'mediumblue'">#0000cd</xsl:when>
  1033. <xsl:when test="$color = 'mediumorchid'">#ba55d3</xsl:when>
  1034. <xsl:when test="$color = 'mediumpurple'">#9370d8</xsl:when>
  1035. <xsl:when test="$color = 'mediumseagreen'">#3cb371</xsl:when>
  1036. <xsl:when test="$color = 'mediumslateblue'">#7b68ee</xsl:when>
  1037. <xsl:when test="$color = 'mediumspringgreen'">#00fa9a</xsl:when>
  1038. <xsl:when test="$color = 'mediumturquoise'">#48d1cc</xsl:when>
  1039. <xsl:when test="$color = 'mediumvioletred'">#c71585</xsl:when>
  1040. <xsl:when test="$color = 'midnightblue'">#191970</xsl:when>
  1041. <xsl:when test="$color = 'mintcream'">#f5fffa</xsl:when>
  1042. <xsl:when test="$color = 'mistyrose'">#ffe4e1</xsl:when>
  1043. <xsl:when test="$color = 'moccasin'">#ffe4b5</xsl:when>
  1044. <xsl:when test="$color = 'navajowhite'">#ffdead</xsl:when>
  1045. <xsl:when test="$color = 'navy'">#000080</xsl:when>
  1046. <xsl:when test="$color = 'oldlace'">#fdf5e6</xsl:when>
  1047. <xsl:when test="$color = 'olive'">#808000</xsl:when>
  1048. <xsl:when test="$color = 'olivedrab'">#6b8e23</xsl:when>
  1049. <xsl:when test="$color = 'orange'">#ffa500</xsl:when>
  1050. <xsl:when test="$color = 'orangered'">#ff4500</xsl:when>
  1051. <xsl:when test="$color = 'orchid'">#da70d6</xsl:when>
  1052. <xsl:when test="$color = 'palegoldenrod'">#eee8aa</xsl:when>
  1053. <xsl:when test="$color = 'palegreen'">#98fb98</xsl:when>
  1054. <xsl:when test="$color = 'paleturquoise'">#afeeee</xsl:when>
  1055. <xsl:when test="$color = 'palevioletred'">#d87093</xsl:when>
  1056. <xsl:when test="$color = 'papayawhip'">#ffefd5</xsl:when>
  1057. <xsl:when test="$color = 'peachpuff'">#ffdab9</xsl:when>
  1058. <xsl:when test="$color = 'peru'">#cd853f</xsl:when>
  1059. <xsl:when test="$color = 'pink'">#ffc0cb</xsl:when>
  1060. <xsl:when test="$color = 'plum'">#dda0dd</xsl:when>
  1061. <xsl:when test="$color = 'powderblue'">#b0e0e6</xsl:when>
  1062. <xsl:when test="$color = 'purple'">#800080</xsl:when>
  1063. <xsl:when test="$color = 'red'">#ff0000</xsl:when>
  1064. <xsl:when test="$color = 'rosybrown'">#bc8f8f</xsl:when>
  1065. <xsl:when test="$color = 'royalblue'">#4169e1</xsl:when>
  1066. <xsl:when test="$color = 'saddlebrown'">#8b4513</xsl:when>
  1067. <xsl:when test="$color = 'salmon'">#fa8072</xsl:when>
  1068. <xsl:when test="$color = 'sandybrown'">#f4a460</xsl:when>
  1069. <xsl:when test="$color = 'seagreen'">#2e8b57</xsl:when>
  1070. <xsl:when test="$color = 'seashell'">#fff5ee</xsl:when>
  1071. <xsl:when test="$color = 'sienna'">#a0522d</xsl:when>
  1072. <xsl:when test="$color = 'silver'">#c0c0c0</xsl:when>
  1073. <xsl:when test="$color = 'skyblue'">#87ceeb</xsl:when>
  1074. <xsl:when test="$color = 'slateblue'">#6a5acd</xsl:when>
  1075. <xsl:when test="$color = 'slategray'">#708090</xsl:when>
  1076. <xsl:when test="$color = 'snow'">#fffafa</xsl:when>
  1077. <xsl:when test="$color = 'springgreen'">#00ff7f</xsl:when>
  1078. <xsl:when test="$color = 'steelblue'">#4682b4</xsl:when>
  1079. <xsl:when test="$color = 'tan'">#d2b48c</xsl:when>
  1080. <xsl:when test="$color = 'teal'">#008080</xsl:when>
  1081. <xsl:when test="$color = 'thistle'">#d8bfd8</xsl:when>
  1082. <xsl:when test="$color = 'tomato'">#ff6347</xsl:when>
  1083. <xsl:when test="$color = 'turquoise'">#40e0d0</xsl:when>
  1084. <xsl:when test="$color = 'violet'">#ee82ee</xsl:when>
  1085. <xsl:when test="$color = 'wheat'">#f5deb3</xsl:when>
  1086. <xsl:when test="$color = 'white'">#ffffff</xsl:when>
  1087. <xsl:when test="$color = 'whitesmoke'">#f5f5f5</xsl:when>
  1088. <xsl:when test="$color = 'yellow'">#ffff00</xsl:when>
  1089. <xsl:when test="$color = 'yellowgreen'">#9acd32</xsl:when>
  1090. <xsl:when test="starts-with($color, '#')"><xsl:value-of select="$color"/></xsl:when>
  1091. <xsl:otherwise><xsl:text></xsl:text></xsl:otherwise>
  1092. </xsl:choose>
  1093. </xsl:function>
  1094. </xsl:stylesheet>