flag.xsl 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451
  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. 2007, 2009 All Rights Reserved. -->
  5. <!-- Updates:
  6. 20090421 robander: Updated so that "flagrules" in all templates
  7. specifies a default. Can simplify calls from other XSL
  8. to these templates, with a slight trade-off in processing
  9. time. Default for "conflictexist" simplifies XSL
  10. elsewhere with no processing trade-off.
  11. -->
  12. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  13. version="2.0"
  14. xmlns:dita2html="http://dita-ot.sourceforge.net/ns/200801/dita2html"
  15. xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
  16. xmlns:styleUtils="org.dita.dost.util.StyleUtils"
  17. xmlns:imgUtils="org.dita.dost.util.ImgUtils"
  18. exclude-result-prefixes="dita2html ditamsg styleUtils imgUtils">
  19. <!-- ========== Flagging with flags & revisions ========== -->
  20. <!-- Single template to set flag variables, generate props and revision flagging, and output
  21. contents. Can be used by any element that does not use any markup between flags and contents. -->
  22. <xsl:template match="*" mode="outputContentsWithFlags">
  23. <xsl:variable name="flagrules">
  24. <xsl:call-template name="getrules"/>
  25. </xsl:variable>
  26. <xsl:call-template name="start-flagit">
  27. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  28. </xsl:call-template>
  29. <xsl:call-template name="revblock">
  30. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  31. </xsl:call-template>
  32. <xsl:call-template name="end-flagit">
  33. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  34. </xsl:call-template>
  35. </xsl:template>
  36. <!-- Single template to set the background style, flag based on props and revisions, and output
  37. contents. Can be used by any element that does not use any markup between flags and contents. -->
  38. <xsl:template match="*" mode="outputContentsWithFlagsAndStyle">
  39. <xsl:variable name="flagrules">
  40. <xsl:call-template name="getrules"/>
  41. </xsl:variable>
  42. <xsl:variable name="conflictexist">
  43. <xsl:call-template name="conflict-check">
  44. <xsl:with-param name="flagrules" select="$flagrules"/>
  45. </xsl:call-template>
  46. </xsl:variable>
  47. <xsl:call-template name="gen-style">
  48. <xsl:with-param name="conflictexist" select="$conflictexist"></xsl:with-param>
  49. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  50. </xsl:call-template>
  51. <xsl:call-template name="start-flagit">
  52. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  53. </xsl:call-template>
  54. <xsl:call-template name="revblock">
  55. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  56. </xsl:call-template>
  57. <xsl:call-template name="end-flagit">
  58. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  59. </xsl:call-template>
  60. </xsl:template>
  61. <!-- Flags - based on audience, product, platform, and otherprops in the source
  62. AND prop elements in the val file:
  63. Flag the text with the artwork from the val file & insert the ALT text from the val file.
  64. For multiple attr values, output each flag in turn.
  65. -->
  66. <xsl:template name="getrules">
  67. <xsl:variable name="domains" select="normalize-space(ancestor-or-self::*[contains(@class,' topic/topic ')][1]/@domains)"/>
  68. <xsl:variable name="tmp_props">
  69. <xsl:call-template name="getExtProps">
  70. <xsl:with-param name="domains" select="$domains"/>
  71. </xsl:call-template>
  72. </xsl:variable>
  73. <xsl:variable name="props" select="substring-after($tmp_props, ',')"/>
  74. <!-- Test for the flagging attributes. If found, call 'gen-prop' with the values to use. Otherwise return -->
  75. <xsl:if test="@audience and not($FILTERFILE='')">
  76. <xsl:call-template name="gen-prop">
  77. <xsl:with-param name="flag-att" select="'audience'"/>
  78. <xsl:with-param name="flag-att-val" select="@audience"/>
  79. </xsl:call-template>
  80. </xsl:if>
  81. <xsl:if test="@platform and not($FILTERFILE='')">
  82. <xsl:call-template name="gen-prop">
  83. <xsl:with-param name="flag-att" select="'platform'"/>
  84. <xsl:with-param name="flag-att-val" select="@platform"/>
  85. </xsl:call-template>
  86. </xsl:if>
  87. <xsl:if test="@product and not($FILTERFILE='')">
  88. <xsl:call-template name="gen-prop">
  89. <xsl:with-param name="flag-att" select="'product'"/>
  90. <xsl:with-param name="flag-att-val" select="@product"/>
  91. </xsl:call-template>
  92. </xsl:if>
  93. <xsl:if test="@otherprops and not($FILTERFILE='')">
  94. <xsl:call-template name="gen-prop">
  95. <xsl:with-param name="flag-att" select="'otherprops'"/>
  96. <xsl:with-param name="flag-att-val" select="@otherprops"/>
  97. </xsl:call-template>
  98. </xsl:if>
  99. <xsl:if test="@rev and not($FILTERFILE='')">
  100. <xsl:call-template name="gen-prop">
  101. <xsl:with-param name="flag-att" select="'rev'"/>
  102. <xsl:with-param name="flag-att-val" select="@rev"/>
  103. </xsl:call-template>
  104. </xsl:if>
  105. <xsl:if test="not($props='') and not($FILTERFILE='')">
  106. <xsl:call-template name="ext-getrules">
  107. <xsl:with-param name="props" select="$props"/>
  108. </xsl:call-template>
  109. </xsl:if>
  110. </xsl:template>
  111. <xsl:template name="getExtProps">
  112. <xsl:param name="domains"/>
  113. <xsl:choose>
  114. <xsl:when test="contains($domains, 'a(props')">
  115. <xsl:text>,</xsl:text><xsl:value-of select="normalize-space(concat('props',substring-before(substring-after($domains,'a(props'), ')')))"/>
  116. <xsl:call-template name="getExtProps">
  117. <xsl:with-param name="domains" select="substring-after(substring-after($domains,'a(props'), ')')"/>
  118. </xsl:call-template>
  119. </xsl:when>
  120. <xsl:otherwise/>
  121. </xsl:choose>
  122. </xsl:template>
  123. <xsl:template name="ext-getrules">
  124. <xsl:param name="props"/>
  125. <xsl:choose>
  126. <xsl:when test="contains($props,',')">
  127. <xsl:variable name="propsValue">
  128. <xsl:call-template name="getPropsValue">
  129. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  130. </xsl:call-template>
  131. </xsl:variable>
  132. <xsl:variable name="propName">
  133. <xsl:call-template name="getLastPropName">
  134. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  135. </xsl:call-template>
  136. </xsl:variable>
  137. <xsl:if test="not($propsValue='')">
  138. <xsl:call-template name="ext-gen-prop">
  139. <xsl:with-param name="flag-att-path" select="substring-before($props,',')"/>
  140. <xsl:with-param name="flag-att-val" select="$propsValue"/>
  141. </xsl:call-template>
  142. </xsl:if>
  143. <xsl:call-template name="ext-getrules">
  144. <xsl:with-param name="props" select="substring-after($props,',')"/>
  145. </xsl:call-template>
  146. </xsl:when>
  147. <xsl:otherwise>
  148. <xsl:variable name="propsValue">
  149. <xsl:call-template name="getPropsValue">
  150. <xsl:with-param name="propsPath" select="$props"/>
  151. </xsl:call-template>
  152. </xsl:variable>
  153. <xsl:variable name="propName">
  154. <xsl:call-template name="getLastPropName">
  155. <xsl:with-param name="propsPath" select="$props"/>
  156. </xsl:call-template>
  157. </xsl:variable>
  158. <xsl:if test="not($propsValue='')">
  159. <xsl:call-template name="ext-gen-prop">
  160. <xsl:with-param name="flag-att-path" select="$props"/>
  161. <xsl:with-param name="flag-att-val" select="$propsValue"/>
  162. </xsl:call-template>
  163. </xsl:if>
  164. </xsl:otherwise>
  165. </xsl:choose>
  166. </xsl:template>
  167. <xsl:template name="getPropsValue">
  168. <xsl:param name="propsPath"/>
  169. <xsl:variable name="propName">
  170. <xsl:call-template name="getLastPropName">
  171. <xsl:with-param name="propsPath" select="$propsPath"/>
  172. </xsl:call-template>
  173. </xsl:variable>
  174. <xsl:choose>
  175. <xsl:when test="@*[name()=$propName]">
  176. <xsl:value-of select="@*[name()=$propName]"/>
  177. </xsl:when>
  178. <xsl:otherwise>
  179. <xsl:call-template name="getGeneralValue">
  180. <xsl:with-param name="propName" select="$propName"/>
  181. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propName))"/>
  182. </xsl:call-template>
  183. </xsl:otherwise>
  184. </xsl:choose>
  185. </xsl:template>
  186. <xsl:template name="getGeneralValue">
  187. <xsl:param name="propsPath"/>
  188. <xsl:param name="propName"/>
  189. <xsl:variable name="propParentName">
  190. <xsl:call-template name="getLastPropName">
  191. <xsl:with-param name="propsPath" select="$propsPath"/>
  192. </xsl:call-template>
  193. </xsl:variable>
  194. <xsl:choose>
  195. <xsl:when test="contains(@*[name()=$propParentName],concat($propName,'('))">
  196. <xsl:value-of select="substring-before(substring-after(@*[name()=$propParentName],concat($propName,'(')),')')"/>
  197. </xsl:when>
  198. <xsl:otherwise>
  199. <xsl:choose>
  200. <xsl:when test="contains($propsPath,' ')">
  201. <xsl:call-template name="getGeneralValue">
  202. <xsl:with-param name="propName" select="$propName"/>
  203. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propParentName))"/>
  204. </xsl:call-template>
  205. </xsl:when>
  206. <xsl:otherwise/>
  207. </xsl:choose>
  208. </xsl:otherwise>
  209. </xsl:choose>
  210. </xsl:template>
  211. <xsl:template name="getLastPropName">
  212. <xsl:param name="propsPath"/>
  213. <xsl:choose>
  214. <xsl:when test="contains($propsPath,' ')">
  215. <xsl:call-template name="getLastPropName">
  216. <xsl:with-param name="propsPath" select="substring-after($propsPath,' ')"/>
  217. </xsl:call-template>
  218. </xsl:when>
  219. <xsl:otherwise>
  220. <xsl:value-of select="$propsPath"/>
  221. </xsl:otherwise>
  222. </xsl:choose>
  223. </xsl:template>
  224. <!-- No flagging attrs allowed to process in phrases - output a message when in debug mode. -->
  225. <xsl:template name="flagcheck">
  226. <xsl:variable name="domains" select="normalize-space(ancestor-or-self::*[contains(@class,' topic/topic ')][1]/@domains)"/>
  227. <xsl:variable name="props">
  228. <xsl:if test="contains($domains, 'a(props')">
  229. <xsl:value-of select="normalize-space(substring-before(substring-after($domains,'a(props'), ')'))"/>
  230. </xsl:if>
  231. </xsl:variable>
  232. <xsl:if test="$DBG='yes' and not($FILTERFILE='')">
  233. <xsl:if test="@audience">
  234. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  235. <xsl:with-param name="attr-name" select="'audience'"/>
  236. </xsl:apply-templates>
  237. </xsl:if>
  238. <xsl:if test="@platform">
  239. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  240. <xsl:with-param name="attr-name" select="'platform'"/>
  241. </xsl:apply-templates>
  242. </xsl:if>
  243. <xsl:if test="@product">
  244. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  245. <xsl:with-param name="attr-name" select="'product'"/>
  246. </xsl:apply-templates>
  247. </xsl:if>
  248. <xsl:if test="@otherprops">
  249. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  250. <xsl:with-param name="attr-name" select="'otherprops'"/>
  251. </xsl:apply-templates>
  252. </xsl:if>
  253. <xsl:if test="not($props='')">
  254. <xsl:call-template name="ext-flagcheck">
  255. <xsl:with-param name="props" select="$props"/>
  256. </xsl:call-template>
  257. </xsl:if>
  258. </xsl:if>
  259. </xsl:template>
  260. <xsl:template name="ext-flagcheck">
  261. <xsl:param name="props"/>
  262. <xsl:choose>
  263. <xsl:when test="contains($props,',')">
  264. <xsl:variable name="propsValue">
  265. <xsl:call-template name="getPropsValue">
  266. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  267. </xsl:call-template>
  268. </xsl:variable>
  269. <xsl:variable name="propName">
  270. <xsl:call-template name="getLastPropName">
  271. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  272. </xsl:call-template>
  273. </xsl:variable>
  274. <xsl:if test="not($propsValue='')">
  275. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  276. <xsl:with-param name="attr-name" select="$propName"/>
  277. </xsl:apply-templates>
  278. </xsl:if>
  279. <xsl:call-template name="ext-flagcheck">
  280. <xsl:with-param name="props" select="substring-after($props,',')"/>
  281. </xsl:call-template>
  282. </xsl:when>
  283. <xsl:otherwise>
  284. <xsl:variable name="propsValue">
  285. <xsl:call-template name="getPropsValue">
  286. <xsl:with-param name="propsPath" select="$props"/>
  287. </xsl:call-template>
  288. </xsl:variable>
  289. <xsl:variable name="propName">
  290. <xsl:call-template name="getLastPropName">
  291. <xsl:with-param name="propsPath" select="$props"/>
  292. </xsl:call-template>
  293. </xsl:variable>
  294. <xsl:if test="not($propsValue='')">
  295. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  296. <xsl:with-param name="attr-name" select="$propName"/>
  297. </xsl:apply-templates>
  298. </xsl:if>
  299. </xsl:otherwise>
  300. </xsl:choose>
  301. </xsl:template>
  302. <xsl:template name="getrules-parent">
  303. <xsl:variable name="domains" select="normalize-space(ancestor::*[contains(@class,' topic/topic ')][1]/@domains)"/>
  304. <xsl:variable name="props">
  305. <xsl:if test="contains($domains, 'a(props')">
  306. <xsl:value-of select="normalize-space(substring-before(substring-after($domains,'a(props'), ')'))"/>
  307. </xsl:if>
  308. </xsl:variable>
  309. <!-- Test for the flagging attributes on the parent.
  310. If found and if the filterfile name was passed in,
  311. call 'gen-prop' with the values to use. Otherwise return -->
  312. <xsl:if test="../@audience and not($FILTERFILE='')">
  313. <xsl:call-template name="gen-prop">
  314. <xsl:with-param name="flag-att" select="'audience'"/>
  315. <xsl:with-param name="flag-att-val" select="../@audience"/>
  316. </xsl:call-template>
  317. </xsl:if>
  318. <xsl:if test="../@platform and not($FILTERFILE='')">
  319. <xsl:call-template name="gen-prop">
  320. <xsl:with-param name="flag-att" select="'platform'"/>
  321. <xsl:with-param name="flag-att-val" select="../@platform"/>
  322. </xsl:call-template>
  323. </xsl:if>
  324. <xsl:if test="../@product and not($FILTERFILE='')">
  325. <xsl:call-template name="gen-prop">
  326. <xsl:with-param name="flag-att" select="'product'"/>
  327. <xsl:with-param name="flag-att-val" select="../@product"/>
  328. </xsl:call-template>
  329. </xsl:if>
  330. <xsl:if test="../@otherprops and not($FILTERFILE='')">
  331. <xsl:call-template name="gen-prop">
  332. <xsl:with-param name="flag-att" select="'otherprops'"/>
  333. <xsl:with-param name="flag-att-val" select="../@otherprops"/>
  334. </xsl:call-template>
  335. </xsl:if>
  336. <xsl:if test="../@rev and not(@rev) and not($FILTERFILE='')">
  337. <xsl:call-template name="gen-prop">
  338. <xsl:with-param name="flag-att" select="'rev'"/>
  339. <xsl:with-param name="flag-att-val" select="../@rev"/>
  340. </xsl:call-template>
  341. </xsl:if>
  342. <xsl:if test="not($props='') and not($FILTERFILE='')">
  343. <xsl:call-template name="ext-getrules-parent">
  344. <xsl:with-param name="props" select="$props"/>
  345. </xsl:call-template>
  346. </xsl:if>
  347. </xsl:template>
  348. <xsl:template name="ext-getrules-parent">
  349. <xsl:param name="props"/>
  350. <xsl:choose>
  351. <xsl:when test="contains($props,',')">
  352. <xsl:variable name="propsValue">
  353. <xsl:call-template name="getPropsValue-parent">
  354. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  355. </xsl:call-template>
  356. </xsl:variable>
  357. <xsl:variable name="propName">
  358. <xsl:call-template name="getLastPropName">
  359. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  360. </xsl:call-template>
  361. </xsl:variable>
  362. <xsl:if test="not($propsValue='')">
  363. <xsl:call-template name="ext-gen-prop">
  364. <xsl:with-param name="flag-att-path" select="substring-before($props,',')"/>
  365. <xsl:with-param name="flag-att-val" select="$propsValue"/>
  366. </xsl:call-template>
  367. </xsl:if>
  368. <xsl:call-template name="ext-getrules-parent">
  369. <xsl:with-param name="props" select="substring-after($props,',')"/>
  370. </xsl:call-template>
  371. </xsl:when>
  372. <xsl:otherwise>
  373. <xsl:variable name="propsValue">
  374. <xsl:call-template name="getPropsValue-parent">
  375. <xsl:with-param name="propsPath" select="$props"/>
  376. </xsl:call-template>
  377. </xsl:variable>
  378. <xsl:variable name="propName">
  379. <xsl:call-template name="getLastPropName">
  380. <xsl:with-param name="propsPath" select="$props"/>
  381. </xsl:call-template>
  382. </xsl:variable>
  383. <xsl:if test="not($propsValue='')">
  384. <xsl:call-template name="ext-gen-prop">
  385. <xsl:with-param name="flag-att-path" select="$props"/>
  386. <xsl:with-param name="flag-att-val" select="$propsValue"/>
  387. </xsl:call-template>
  388. </xsl:if>
  389. </xsl:otherwise>
  390. </xsl:choose>
  391. </xsl:template>
  392. <xsl:template name="getPropsValue-parent">
  393. <xsl:param name="propsPath"/>
  394. <xsl:variable name="propName">
  395. <xsl:call-template name="getLastPropName">
  396. <xsl:with-param name="propsPath" select="$propsPath"/>
  397. </xsl:call-template>
  398. </xsl:variable>
  399. <xsl:choose>
  400. <xsl:when test="../@*[name()=$propName]">
  401. <xsl:value-of select="../@*[name()=$propName]"/>
  402. </xsl:when>
  403. <xsl:otherwise>
  404. <xsl:call-template name="getGeneralValue-parent">
  405. <xsl:with-param name="propName" select="$propName"/>
  406. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propName))"/>
  407. </xsl:call-template>
  408. </xsl:otherwise>
  409. </xsl:choose>
  410. </xsl:template>
  411. <xsl:template name="getGeneralValue-parent">
  412. <xsl:param name="propsPath"/>
  413. <xsl:param name="propName"/>
  414. <xsl:variable name="propParentName">
  415. <xsl:call-template name="getLastPropName">
  416. <xsl:with-param name="propsPath" select="$propsPath"/>
  417. </xsl:call-template>
  418. </xsl:variable>
  419. <xsl:choose>
  420. <xsl:when test="contains(../@*[name()=$propParentName],concat($propName,'('))">
  421. <xsl:value-of select="substring-before(substring-after(../@*[name()=$propParentName],concat($propName,'(')),')')"/>
  422. </xsl:when>
  423. <xsl:otherwise>
  424. <xsl:choose>
  425. <xsl:when test="contains($propsPath,' ')">
  426. <xsl:call-template name="getGeneralValue-parent">
  427. <xsl:with-param name="propName" select="$propName"/>
  428. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propParentName))"/>
  429. </xsl:call-template>
  430. </xsl:when>
  431. <xsl:otherwise/>
  432. </xsl:choose>
  433. </xsl:otherwise>
  434. </xsl:choose>
  435. </xsl:template>
  436. <!-- Use passed attr value to mark each active flag. -->
  437. <xsl:template name="ext-gen-prop">
  438. <xsl:param name="flag-att-path"/>
  439. <xsl:param name="flag-att-val"/>
  440. <xsl:variable name="propName">
  441. <xsl:call-template name="getLastPropName">
  442. <xsl:with-param name="propsPath" select="$flag-att-path"/>
  443. </xsl:call-template>
  444. </xsl:variable>
  445. <xsl:variable name="flag-result">
  446. <xsl:call-template name="gen-prop">
  447. <xsl:with-param name="flag-att" select="$propName"/>
  448. <xsl:with-param name="flag-att-val" select="$flag-att-val"/>
  449. </xsl:call-template>
  450. </xsl:variable>
  451. <xsl:choose>
  452. <xsl:when test="$flag-result/prop">
  453. <xsl:copy-of select="$flag-result"/>
  454. </xsl:when>
  455. <xsl:otherwise>
  456. <xsl:if test="contains($flag-att-path,' ')">
  457. <xsl:call-template name="ext-gen-prop">
  458. <xsl:with-param name="flag-att-path" select="normalize-space(substring-before($flag-att-path, $propName))"/>
  459. <xsl:with-param name="flag-att-val" select="$flag-att-val"/>
  460. </xsl:call-template>
  461. </xsl:if>
  462. </xsl:otherwise>
  463. </xsl:choose>
  464. </xsl:template>
  465. <xsl:template name="gen-prop">
  466. <xsl:param name="flag-att"/> <!-- attribute name -->
  467. <xsl:param name="flag-att-val"/> <!-- content of attribute -->
  468. <!-- Determine the first flag value, which is the value before the first space -->
  469. <xsl:variable name="firstflag">
  470. <xsl:choose>
  471. <xsl:when test="contains($flag-att-val,' ')">
  472. <xsl:value-of select="substring-before($flag-att-val,' ')"/>
  473. </xsl:when>
  474. <xsl:otherwise> <!-- no space, one value -->
  475. <xsl:value-of select="$flag-att-val"/>
  476. </xsl:otherwise>
  477. </xsl:choose>
  478. </xsl:variable>
  479. <!-- Determine the other flag values, after the first space -->
  480. <xsl:variable name="moreflags">
  481. <xsl:choose>
  482. <xsl:when test="contains($flag-att-val,' ')">
  483. <xsl:value-of select="substring-after($flag-att-val,' ')"/>
  484. </xsl:when>
  485. <xsl:otherwise/> <!-- no space, one value -->
  486. </xsl:choose>
  487. </xsl:variable>
  488. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  489. <xsl:when test="$flag-att='rev' and $FILTERDOC/val/revprop[@val=$firstflag][@action='flag']">
  490. <xsl:copy-of select="$FILTERDOC/val/revprop[@val=$firstflag][@action='flag']"/>
  491. </xsl:when>
  492. <xsl:when test="$FILTERDOC/val/prop[@att=$flag-att][@val=$firstflag][@action='flag']">
  493. <xsl:copy-of select="$FILTERDOC/val/prop[@att=$flag-att][@val=$firstflag][@action='flag']"/>
  494. </xsl:when>
  495. <xsl:otherwise/> <!-- that flag not active -->
  496. </xsl:choose>
  497. <!-- keep testing other values -->
  498. <xsl:choose>
  499. <xsl:when test="string-length($moreflags)>0">
  500. <!-- more values - call it again with remaining values -->
  501. <xsl:call-template name="gen-prop">
  502. <xsl:with-param name="flag-att" select="$flag-att"/>
  503. <xsl:with-param name="flag-att-val" select="$moreflags"/>
  504. </xsl:call-template>
  505. </xsl:when>
  506. <xsl:otherwise/> <!-- no more values -->
  507. </xsl:choose>
  508. </xsl:template>
  509. <!-- copy needed elements -->
  510. <xsl:template match="*" mode="copy-element">
  511. <xsl:param name="att"/>
  512. <xsl:param name="bgcolor"/>
  513. <xsl:param name="fcolor"/>
  514. <xsl:param name="style"/>
  515. <xsl:param name="value"/>
  516. <xsl:param name="flag"/>
  517. <xsl:param name="cvffilename" select="@source"/>
  518. <xsl:param name="childnodes"/>
  519. <!--get the location of dita.xml.properties-->
  520. <xsl:variable name="INITIAL-PROPERTIES-FILE" select="translate(concat($WORKDIR , $PATH2PROJ , 'subject_scheme.dictionary'), '\', '/')"/>
  521. <xsl:variable name="PROPERTIES-FILE">
  522. <xsl:choose>
  523. <xsl:when test="starts-with($INITIAL-PROPERTIES-FILE,'/')">
  524. <xsl:text>file://</xsl:text><xsl:value-of select="$INITIAL-PROPERTIES-FILE"/>
  525. </xsl:when>
  526. <xsl:otherwise>
  527. <xsl:text>file:/</xsl:text><xsl:value-of select="$INITIAL-PROPERTIES-FILE"/>
  528. </xsl:otherwise>
  529. </xsl:choose>
  530. </xsl:variable>
  531. <!-- get the scheme list -->
  532. <!-- check CURRENT File -->
  533. <xsl:variable name="editedFileName">
  534. <xsl:call-template name="checkFile">
  535. <xsl:with-param name="in" select="$CURRENTFILE"/>
  536. </xsl:call-template>
  537. </xsl:variable>
  538. <xsl:variable name="schemeList">
  539. <xsl:apply-templates select="document($PROPERTIES-FILE,/)//*[@key=$editedFileName]" mode="check"/>
  540. </xsl:variable>
  541. <!-- scheme list contains the scheme file -->
  542. <xsl:if test="contains($schemeList, $cvffilename)">
  543. <!-- get the path of scheme file -->
  544. <xsl:variable name="submfile">
  545. <xsl:value-of select="$cvffilename"/><xsl:text>.subm</xsl:text>
  546. </xsl:variable>
  547. <xsl:variable name="cvffilepath" select="concat($WORKDIR,$PATH2PROJ,$submfile)"/>
  548. <xsl:if test="document($cvffilepath,/)//*[@keys=$value]//*[@keys=$flag]">
  549. <!-- copy the child node for flag and just copy the first element whose keys=$flag-->
  550. <!--xsl:for-each select="document($cvffilepath,/)//*[@keys=$value]/*"-->
  551. <xsl:for-each select="document($cvffilepath,/)//*[@keys=$value]//*[@keys=$flag][1]">
  552. <prop att="{$att}" val="{@keys}" action="{'flag'}" backcolor="{$bgcolor}" color="{$fcolor}" style="{$style}">
  553. <xsl:copy-of select="$childnodes"/>
  554. </prop>
  555. </xsl:for-each>
  556. </xsl:if>
  557. </xsl:if>
  558. </xsl:template>
  559. <!-- check CURRENT File -->
  560. <xsl:template name="checkFile">
  561. <xsl:param name="in"/>
  562. <xsl:choose>
  563. <xsl:when test="starts-with($in, '.\')">
  564. <xsl:value-of select="substring-after($in, '.\')"/>
  565. </xsl:when>
  566. <!-- The file dir passed in by ant cannot by none -->
  567. <xsl:when test="starts-with($in, './')">
  568. <xsl:value-of select="substring-after($in, './')"/>
  569. </xsl:when>
  570. <xsl:otherwise>
  571. <xsl:value-of select="$in"/>
  572. </xsl:otherwise>
  573. </xsl:choose>
  574. </xsl:template>
  575. <!-- get the scheme list -->
  576. <xsl:template match="*" mode="check">
  577. <xsl:value-of select="."/>
  578. </xsl:template>
  579. <xsl:template match="*" mode="getVal">
  580. <xsl:value-of select="@val"/>
  581. </xsl:template>
  582. <!-- get background color -->
  583. <xsl:template match="*" mode="getBgcolor">
  584. <xsl:choose>
  585. <xsl:when test="@backcolor">
  586. <xsl:value-of select="@backcolor"/>
  587. </xsl:when>
  588. <xsl:otherwise>
  589. <xsl:value-of select="''"/>
  590. </xsl:otherwise>
  591. </xsl:choose>
  592. </xsl:template>
  593. <!-- get font color -->
  594. <xsl:template match="*" mode="getColor">
  595. <xsl:choose>
  596. <xsl:when test="@color">
  597. <xsl:value-of select="@color"/>
  598. </xsl:when>
  599. <xsl:otherwise>
  600. <xsl:value-of select="''"/>
  601. </xsl:otherwise>
  602. </xsl:choose>
  603. </xsl:template>
  604. <!-- get font style -->
  605. <xsl:template match="*" mode="getStyle">
  606. <xsl:choose>
  607. <xsl:when test="@style">
  608. <xsl:value-of select="@style"/>
  609. </xsl:when>
  610. <xsl:otherwise>
  611. <xsl:value-of select="''"/>
  612. </xsl:otherwise>
  613. </xsl:choose>
  614. </xsl:template>
  615. <!-- get child nodes -->
  616. <xsl:template match="*" mode="getChildNode">
  617. <xsl:copy-of select="node()"/>
  618. </xsl:template>
  619. <!-- Shortcuts for generating both rev flags and property flags -->
  620. <xsl:template name="start-flags-and-rev">
  621. <xsl:param name="flagrules">
  622. <xsl:call-template name="getrules"/>
  623. </xsl:param>
  624. <xsl:call-template name="start-flagit">
  625. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  626. </xsl:call-template>
  627. <xsl:call-template name="start-revflag">
  628. <xsl:with-param name="flagrules" select="$flagrules"/>
  629. </xsl:call-template>
  630. </xsl:template>
  631. <xsl:template name="end-flags-and-rev">
  632. <xsl:param name="flagrules">
  633. <xsl:call-template name="getrules"/>
  634. </xsl:param>
  635. <xsl:call-template name="end-revflag">
  636. <xsl:with-param name="flagrules" select="$flagrules"/>
  637. </xsl:call-template>
  638. <xsl:call-template name="end-flagit">
  639. <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  640. </xsl:call-template>
  641. </xsl:template>
  642. <!-- Output starting flag only -->
  643. <xsl:template name="start-revflag">
  644. <xsl:param name="flagrules">
  645. <xsl:call-template name="getrules"/>
  646. </xsl:param>
  647. <xsl:if test="@rev and not($FILTERFILE='')">
  648. <xsl:call-template name="start-mark-rev">
  649. <xsl:with-param name="revvalue" select="@rev"/>
  650. <xsl:with-param name="flagrules" select="$flagrules"/>
  651. </xsl:call-template>
  652. </xsl:if>
  653. </xsl:template>
  654. <!-- Output ending flag only -->
  655. <xsl:template name="end-revflag">
  656. <xsl:param name="flagrules">
  657. <xsl:call-template name="getrules"/>
  658. </xsl:param>
  659. <xsl:if test="@rev and not($FILTERFILE='')">
  660. <xsl:call-template name="end-mark-rev">
  661. <xsl:with-param name="revvalue" select="@rev"/>
  662. <xsl:with-param name="flagrules" select="$flagrules"/>
  663. </xsl:call-template>
  664. </xsl:if>
  665. </xsl:template>
  666. <!-- for table entries - if the parent (row) has a rev but the cell does not - output the rev -->
  667. <xsl:template name="start-revflag-parent">
  668. <xsl:param name="flagrules">
  669. <xsl:call-template name="getrules-parent"/>
  670. </xsl:param>
  671. <xsl:if test="../@rev and not(@rev) and not($FILTERFILE='')">
  672. <xsl:call-template name="start-mark-rev">
  673. <xsl:with-param name="revvalue" select="../@rev"/>
  674. <xsl:with-param name="flagrules" select="$flagrules"/>
  675. </xsl:call-template>
  676. </xsl:if>
  677. </xsl:template>
  678. <xsl:template name="end-revflag-parent">
  679. <xsl:param name="flagrules">
  680. <xsl:call-template name="getrules-parent"/>
  681. </xsl:param>
  682. <xsl:if test="../@rev and not(@rev) and not($FILTERFILE='')">
  683. <xsl:call-template name="end-mark-rev">
  684. <xsl:with-param name="revvalue" select="../@rev"/>
  685. <xsl:with-param name="flagrules" select="$flagrules"/>
  686. </xsl:call-template>
  687. </xsl:if>
  688. </xsl:template>
  689. <!-- Output starting & ending flag for "blocked" text.
  690. Use instead of 'apply-templates' for block areas (P, Note, DD, etc) -->
  691. <xsl:template name="revblock">
  692. <xsl:param name="flagrules">
  693. <xsl:call-template name="getrules"/>
  694. </xsl:param>
  695. <xsl:choose>
  696. <xsl:when test="@rev and not($FILTERFILE='') and ($DRAFT='yes')"> <!-- draft rev mode, add div w/ rev attr value -->
  697. <xsl:variable name="revtest">
  698. <xsl:call-template name="find-active-rev-flag">
  699. <xsl:with-param name="allrevs" select="@rev"/>
  700. </xsl:call-template>
  701. </xsl:variable>
  702. <xsl:choose>
  703. <xsl:when test="$revtest=1">
  704. <div class="{@rev}">
  705. <xsl:call-template name="start-mark-rev">
  706. <xsl:with-param name="revvalue" select="@rev"/>
  707. <xsl:with-param name="flagrules" select="$flagrules"/>
  708. </xsl:call-template>
  709. <xsl:apply-templates/>
  710. <xsl:call-template name="end-mark-rev">
  711. <xsl:with-param name="revvalue" select="@rev"/>
  712. <xsl:with-param name="flagrules" select="$flagrules"/>
  713. </xsl:call-template>
  714. </div>
  715. </xsl:when>
  716. <xsl:otherwise>
  717. <xsl:apply-templates/>
  718. </xsl:otherwise>
  719. </xsl:choose>
  720. </xsl:when>
  721. <xsl:when test="@rev and not($FILTERFILE='')"> <!-- normal rev mode -->
  722. <xsl:call-template name="start-mark-rev">
  723. <xsl:with-param name="revvalue" select="@rev"/>
  724. <xsl:with-param name="flagrules" select="$flagrules"/>
  725. </xsl:call-template>
  726. <xsl:apply-templates/>
  727. <xsl:call-template name="end-mark-rev">
  728. <xsl:with-param name="revvalue" select="@rev"/>
  729. <xsl:with-param name="flagrules" select="$flagrules"/>
  730. </xsl:call-template>
  731. </xsl:when>
  732. <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> <!-- rev mode -->
  733. </xsl:choose>
  734. </xsl:template>
  735. <!-- Output starting & ending flag & color for phrase text.
  736. Use instead of 'apply-templates' for phrase areas (PH, B, DT, etc) -->
  737. <xsl:template name="revtext">
  738. <xsl:param name="flagrules">
  739. <xsl:call-template name="getrules"/>
  740. </xsl:param>
  741. <xsl:variable name="revtest">
  742. <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')">
  743. <xsl:call-template name="find-active-rev-flag">
  744. <xsl:with-param name="allrevs" select="@rev"/>
  745. </xsl:call-template>
  746. </xsl:if>
  747. </xsl:variable>
  748. <xsl:choose>
  749. <xsl:when test="$revtest=1"> <!-- Rev is active - add the SPAN -->
  750. <span class="{@rev}">
  751. <xsl:call-template name="start-mark-rev">
  752. <xsl:with-param name="revvalue" select="@rev"/>
  753. <xsl:with-param name="flagrules" select="$flagrules"/>
  754. </xsl:call-template>
  755. <xsl:call-template name="revstyle">
  756. <xsl:with-param name="revvalue" select="@rev"/>
  757. <xsl:with-param name="flagrules" select="$flagrules"/>
  758. </xsl:call-template>
  759. <xsl:call-template name="end-mark-rev">
  760. <xsl:with-param name="revvalue" select="@rev"/>
  761. <xsl:with-param name="flagrules" select="$flagrules"/>
  762. </xsl:call-template>
  763. </span>
  764. </xsl:when>
  765. <xsl:when test="@rev and not($FILTERFILE='')"> <!-- normal rev mode -->
  766. <xsl:call-template name="start-mark-rev">
  767. <xsl:with-param name="revvalue" select="@rev"/>
  768. <xsl:with-param name="flagrules" select="$flagrules"/>
  769. </xsl:call-template>
  770. <xsl:call-template name="revstyle">
  771. <xsl:with-param name="revvalue" select="@rev"/>
  772. <xsl:with-param name="flagrules" select="$flagrules"/>
  773. </xsl:call-template>
  774. <xsl:call-template name="end-mark-rev">
  775. <xsl:with-param name="revvalue" select="@rev"/>
  776. <xsl:with-param name="flagrules" select="$flagrules"/>
  777. </xsl:call-template>
  778. </xsl:when>
  779. <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> <!-- no rev mode -->
  780. </xsl:choose>
  781. </xsl:template>
  782. <!-- There's a rev attr - test for active rev values -->
  783. <xsl:template name="start-mark-rev">
  784. <xsl:param name="flagrules">
  785. <xsl:call-template name="getrules"/>
  786. </xsl:param>
  787. <xsl:param name="revvalue"/>
  788. <xsl:variable name="revtest">
  789. <xsl:call-template name="find-active-rev-flag">
  790. <xsl:with-param name="allrevs" select="$revvalue"/>
  791. </xsl:call-template>
  792. </xsl:variable>
  793. <xsl:if test="$revtest=1">
  794. <xsl:call-template name="start-revision-flag">
  795. <xsl:with-param name="flagrules" select="$flagrules"/>
  796. </xsl:call-template>
  797. </xsl:if>
  798. </xsl:template>
  799. <!-- There's a rev attr - test for active rev values -->
  800. <xsl:template name="end-mark-rev">
  801. <xsl:param name="flagrules">
  802. <xsl:call-template name="getrules"/>
  803. </xsl:param>
  804. <xsl:param name="revvalue"/>
  805. <xsl:variable name="revtest">
  806. <xsl:call-template name="find-active-rev-flag">
  807. <xsl:with-param name="allrevs" select="$revvalue"/>
  808. </xsl:call-template>
  809. </xsl:variable>
  810. <xsl:if test="$revtest=1">
  811. <xsl:call-template name="end-revision-flag">
  812. <xsl:with-param name="flagrules" select="$flagrules"/>
  813. </xsl:call-template>
  814. </xsl:if>
  815. </xsl:template>
  816. <!-- output the revision color & apply further templates-->
  817. <xsl:template name="revstyle">
  818. <xsl:param name="flagrules">
  819. <xsl:call-template name="getrules"/>
  820. </xsl:param>
  821. <xsl:param name="revvalue"/>
  822. <xsl:choose>
  823. <xsl:when test="not($flagrules)">
  824. <!-- $flagrules was not passed in, so the call must be looking for the deprecated template -->
  825. <xsl:call-template name="revstyle-deprecated"/>
  826. </xsl:when>
  827. <xsl:when test="$flagrules/revprop[@color or @backcolor]">
  828. <xsl:variable name="conflictexist">
  829. <xsl:call-template name="conflict-check">
  830. <xsl:with-param name="flagrules" select="$flagrules"/>
  831. </xsl:call-template>
  832. </xsl:variable>
  833. <font>
  834. <xsl:call-template name="gen-style"/>
  835. <xsl:apply-templates/>
  836. </font>
  837. </xsl:when>
  838. <xsl:otherwise>
  839. <xsl:variable name="revcolor">
  840. <xsl:call-template name="find-active-rev-style"> <!-- get 1st active rev color -->
  841. <xsl:with-param name="allrevs" select="$revvalue"/>
  842. </xsl:call-template>
  843. </xsl:variable>
  844. <xsl:choose>
  845. <xsl:when test="string-length($revcolor)>0"> <!-- if there's a value, there's an active color -->
  846. <font>
  847. <xsl:attribute name="color">
  848. <xsl:value-of select="$revcolor"/>
  849. </xsl:attribute>
  850. <xsl:apply-templates/>
  851. </font>
  852. </xsl:when>
  853. <xsl:otherwise>
  854. <xsl:apply-templates/> <!-- no active rev color - just apply templates -->
  855. </xsl:otherwise>
  856. </xsl:choose>
  857. </xsl:otherwise>
  858. </xsl:choose>
  859. </xsl:template>
  860. <!-- output the beginning revision graphic & ALT text -->
  861. <!-- Reverse the artwork for BIDI languages -->
  862. <xsl:template name="start-revision-flag">
  863. <xsl:param name="flagrules">
  864. <xsl:call-template name="getrules"/>
  865. </xsl:param>
  866. <xsl:variable name="biditest">
  867. <xsl:call-template name="bidi-area"/>
  868. </xsl:variable>
  869. <xsl:choose>
  870. <xsl:when test="not($flagrules)">
  871. <!-- $flagrules was not passed in, so the call must be looking for the deprecated template -->
  872. <xsl:call-template name="start-revision-flag-deprecated"/>
  873. </xsl:when>
  874. <xsl:when test="$biditest='bidi'">
  875. <xsl:call-template name="end-revflagit">
  876. <xsl:with-param name="flagrules" select="$flagrules"/>
  877. </xsl:call-template>
  878. </xsl:when>
  879. <xsl:otherwise>
  880. <xsl:call-template name="start-revflagit">
  881. <xsl:with-param name="flagrules" select="$flagrules"/>
  882. </xsl:call-template>
  883. </xsl:otherwise>
  884. </xsl:choose>
  885. </xsl:template>
  886. <xsl:template name="start-revflagit">
  887. <xsl:param name="flagrules">
  888. <xsl:call-template name="getrules"/>
  889. </xsl:param>
  890. <xsl:apply-templates select="$flagrules/revprop[1]" mode="start-revflagit"/>
  891. </xsl:template>
  892. <xsl:template name="end-revflagit">
  893. <xsl:param name="flagrules">
  894. <xsl:call-template name="getrules"/>
  895. </xsl:param>
  896. <xsl:apply-templates select="$flagrules/revprop[last()]" mode="end-revflagit"/>
  897. </xsl:template>
  898. <xsl:template match="revprop" mode="start-revflagit">
  899. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  900. <xsl:when test="startflag/@imageref">
  901. <xsl:variable name="imgsrc" select="startflag/@imageref"/>
  902. <img>
  903. <xsl:attribute name="src">
  904. <xsl:if test="string-length($PATH2PROJ) > 0"><xsl:value-of select="$PATH2PROJ"/></xsl:if>
  905. <!--
  906. <xsl:call-template name="get-file-name">
  907. <xsl:with-param name="file-path" select="$imgsrc"/>
  908. </xsl:call-template>
  909. -->
  910. <xsl:value-of select="$imgsrc"/>
  911. </xsl:attribute>
  912. <xsl:if test="startflag/alt-text">
  913. <xsl:attribute name="alt">
  914. <xsl:value-of select="startflag/alt-text"/>
  915. </xsl:attribute>
  916. </xsl:if>
  917. </img>
  918. </xsl:when>
  919. <xsl:when test="startflag/alt-text">
  920. <xsl:value-of select="startflag/alt-text"/>
  921. </xsl:when>
  922. <xsl:otherwise/> <!-- that flag not active -->
  923. </xsl:choose>
  924. <xsl:apply-templates select="following-sibling::revprop[1]" mode="start-revflagit"/>
  925. </xsl:template>
  926. <xsl:template match="revprop" mode="end-revflagit">
  927. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  928. <xsl:when test="endflag/@imageref">
  929. <xsl:variable name="imgsrc" select="endflag/@imageref"/>
  930. <img>
  931. <xsl:attribute name="src">
  932. <xsl:if test="string-length($PATH2PROJ) > 0"><xsl:value-of select="$PATH2PROJ"/></xsl:if>
  933. <!--
  934. <xsl:call-template name="get-file-name">
  935. <xsl:with-param name="file-path" select="$imgsrc"/>
  936. </xsl:call-template>
  937. -->
  938. <xsl:value-of select="$imgsrc"/>
  939. </xsl:attribute>
  940. <xsl:if test="endflag/alt-text">
  941. <xsl:attribute name="alt">
  942. <xsl:value-of select="endflag/alt-text"/>
  943. </xsl:attribute>
  944. </xsl:if>
  945. </img>
  946. </xsl:when>
  947. <xsl:when test="endflag/alt-text">
  948. <xsl:value-of select="endflag/alt-text"/>
  949. </xsl:when>
  950. <xsl:otherwise/> <!-- that flag not active -->
  951. </xsl:choose>
  952. <xsl:apply-templates select="preceding-sibling::revprop[1]" mode="end-revflagit"/>
  953. </xsl:template>
  954. <!-- output the ending revision graphic & ALT text -->
  955. <!-- Reverse the artwork for BIDI languages -->
  956. <xsl:template name="end-revision-flag">
  957. <xsl:param name="flagrules">
  958. <xsl:call-template name="getrules"/>
  959. </xsl:param>
  960. <xsl:variable name="biditest">
  961. <xsl:call-template name="bidi-area"/>
  962. </xsl:variable>
  963. <xsl:choose>
  964. <xsl:when test="not($flagrules)">
  965. <!-- $flagrules was not passed in, so the call must be looking for the deprecated template -->
  966. <xsl:call-template name="end-revision-flag-deprecated"/>
  967. </xsl:when>
  968. <xsl:when test="$biditest='bidi'">
  969. <xsl:call-template name="start-revflagit">
  970. <xsl:with-param name="flagrules" select="$flagrules"/>
  971. </xsl:call-template>
  972. </xsl:when>
  973. <xsl:otherwise>
  974. <xsl:call-template name="end-revflagit">
  975. <xsl:with-param name="flagrules" select="$flagrules"/>
  976. </xsl:call-template>
  977. </xsl:otherwise>
  978. </xsl:choose>
  979. </xsl:template>
  980. <!-- output the beginning revision graphic & ALT text -->
  981. <xsl:template name="start-rev-art">
  982. <xsl:param name="deltaname"/>
  983. <!-- zdihua -->
  984. <!--
  985. <img src="{$PATH2PROJ}{$deltaname}">
  986. <xsl:attribute name='alt'>
  987. <xsl:call-template name="getVariable">
  988. <xsl:with-param name="stringName" select="'Start of change'"/>
  989. </xsl:call-template>
  990. </xsl:attribute>
  991. </img>
  992. -->
  993. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  994. <xsl:when test="$deltaname">
  995. <xsl:variable name="imgsrc" select="$deltaname"/>
  996. <xsl:variable name="height">
  997. <xsl:choose>
  998. <xsl:when test="not(contains($imgsrc,'://'))">
  999. <xsl:value-of select="number(imgUtils:getHeight($OUTPUTDIR, string($imgsrc)) div 96)"/>
  1000. </xsl:when>
  1001. <xsl:otherwise/>
  1002. </xsl:choose>
  1003. </xsl:variable>
  1004. <xsl:variable name="width">
  1005. <xsl:choose>
  1006. <xsl:when test="not(contains($imgsrc,'://'))">
  1007. <xsl:value-of select="number(imgUtils:getWidth($OUTPUTDIR, string($imgsrc)) div 96)"/>
  1008. </xsl:when>
  1009. <xsl:otherwise/>
  1010. </xsl:choose>
  1011. </xsl:variable>
  1012. <xsl:call-template name="draw_image_odt">
  1013. <xsl:with-param name="height" select="$height"/>
  1014. <xsl:with-param name="width" select="$width"/>
  1015. <xsl:with-param name="imgsrc" select="$imgsrc"/>
  1016. <xsl:with-param name="alttext" select="'Start of change'"/>
  1017. </xsl:call-template>
  1018. </xsl:when>
  1019. <xsl:otherwise>
  1020. <xsl:call-template name="getVariable">
  1021. <xsl:with-param name="id" select="'Start of change'"/>
  1022. </xsl:call-template>
  1023. </xsl:otherwise>
  1024. </xsl:choose>
  1025. </xsl:template>
  1026. <!-- output the ending revision graphic & ALT text -->
  1027. <xsl:template name="end-rev-art">
  1028. <xsl:param name="deltaname"/>
  1029. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  1030. <xsl:when test="$deltaname">
  1031. <xsl:variable name="imgsrc" select="$deltaname"/>
  1032. <xsl:variable name="height">
  1033. <xsl:choose>
  1034. <xsl:when test="not(contains($imgsrc,'://'))">
  1035. <xsl:value-of select="number(imgUtils:getHeight($OUTPUTDIR, string($imgsrc)) div 96)"/>
  1036. </xsl:when>
  1037. <xsl:otherwise/>
  1038. </xsl:choose>
  1039. </xsl:variable>
  1040. <xsl:variable name="width">
  1041. <xsl:choose>
  1042. <xsl:when test="not(contains($imgsrc,'://'))">
  1043. <xsl:value-of select="number(imgUtils:getWidth($OUTPUTDIR, string($imgsrc)) div 96)"/>
  1044. </xsl:when>
  1045. <xsl:otherwise/>
  1046. </xsl:choose>
  1047. </xsl:variable>
  1048. <xsl:call-template name="draw_image_odt">
  1049. <xsl:with-param name="height" select="$height"/>
  1050. <xsl:with-param name="width" select="$width"/>
  1051. <xsl:with-param name="imgsrc" select="$imgsrc"/>
  1052. <xsl:with-param name="alttext" select="'End of change'"/>
  1053. </xsl:call-template>
  1054. </xsl:when>
  1055. <xsl:otherwise>
  1056. <xsl:call-template name="getVariable">
  1057. <xsl:with-param name="id" select="'End of change'"/>
  1058. </xsl:call-template>
  1059. </xsl:otherwise>
  1060. </xsl:choose>
  1061. </xsl:template>
  1062. <!-- Use @rev to find the first active flagged revision.
  1063. Return 1 for active.
  1064. Return 0 for non-active. -->
  1065. <xsl:template name="find-active-rev-flag">
  1066. <xsl:param name="allrevs"/>
  1067. <!-- Determine the first rev value, which is the value before the first space -->
  1068. <xsl:variable name="firstrev">
  1069. <xsl:choose>
  1070. <xsl:when test="contains($allrevs,' ')">
  1071. <xsl:value-of select="substring-before($allrevs,' ')"/>
  1072. </xsl:when>
  1073. <xsl:otherwise> <!-- no space, one value -->
  1074. <xsl:value-of select="$allrevs"/>
  1075. </xsl:otherwise>
  1076. </xsl:choose>
  1077. </xsl:variable>
  1078. <!-- Determine the other rev value, after the first space -->
  1079. <xsl:variable name="morerevs">
  1080. <xsl:choose>
  1081. <xsl:when test="contains($allrevs,' ')">
  1082. <xsl:value-of select="substring-after($allrevs,' ')"/>
  1083. </xsl:when>
  1084. <xsl:otherwise/> <!-- no space, one value -->
  1085. </xsl:choose>
  1086. </xsl:variable>
  1087. <xsl:choose>
  1088. <xsl:when test="$FILTERDOC/val/revprop[@val=$firstrev][@action='flag']">
  1089. <xsl:value-of select="1"/> <!-- rev active -->
  1090. </xsl:when>
  1091. <xsl:otherwise> <!-- rev not active -->
  1092. <!-- keep testing other values -->
  1093. <xsl:choose>
  1094. <xsl:when test="string-length($morerevs)>0">
  1095. <!-- more values - call it again with remaining values -->
  1096. <xsl:call-template name="find-active-rev-flag">
  1097. <xsl:with-param name="allrevs" select="$morerevs"/>
  1098. </xsl:call-template>
  1099. </xsl:when>
  1100. <xsl:otherwise> <!-- no more values - none found -->
  1101. <xsl:value-of select="0"/>
  1102. </xsl:otherwise>
  1103. </xsl:choose>
  1104. </xsl:otherwise>
  1105. </xsl:choose>
  1106. </xsl:template>
  1107. <!-- Use @rev to find the first active styled revision.
  1108. Return color setting when active.
  1109. Return null for non-active. -->
  1110. <xsl:template name="find-active-rev-style">
  1111. <xsl:param name="allrevs"/>
  1112. <!-- Determine the first rev value, which is the value before the first space -->
  1113. <xsl:variable name="firstrev">
  1114. <xsl:choose>
  1115. <xsl:when test="contains($allrevs,' ')">
  1116. <xsl:value-of select="substring-before($allrevs,' ')"/>
  1117. </xsl:when>
  1118. <xsl:otherwise> <!-- no space, one value -->
  1119. <xsl:value-of select="$allrevs"/>
  1120. </xsl:otherwise>
  1121. </xsl:choose>
  1122. </xsl:variable>
  1123. <!-- Determine the other rev value, after the first space -->
  1124. <xsl:variable name="morerevs">
  1125. <xsl:choose>
  1126. <xsl:when test="contains($allrevs,' ')">
  1127. <xsl:value-of select="substring-after($allrevs,' ')"/>
  1128. </xsl:when>
  1129. <xsl:otherwise/> <!-- no space, one value -->
  1130. </xsl:choose>
  1131. </xsl:variable>
  1132. <xsl:choose>
  1133. <xsl:when test="$FILTERDOC/val/revprop[@val=$firstrev]/@style">
  1134. <!-- rev active -->
  1135. <xsl:value-of select="$FILTERDOC/val/revprop[@val=$firstrev]/@style"/>
  1136. </xsl:when>
  1137. <xsl:otherwise> <!-- rev not active -->
  1138. <!-- keep testing other values -->
  1139. <xsl:choose>
  1140. <xsl:when test="string-length($morerevs)>0">
  1141. <!-- more values - call it again with remaining values -->
  1142. <xsl:call-template name="find-active-rev-style">
  1143. <xsl:with-param name="allrevs" select="$morerevs"/>
  1144. </xsl:call-template>
  1145. </xsl:when>
  1146. <xsl:otherwise/> <!-- no more values - none found -->
  1147. </xsl:choose>
  1148. </xsl:otherwise>
  1149. </xsl:choose>
  1150. </xsl:template>
  1151. <xsl:template name="conflict-check">
  1152. <xsl:param name="flagrules">
  1153. <xsl:call-template name="getrules"/>
  1154. </xsl:param>
  1155. <xsl:choose>
  1156. <xsl:when test="$flagrules/*">
  1157. <xsl:apply-templates select="$flagrules/*[1]" mode="conflict-check"/>
  1158. </xsl:when>
  1159. <xsl:otherwise>
  1160. <xsl:value-of select="'false'"/>
  1161. </xsl:otherwise>
  1162. </xsl:choose>
  1163. </xsl:template>
  1164. <xsl:template match="prop|revprop" mode="conflict-check">
  1165. <xsl:param name="color"/>
  1166. <xsl:param name="backcolor"/>
  1167. <xsl:choose>
  1168. <xsl:when test="(@color and @color!='' and $color!='' and $color!=@color)or(@backcolor and @backcolor!='' and $backcolor!='' and $backcolor!=@backcolor)">
  1169. <xsl:value-of select="'true'"/>
  1170. </xsl:when>
  1171. <xsl:when test="following-sibling::*">
  1172. <xsl:apply-templates select="following-sibling::*[1]" mode="conflict-check">
  1173. <xsl:with-param name="color" select="@color"/>
  1174. <xsl:with-param name="backcolor" select="@backcolor"/>
  1175. </xsl:apply-templates>
  1176. </xsl:when>
  1177. <xsl:otherwise>
  1178. <xsl:value-of select="'false'"/>
  1179. </xsl:otherwise>
  1180. </xsl:choose>
  1181. </xsl:template>
  1182. <!-- Currently, gen-style is never called without conflictexist in the OT
  1183. code, so the default is never used. If we replace the default with the
  1184. default code used elsewhere, then most or all calls to gen-style can be
  1185. simplified. -->
  1186. <xsl:template name="gen-style">
  1187. <xsl:param name="flagrules">
  1188. <xsl:call-template name="getrules"/>
  1189. </xsl:param>
  1190. <xsl:param name="conflictexist">
  1191. <xsl:call-template name="conflict-check">
  1192. <xsl:with-param name="flagrules" select="$flagrules"/>
  1193. </xsl:call-template>
  1194. </xsl:param>
  1195. <xsl:variable name="validstyle">
  1196. <!-- This variable is used to prevent using pre-OASIS or unrecognized ditaval styles -->
  1197. <xsl:if test="$conflictexist='false' and $flagrules/*[@style]">
  1198. <xsl:choose>
  1199. <xsl:when test="$flagrules/*/@style='italics'">YES</xsl:when>
  1200. <xsl:when test="$flagrules/*/@style='bold'">YES</xsl:when>
  1201. <xsl:when test="$flagrules/*/@style='underline'">YES</xsl:when>
  1202. <xsl:when test="$flagrules/*/@style='double-underline'">YES</xsl:when>
  1203. <xsl:when test="$flagrules/*/@style='overline'">YES</xsl:when>
  1204. </xsl:choose>
  1205. </xsl:if>
  1206. </xsl:variable>
  1207. <xsl:choose>
  1208. <xsl:when test="$conflictexist='true' and $FILTERDOC/val/style-conflict[@foreground-conflict-color or @background-conflict-color]">
  1209. <xsl:apply-templates select="." mode="ditamsg:conflict-text-style-applied"/>
  1210. <xsl:attribute name="style">
  1211. <xsl:if test="$FILTERDOC/val/style-conflict[@foreground-conflict-color]">
  1212. <xsl:text>color:</xsl:text>
  1213. <xsl:value-of select="$FILTERDOC/val/style-conflict/@foreground-conflict-color"/>
  1214. <xsl:text>;</xsl:text>
  1215. </xsl:if>
  1216. <xsl:if test="$FILTERDOC/val/style-conflict[@background-conflict-color]">
  1217. <xsl:text>background-color:</xsl:text>
  1218. <xsl:value-of select="$FILTERDOC/val/style-conflict/@background-conflict-color"/>
  1219. <xsl:text>;</xsl:text>
  1220. </xsl:if>
  1221. </xsl:attribute>
  1222. </xsl:when>
  1223. <xsl:when test="$conflictexist='false' and
  1224. ($flagrules/*[@color or @backcolor] or $validstyle='YES')">
  1225. <xsl:attribute name="style">
  1226. <xsl:if test="$flagrules/*[@color]">
  1227. <xsl:text>color:</xsl:text>
  1228. <xsl:value-of select="$flagrules/*[@color]/@color"/>
  1229. <xsl:text>;</xsl:text>
  1230. </xsl:if>
  1231. <xsl:if test="$flagrules/*[@backcolor]">
  1232. <xsl:text>background-color:</xsl:text>
  1233. <xsl:value-of select="$flagrules/*[@backcolor]/@backcolor"/>
  1234. <xsl:text>;</xsl:text>
  1235. </xsl:if>
  1236. <xsl:if test="$flagrules/*/@style='italics'">
  1237. <xsl:text>font-style:italic;</xsl:text>
  1238. </xsl:if>
  1239. <xsl:if test="$flagrules/*/@style='bold'">
  1240. <xsl:text>font-weight:bold;</xsl:text>
  1241. </xsl:if>
  1242. <xsl:if test="$flagrules/*/@style='underline' or
  1243. $flagrules/*/@style='double-underline'">
  1244. <!-- For double-underline, style="border-bottom: 3px double;" seems to work
  1245. in some cases, but not in all. For now, treat it as underline. -->
  1246. <xsl:text>text-decoration:underline;</xsl:text>
  1247. </xsl:if>
  1248. <xsl:if test="$flagrules/*/@style='overline'">
  1249. <xsl:text>text-decoration:overline;</xsl:text>
  1250. </xsl:if>
  1251. </xsl:attribute>
  1252. </xsl:when>
  1253. </xsl:choose>
  1254. </xsl:template>
  1255. <xsl:template name="start-flagit">
  1256. <xsl:param name="flagrules">
  1257. <xsl:call-template name="getrules"/>
  1258. </xsl:param>
  1259. <xsl:apply-templates select="$flagrules/prop[1]" mode="start-flagit"/>
  1260. </xsl:template>
  1261. <xsl:template match="prop" mode="start-flagit">
  1262. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  1263. <xsl:when test="startflag/@imageref">
  1264. <xsl:variable name="imgsrc" select="startflag/@imageref"/>
  1265. <xsl:variable name="height">
  1266. <xsl:choose>
  1267. <xsl:when test="not(contains($imgsrc,'://'))">
  1268. <xsl:value-of select="number(imgUtils:getHeight($OUTPUTDIR, string($imgsrc)) div 96)"/>
  1269. </xsl:when>
  1270. <xsl:otherwise/>
  1271. </xsl:choose>
  1272. </xsl:variable>
  1273. <xsl:variable name="width">
  1274. <xsl:choose>
  1275. <xsl:when test="not(contains($imgsrc,'://'))">
  1276. <xsl:value-of select="number(imgUtils:getWidth($OUTPUTDIR, string($imgsrc)) div 96)"/>
  1277. </xsl:when>
  1278. <xsl:otherwise/>
  1279. </xsl:choose>
  1280. </xsl:variable>
  1281. <xsl:call-template name="draw_image_odt">
  1282. <xsl:with-param name="height" select="$height"/>
  1283. <xsl:with-param name="width" select="$width"/>
  1284. <xsl:with-param name="imgsrc" select="$imgsrc"/>
  1285. <xsl:with-param name="alttext" select="startflag/alt-text"/>
  1286. </xsl:call-template>
  1287. </xsl:when>
  1288. <xsl:when test="startflag/alt-text">
  1289. <xsl:value-of select="startflag/alt-text"/>
  1290. </xsl:when>
  1291. <xsl:otherwise/> <!-- that flag not active -->
  1292. </xsl:choose>
  1293. <xsl:apply-templates select="following-sibling::prop[1]" mode="start-flagit"/>
  1294. </xsl:template>
  1295. <xsl:template name="end-flagit">
  1296. <xsl:param name="flagrules">
  1297. <xsl:call-template name="getrules"/>
  1298. </xsl:param>
  1299. <xsl:apply-templates select="$flagrules/prop[last()]" mode="end-flagit"/>
  1300. </xsl:template>
  1301. <xsl:template match="prop" mode="end-flagit">
  1302. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  1303. <xsl:when test="endflag/@imageref">
  1304. <xsl:variable name="imgsrc" select="endflag/@imageref"/>
  1305. <xsl:variable name="height">
  1306. <xsl:choose>
  1307. <xsl:when test="not(contains($imgsrc,'://'))">
  1308. <xsl:value-of select="number(imgUtils:getHeight($OUTPUTDIR, string($imgsrc)) div 96)"/>
  1309. </xsl:when>
  1310. <xsl:otherwise/>
  1311. </xsl:choose>
  1312. </xsl:variable>
  1313. <xsl:variable name="width">
  1314. <xsl:choose>
  1315. <xsl:when test="not(contains($imgsrc,'://'))">
  1316. <xsl:value-of select="number(imgUtils:getWidth($OUTPUTDIR, string($imgsrc)) div 96)"/>
  1317. </xsl:when>
  1318. <xsl:otherwise/>
  1319. </xsl:choose>
  1320. </xsl:variable>
  1321. <xsl:call-template name="draw_image_odt">
  1322. <xsl:with-param name="height" select="$height"/>
  1323. <xsl:with-param name="width" select="$width"/>
  1324. <xsl:with-param name="imgsrc" select="$imgsrc"/>
  1325. <xsl:with-param name="alttext" select="endflag/alt-text"/>
  1326. </xsl:call-template>
  1327. </xsl:when>
  1328. <xsl:when test="endflag/alt-text">
  1329. <xsl:value-of select="endflag/alt-text"/>
  1330. </xsl:when>
  1331. <!-- not necessary to add logic for @img. original ditaval does not support end flag. -->
  1332. <xsl:otherwise/> <!-- that flag not active -->
  1333. </xsl:choose>
  1334. <xsl:apply-templates select="preceding-sibling::prop[1]" mode="end-flagit"/>
  1335. </xsl:template>
  1336. <xsl:template match="*" mode="ditamsg:cannot-flag-inline-element">
  1337. <xsl:param name="attr-name"/>
  1338. <xsl:call-template name="output-message">
  1339. <xsl:with-param name="id" select="'DOTX042W'"/>
  1340. <xsl:with-param name="msgparams">%i=<xsl:value-of select="$attr-name"/></xsl:with-param>
  1341. </xsl:call-template>
  1342. </xsl:template>
  1343. <xsl:template match="*" mode="ditamsg:conflict-text-style-applied">
  1344. <xsl:call-template name="output-message">
  1345. <xsl:with-param name="id" select="'DOTX054W'"/>
  1346. </xsl:call-template>
  1347. </xsl:template>
  1348. <!-- ===================================================================== -->
  1349. </xsl:stylesheet>