flagImpl.xsl 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  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, 2012 -->
  5. <!-- PURPOSE: Replace the XHTML based flagging routines with a common routine.
  6. Logic for determining what to flag is the same.
  7. When flags are active:
  8. * Create element <ditaval-startprop> as the first child, and <ditaval-endprop> as the last.
  9. These are each pseudo-specializations of <foreign>, with class values
  10. "+ topic/foreign ditaot-d/ditaval-startprop "
  11. and
  12. "+ topic/foreign ditaot-d/ditaval-endprop "
  13. * Properties / revisions that are set to "flag" in the ditaval are copied as-is into each
  14. element, so that rendering steps can directly access all active flags and revisions.
  15. * Relative paths for flagging images are adjusted to be valid from the current topic
  16. * If styling is active, only one style can be set per element; the CSS style is calculated
  17. in this step and placed on @outputclass of <ditaval-startprop>.
  18. * If there is a style conflict, and the file has <style-conflict>, then a copy of
  19. <style-conflict> is included in <ditaval-startprop>.
  20. LOOK FOR FIXME TO FIX SCHEMEDEF STUFF
  21. -->
  22. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  23. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  24. version="2.0"
  25. xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
  26. exclude-result-prefixes="xs ditamsg">
  27. <!-- ========== Flagging with flags & revisions ========== -->
  28. <xsl:import href="plugin:org.dita.base:xsl/common/output-message.xsl"/>
  29. <xsl:import href="plugin:org.dita.base:xsl/common/dita-utilities.xsl"/>
  30. <xsl:output method="xml"
  31. encoding="utf-8"
  32. indent="no"
  33. byte-order-mark="no"
  34. />
  35. <xsl:param name="DBG" select="'no'"/>
  36. <xsl:param name="DRAFT" select="'no'"/>
  37. <xsl:param name="FILTERFILEURL"/>
  38. <xsl:param name="PATH2PROJ">
  39. <xsl:apply-templates select="/processing-instruction('path2project-uri')[1]" mode="get-path2project"/>
  40. </xsl:param>
  41. <xsl:param name="WORKDIR">
  42. <xsl:apply-templates select="/processing-instruction('workdir-uri')[1]" mode="get-work-dir"/>
  43. </xsl:param>
  44. <xsl:param name="FILENAME"/>
  45. <xsl:param name="FILEDIR"/>
  46. <xsl:param name="CURRENTFILE" select="concat($FILEDIR, '/', $FILENAME)"/>
  47. <!-- Deprecated since 2.3 -->
  48. <xsl:variable name="msgprefix">DOTX</xsl:variable>
  49. <xsl:variable name="FILTERDOC" select="document($FILTERFILEURL,/)" as="document-node()"/>
  50. <xsl:variable name="GLOBAL-DOMAINS">
  51. <xsl:choose>
  52. <xsl:when test="/dita">
  53. <xsl:value-of select="normalize-space(/dita/*[1]/@domains)"/>
  54. </xsl:when>
  55. <xsl:otherwise>
  56. <xsl:value-of select="normalize-space(/*[1]/@domains)"/>
  57. </xsl:otherwise>
  58. </xsl:choose>
  59. </xsl:variable>
  60. <!-- Specialized attributes for analysis by flagging templates. Format is:
  61. props attr1,props attr2,props attr3 -->
  62. <xsl:variable name="propsExtensions" as="xs:string">
  63. <xsl:variable name="collectPropsExtensions">
  64. <xsl:call-template name="getExtProps">
  65. <xsl:with-param name="domains" select="$GLOBAL-DOMAINS"/>
  66. </xsl:call-template>
  67. </xsl:variable>
  68. <xsl:value-of select="substring-after($collectPropsExtensions, ',')"/>
  69. </xsl:variable>
  70. <xsl:template match="/">
  71. <!-- Avoid all later checks by adding test here - if no filter file, copy full tree? -->
  72. <xsl:apply-templates/>
  73. </xsl:template>
  74. <xsl:template match="*">
  75. <xsl:param name="flagrules" as="element()*">
  76. <xsl:call-template name="getrules"/>
  77. </xsl:param>
  78. <xsl:choose>
  79. <xsl:when test="exists($flagrules/*)">
  80. <xsl:variable name="conflictexist">
  81. <xsl:call-template name="conflict-check">
  82. <xsl:with-param name="flagrules" select="$flagrules"/>
  83. </xsl:call-template>
  84. </xsl:variable>
  85. <xsl:copy>
  86. <xsl:apply-templates select="@*"/>
  87. <ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop ">
  88. <xsl:apply-templates select="." mode="gen-style">
  89. <xsl:with-param name="flagrules" select="$flagrules"/>
  90. <xsl:with-param name="conflictexist" select="$conflictexist"/>
  91. </xsl:apply-templates>
  92. <xsl:if test="$conflictexist='true' and $FILTERDOC/val/style-conflict">
  93. <xsl:copy-of select="$FILTERDOC/val/style-conflict"/>
  94. </xsl:if>
  95. <xsl:apply-templates select="." mode="dita-start-flagit">
  96. <xsl:with-param name="flagrules" select="$flagrules"/>
  97. </xsl:apply-templates>
  98. <xsl:apply-templates select="." mode="dita-start-revflag">
  99. <xsl:with-param name="flagrules" select="$flagrules"/>
  100. </xsl:apply-templates>
  101. </ditaval-startprop>
  102. <xsl:apply-templates select="*|processing-instruction()|comment()|text()"/>
  103. <ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop ">
  104. <xsl:apply-templates select="." mode="dita-end-revflag">
  105. <xsl:with-param name="flagrules" select="$flagrules"/>
  106. </xsl:apply-templates>
  107. <xsl:apply-templates select="." mode="dita-end-flagit">
  108. <xsl:with-param name="flagrules" select="$flagrules"/>
  109. </xsl:apply-templates>
  110. </ditaval-endprop>
  111. </xsl:copy>
  112. </xsl:when>
  113. <xsl:otherwise>
  114. <xsl:copy>
  115. <xsl:apply-templates select="@*|*|processing-instruction()|comment()|text()"/>
  116. </xsl:copy>
  117. </xsl:otherwise>
  118. </xsl:choose>
  119. </xsl:template>
  120. <xsl:template match="@*|processing-instruction()|comment()|text()">
  121. <xsl:copy>
  122. <xsl:apply-templates select="@*"/>
  123. <xsl:apply-templates select="*|processing-instruction()|comment()|text()"/>
  124. </xsl:copy>
  125. </xsl:template>
  126. <xsl:template match="*" mode="dita-start-flagit">
  127. <xsl:param name="flagrules" as="element()*">
  128. <xsl:call-template name="getrules"/>
  129. </xsl:param>
  130. <xsl:apply-templates select="$flagrules/prop[1]" mode="start-flagit"/>
  131. </xsl:template>
  132. <xsl:template match="prop" mode="start-flagit">
  133. <xsl:copy>
  134. <xsl:copy-of select="@*"/>
  135. <xsl:if test="startflag">
  136. <startflag>
  137. <xsl:copy-of select="startflag/@*"/>
  138. <xsl:apply-templates select="startflag/@imageref" mode="adjust-imageref"/>
  139. <xsl:copy-of select="startflag/*"/>
  140. </startflag>
  141. </xsl:if>
  142. </xsl:copy>
  143. <xsl:apply-templates select="following-sibling::prop[1]" mode="start-flagit"/>
  144. </xsl:template>
  145. <xsl:template match="*" mode="dita-end-flagit">
  146. <xsl:param name="flagrules" as="element()*">
  147. <xsl:call-template name="getrules"/>
  148. </xsl:param>
  149. <xsl:apply-templates select="$flagrules/prop[last()]" mode="end-flagit"/>
  150. </xsl:template>
  151. <xsl:template match="prop" mode="end-flagit">
  152. <xsl:copy>
  153. <xsl:copy-of select="@*"/>
  154. <xsl:if test="endflag">
  155. <endflag>
  156. <xsl:copy-of select="endflag/@*"/>
  157. <xsl:apply-templates select="endflag/@imageref" mode="adjust-imageref"/>
  158. <xsl:copy-of select="endflag/*"/>
  159. </endflag>
  160. </xsl:if>
  161. </xsl:copy>
  162. <xsl:apply-templates select="preceding-sibling::prop[1]" mode="end-flagit"/>
  163. </xsl:template>
  164. <!-- Output starting flag only -->
  165. <xsl:template match="*" mode="dita-start-revflag">
  166. <xsl:param name="flagrules" as="element()*">
  167. <xsl:call-template name="getrules"/>
  168. </xsl:param>
  169. <xsl:if test="@rev and not($FILTERFILEURL='')">
  170. <xsl:call-template name="start-mark-rev">
  171. <xsl:with-param name="revvalue" select="@rev"/>
  172. <xsl:with-param name="flagrules" select="$flagrules"/>
  173. </xsl:call-template>
  174. </xsl:if>
  175. </xsl:template>
  176. <!-- Output ending flag only -->
  177. <xsl:template match="*" mode="dita-end-revflag">
  178. <xsl:param name="flagrules" as="element()*">
  179. <xsl:call-template name="getrules"/>
  180. </xsl:param>
  181. <xsl:if test="@rev and not($FILTERFILEURL='')">
  182. <xsl:call-template name="end-mark-rev">
  183. <xsl:with-param name="revvalue" select="@rev"/>
  184. <xsl:with-param name="flagrules" select="$flagrules"/>
  185. </xsl:call-template>
  186. </xsl:if>
  187. </xsl:template>
  188. <!-- This revision is active for this element -->
  189. <xsl:template match="revprop" mode="start-revflagit">
  190. <xsl:param name="lang"/>
  191. <xsl:param name="biditest"/>
  192. <xsl:copy>
  193. <xsl:copy-of select="@*"/>
  194. <xsl:choose>
  195. <xsl:when test="startflag">
  196. <startflag>
  197. <xsl:copy-of select="startflag/@*"/>
  198. <xsl:apply-templates select="startflag/@imageref" mode="adjust-imageref"/>
  199. <xsl:copy-of select="startflag/*"/>
  200. </startflag>
  201. </xsl:when>
  202. <xsl:otherwise>
  203. <!-- Create default start revision reference? -->
  204. <xsl:call-template name="default-rev-start">
  205. <!--
  206. <xsl:with-param name="lang" select="$lang"/>
  207. <xsl:with-param name="biditest" select="$biditest"/>
  208. -->
  209. </xsl:call-template>
  210. </xsl:otherwise>
  211. </xsl:choose>
  212. </xsl:copy>
  213. <xsl:apply-templates select="following-sibling::revprop[1]" mode="start-revflagit">
  214. <xsl:with-param name="lang" select="$lang"/>
  215. <xsl:with-param name="biditest" select="$biditest"/>
  216. </xsl:apply-templates>
  217. </xsl:template>
  218. <xsl:template match="revprop" mode="end-revflagit">
  219. <xsl:param name="lang"/>
  220. <xsl:param name="biditest"/>
  221. <xsl:copy>
  222. <xsl:copy-of select="@*"/>
  223. <xsl:choose>
  224. <xsl:when test="endflag">
  225. <endflag>
  226. <xsl:copy-of select="endflag/@*"/>
  227. <xsl:apply-templates select="endflag/@imageref" mode="adjust-imageref"/>
  228. <xsl:copy-of select="endflag/*"/>
  229. </endflag>
  230. </xsl:when>
  231. <xsl:otherwise>
  232. <!-- Create default end revision reference? -->
  233. <xsl:call-template name="default-rev-end">
  234. <!--
  235. <xsl:with-param name="lang" select="$lang"/>
  236. <xsl:with-param name="biditest" select="$biditest"/>
  237. -->
  238. </xsl:call-template>
  239. </xsl:otherwise>
  240. </xsl:choose>
  241. </xsl:copy>
  242. <xsl:apply-templates select="preceding-sibling::revprop[1]" mode="end-revflagit">
  243. <xsl:with-param name="lang" select="$lang"/>
  244. <xsl:with-param name="biditest" select="$biditest"/>
  245. </xsl:apply-templates>
  246. </xsl:template>
  247. <!-- output the DEFAULT beginning revision graphic & ALT text.
  248. Commented out section shows how to insert a default start flag of "delta.gif"
  249. by creating the proper ditaval syntax -->
  250. <xsl:template name="default-rev-start">
  251. <xsl:param name="lang"/>
  252. <xsl:param name="biditest"/>
  253. <!--
  254. <xsl:param name="startRevImage">
  255. <xsl:choose>
  256. <xsl:when test="$biditest='bidi'">deltaend.gif</xsl:when>
  257. <xsl:otherwise>delta.gif</xsl:otherwise>
  258. </xsl:choose>
  259. </xsl:param>
  260. <startflag imageref="{$PATH2PROJ}{$startRevImage}">
  261. <alt-text>
  262. <xsl:call-template name="getVariable">
  263. <xsl:with-param name="id" select="'Start of change'"/>
  264. </xsl:call-template>
  265. </alt-text>
  266. </startflag>-->
  267. </xsl:template>
  268. <!-- output the DEFAULT ending revision graphic & ALT text -->
  269. <xsl:template name="default-rev-end">
  270. <xsl:param name="lang"/>
  271. <xsl:param name="biditest"/>
  272. <!--
  273. <xsl:param name="endRevImage">
  274. <xsl:choose>
  275. <xsl:when test="$biditest='bidi'">delta.gif</xsl:when>
  276. <xsl:otherwise>deltaend.gif</xsl:otherwise>
  277. </xsl:choose>
  278. </xsl:param>
  279. <endflag imageref="{$PATH2PROJ}{$endRevImage}">
  280. <alt-text>
  281. <xsl:call-template name="getVariable">
  282. <xsl:with-param name="id" select="'End of change'"/>
  283. </xsl:call-template>
  284. </alt-text>
  285. </endflag>-->
  286. </xsl:template>
  287. <xsl:template match="@imageref" mode="adjust-imageref">
  288. <xsl:if test="string-length($PATH2PROJ) > 0 and
  289. not(contains(.,'://'))">
  290. <xsl:attribute name="imageref">
  291. <xsl:value-of select="$PATH2PROJ"/>
  292. <xsl:value-of select="."/>
  293. </xsl:attribute>
  294. </xsl:if>
  295. </xsl:template>
  296. <!-- ========== COPIED FROM XHTML CODE ========== -->
  297. <!-- Test for in BIDI area: returns "bidi" when parent's @xml:lang is a bidi language; otherwise, leave blank -->
  298. <xsl:template name="bidi-area" as="xs:string?">
  299. <xsl:param name="parentlang" as="xs:string">
  300. <xsl:call-template name="getLowerCaseLang"/>
  301. </xsl:param>
  302. <xsl:variable name="direction" as="xs:string">
  303. <xsl:apply-templates select="." mode="get-render-direction">
  304. <xsl:with-param name="lang" select="$parentlang"/>
  305. </xsl:apply-templates>
  306. </xsl:variable>
  307. <xsl:value-of select="if ($direction = 'rtl') then 'bidi' else ()"/>
  308. </xsl:template>
  309. <!-- Flags - based on audience, product, platform, and otherprops in the source
  310. AND prop elements in the val file:
  311. Flag the text with the artwork from the val file & insert the ALT text from the val file.
  312. For multiple attr values, output each flag in turn.
  313. -->
  314. <xsl:template name="getrules" as="element()*">
  315. <xsl:param name="current" select="." as="element()"/>
  316. <val>
  317. <!-- Test for the flagging attributes. If found, call 'gen-prop' with the values to use. Otherwise return -->
  318. <xsl:if test="normalize-space($FILTERFILEURL)!=''">
  319. <xsl:if test="$current/@audience">
  320. <xsl:call-template name="gen-prop">
  321. <xsl:with-param name="flag-att" select="'audience'"/>
  322. <xsl:with-param name="flag-att-val" select="$current/@audience"/>
  323. </xsl:call-template>
  324. </xsl:if>
  325. <xsl:if test="$current/@platform">
  326. <xsl:call-template name="gen-prop">
  327. <xsl:with-param name="flag-att" select="'platform'"/>
  328. <xsl:with-param name="flag-att-val" select="$current/@platform"/>
  329. </xsl:call-template>
  330. </xsl:if>
  331. <xsl:if test="$current/@product">
  332. <xsl:call-template name="gen-prop">
  333. <xsl:with-param name="flag-att" select="'product'"/>
  334. <xsl:with-param name="flag-att-val" select="$current/@product"/>
  335. </xsl:call-template>
  336. </xsl:if>
  337. <xsl:if test="$current/@otherprops">
  338. <xsl:call-template name="gen-prop">
  339. <xsl:with-param name="flag-att" select="'otherprops'"/>
  340. <xsl:with-param name="flag-att-val" select="$current/@otherprops"/>
  341. </xsl:call-template>
  342. </xsl:if>
  343. <xsl:if test="$current/@rev">
  344. <xsl:call-template name="gen-prop">
  345. <xsl:with-param name="flag-att" select="'rev'"/>
  346. <xsl:with-param name="flag-att-val" select="$current/@rev"/>
  347. </xsl:call-template>
  348. </xsl:if>
  349. <xsl:if test="$propsExtensions != ''">
  350. <xsl:call-template name="ext-getrules">
  351. <xsl:with-param name="props" select="$propsExtensions"/>
  352. <xsl:with-param name="current" select="$current"/>
  353. </xsl:call-template>
  354. </xsl:if>
  355. <!-- default flags -->
  356. <xsl:if test="$current/@audience">
  357. <xsl:copy-of select="$FILTERDOC/val/prop[@att='audience' and empty(@val) and @action = 'flag']"/>
  358. </xsl:if>
  359. <xsl:if test="$current/@platform">
  360. <xsl:copy-of select="$FILTERDOC/val/prop[@att='platform' and empty(@val) and @action = 'flag']"/>
  361. </xsl:if>
  362. <xsl:if test="$current/@product">
  363. <xsl:copy-of select="$FILTERDOC/val/prop[@att='product' and empty(@val) and @action = 'flag']"/>
  364. </xsl:if>
  365. <xsl:if test="$current/@otherprops">
  366. <xsl:copy-of select="$FILTERDOC/val/prop[@att='otherprops' and empty(@val) and @action = 'flag']"/>
  367. </xsl:if>
  368. <xsl:if test="$current/@audience | $current/@platform | $current/@product | $current/@otherprops">
  369. <xsl:copy-of select="$FILTERDOC/val/prop[empty(@att) and empty(@val) and @action = 'flag']"/>
  370. </xsl:if>
  371. <xsl:if test="$current/@rev">
  372. <xsl:copy-of select="$FILTERDOC/val/revprop[empty(@val) and @action = 'flag']"/>
  373. </xsl:if>
  374. </xsl:if>
  375. </val>
  376. </xsl:template>
  377. <xsl:template name="getExtProps" as="xs:string*">
  378. <xsl:param name="domains" as="xs:string"/>
  379. <xsl:if test="contains($domains, 'a(props')">
  380. <xsl:text>,</xsl:text>
  381. <xsl:value-of select="normalize-space(concat('props',substring-before(substring-after($domains,'a(props'), ')')))"/>
  382. <xsl:call-template name="getExtProps">
  383. <xsl:with-param name="domains" select="substring-after(substring-after($domains,'a(props'), ')')"/>
  384. </xsl:call-template>
  385. </xsl:if>
  386. </xsl:template>
  387. <xsl:template name="ext-getrules" as="element()*">
  388. <xsl:param name="props" as="xs:string?"/>
  389. <xsl:param name="current" as="element()"/>
  390. <xsl:if test="normalize-space($props)">
  391. <xsl:variable name="head" select="if (contains($props, ',')) then substring-before($props,',') else $props" as="xs:string"/>
  392. <xsl:variable name="tail" select="if (contains($props, ',')) then substring-after($props,',') else ()" as="xs:string?"/>
  393. <xsl:variable name="propsValue" as="xs:string?">
  394. <xsl:call-template name="getPropsValue">
  395. <xsl:with-param name="propsPath" select="$head"/>
  396. <xsl:with-param name="current" select="$current"/>
  397. </xsl:call-template>
  398. </xsl:variable>
  399. <xsl:if test="not($propsValue='')">
  400. <xsl:call-template name="ext-gen-prop">
  401. <xsl:with-param name="flag-att-path" select="$head"/>
  402. <xsl:with-param name="flag-att-val" select="$propsValue"/>
  403. </xsl:call-template>
  404. </xsl:if>
  405. <xsl:call-template name="ext-getrules">
  406. <xsl:with-param name="props" select="$tail"/>
  407. <xsl:with-param name="current" select="$current"/>
  408. </xsl:call-template>
  409. </xsl:if>
  410. </xsl:template>
  411. <xsl:template name="getPropsValue" as="xs:string?">
  412. <xsl:param name="propsPath" as="xs:string"/>
  413. <xsl:param name="current" as="element()"/>
  414. <xsl:variable name="propName" as="xs:string">
  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="$current/@*[name() = $propName]">
  421. <xsl:value-of select="$current/@*[name() = $propName]"/>
  422. </xsl:when>
  423. <xsl:otherwise>
  424. <xsl:call-template name="getGeneralValue">
  425. <xsl:with-param name="propName" select="$propName"/>
  426. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propName))"/>
  427. <xsl:with-param name="current" select="$current"/>
  428. </xsl:call-template>
  429. </xsl:otherwise>
  430. </xsl:choose>
  431. </xsl:template>
  432. <xsl:template name="getGeneralValue" as="xs:string?">
  433. <xsl:param name="propsPath" as="xs:string"/>
  434. <xsl:param name="propName" as="xs:string"/>
  435. <xsl:param name="current" as="element()"/>
  436. <xsl:variable name="propParentName" as="xs:string">
  437. <xsl:call-template name="getLastPropName">
  438. <xsl:with-param name="propsPath" select="$propsPath"/>
  439. </xsl:call-template>
  440. </xsl:variable>
  441. <xsl:choose>
  442. <xsl:when test="contains($current/@*[name() = $propParentName], concat($propName,'('))">
  443. <xsl:value-of select="substring-before(substring-after($current/@*[name() = $propParentName], concat($propName,'(')),')')"/>
  444. </xsl:when>
  445. <xsl:when test="contains($propsPath,' ')">
  446. <xsl:call-template name="getGeneralValue">
  447. <xsl:with-param name="propName" select="$propName"/>
  448. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propParentName))"/>
  449. <xsl:with-param name="current" select="$current"/>
  450. </xsl:call-template>
  451. </xsl:when>
  452. </xsl:choose>
  453. </xsl:template>
  454. <xsl:template name="getLastPropName" as="xs:string">
  455. <xsl:param name="propsPath" as="xs:string"/>
  456. <xsl:choose>
  457. <xsl:when test="contains($propsPath,' ')">
  458. <xsl:call-template name="getLastPropName">
  459. <xsl:with-param name="propsPath" select="substring-after($propsPath,' ')"/>
  460. </xsl:call-template>
  461. </xsl:when>
  462. <xsl:otherwise>
  463. <xsl:value-of select="$propsPath"/>
  464. </xsl:otherwise>
  465. </xsl:choose>
  466. </xsl:template>
  467. <xsl:template name="ext-flagcheck">
  468. <xsl:param name="props"/>
  469. <xsl:choose>
  470. <xsl:when test="contains($props,',')">
  471. <xsl:variable name="propsValue" as="xs:string?">
  472. <xsl:call-template name="getPropsValue">
  473. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  474. </xsl:call-template>
  475. </xsl:variable>
  476. <xsl:variable name="propName" as="xs:string">
  477. <xsl:call-template name="getLastPropName">
  478. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  479. </xsl:call-template>
  480. </xsl:variable>
  481. <xsl:if test="not($propsValue='')">
  482. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  483. <xsl:with-param name="attr-name" select="$propName"/>
  484. </xsl:apply-templates>
  485. </xsl:if>
  486. <xsl:call-template name="ext-flagcheck">
  487. <xsl:with-param name="props" select="substring-after($props,',')"/>
  488. </xsl:call-template>
  489. </xsl:when>
  490. <xsl:otherwise>
  491. <xsl:variable name="propsValue" as="xs:string?">
  492. <xsl:call-template name="getPropsValue">
  493. <xsl:with-param name="propsPath" select="$props"/>
  494. </xsl:call-template>
  495. </xsl:variable>
  496. <xsl:variable name="propName" as="xs:string">
  497. <xsl:call-template name="getLastPropName">
  498. <xsl:with-param name="propsPath" select="$props"/>
  499. </xsl:call-template>
  500. </xsl:variable>
  501. <xsl:if test="not($propsValue='')">
  502. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  503. <xsl:with-param name="attr-name" select="$propName"/>
  504. </xsl:apply-templates>
  505. </xsl:if>
  506. </xsl:otherwise>
  507. </xsl:choose>
  508. </xsl:template>
  509. <!-- Use passed attr value to mark each active flag. -->
  510. <xsl:template name="ext-gen-prop">
  511. <xsl:param name="flag-att-path"/>
  512. <xsl:param name="flag-att-val"/>
  513. <xsl:variable name="propName" as="xs:string">
  514. <xsl:call-template name="getLastPropName">
  515. <xsl:with-param name="propsPath" select="$flag-att-path"/>
  516. </xsl:call-template>
  517. </xsl:variable>
  518. <xsl:variable name="flag-result">
  519. <xsl:call-template name="gen-prop">
  520. <xsl:with-param name="flag-att" select="$propName"/>
  521. <xsl:with-param name="flag-att-val" select="$flag-att-val"/>
  522. </xsl:call-template>
  523. </xsl:variable>
  524. <xsl:choose>
  525. <xsl:when test="$flag-result/prop">
  526. <xsl:copy-of select="$flag-result"/>
  527. </xsl:when>
  528. <xsl:otherwise>
  529. <xsl:if test="contains($flag-att-path,' ')">
  530. <xsl:call-template name="ext-gen-prop">
  531. <xsl:with-param name="flag-att-path" select="normalize-space(substring-before($flag-att-path, $propName))"/>
  532. <xsl:with-param name="flag-att-val" select="$flag-att-val"/>
  533. </xsl:call-template>
  534. </xsl:if>
  535. </xsl:otherwise>
  536. </xsl:choose>
  537. </xsl:template>
  538. <xsl:template name="gen-prop" as="element()*">
  539. <xsl:param name="flag-att" as="xs:string"/> <!-- attribute name -->
  540. <xsl:param name="flag-att-val" as="xs:string?"/> <!-- content of attribute -->
  541. <!-- Determine the first flag value, which is the value before the first space -->
  542. <xsl:variable name="firstflag" as="xs:string">
  543. <xsl:choose>
  544. <xsl:when test="contains($flag-att-val,' ')">
  545. <xsl:value-of select="substring-before($flag-att-val,' ')"/>
  546. </xsl:when>
  547. <xsl:otherwise> <!-- no space, one value -->
  548. <xsl:value-of select="$flag-att-val"/>
  549. </xsl:otherwise>
  550. </xsl:choose>
  551. </xsl:variable>
  552. <!-- Determine the other flag values, after the first space -->
  553. <xsl:variable name="moreflags" as="xs:string">
  554. <xsl:choose>
  555. <xsl:when test="contains($flag-att-val,' ')">
  556. <xsl:value-of select="substring-after($flag-att-val,' ')"/>
  557. </xsl:when>
  558. <xsl:otherwise>
  559. <xsl:value-of select="''"/>
  560. </xsl:otherwise> <!-- no space, one value -->
  561. </xsl:choose>
  562. </xsl:variable>
  563. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  564. <xsl:when test="$flag-att='rev' and $FILTERDOC/val/revprop[@val=$firstflag][1][@action='flag']">
  565. <xsl:copy-of select="$FILTERDOC/val/revprop[@val=$firstflag][1][@action='flag']"/>
  566. </xsl:when>
  567. <xsl:when test="$FILTERDOC/val/prop[@att=$flag-att][@val=$firstflag][1][@action='flag']">
  568. <xsl:copy-of select="$FILTERDOC/val/prop[@att=$flag-att][@val=$firstflag][1][@action='flag']"/>
  569. </xsl:when>
  570. <xsl:when test="$FILTERDOC/val/prop[@att=$flag-att][not(@val=$firstflag)][@action='flag']">
  571. <xsl:for-each select="$FILTERDOC/val/prop[@att=$flag-att][not(@val=$firstflag)][@action='flag']">
  572. <!-- get the val -->
  573. <xsl:variable name="val">
  574. <xsl:apply-templates select="." mode="getVal"/>
  575. </xsl:variable>
  576. <!-- get the backcolor -->
  577. <xsl:variable name="backcolor">
  578. <xsl:apply-templates select="." mode="getBgcolor"/>
  579. </xsl:variable>
  580. <!-- get the color -->
  581. <xsl:variable name="color">
  582. <xsl:apply-templates select="." mode="getColor"/>
  583. </xsl:variable>
  584. <!-- get the style -->
  585. <xsl:variable name="style">
  586. <xsl:apply-templates select="." mode="getStyle"/>
  587. </xsl:variable>
  588. <!-- get child node -->
  589. <xsl:variable name="childnode">
  590. <xsl:apply-templates select="." mode="getChildNode"/>
  591. </xsl:variable>
  592. <!-- get the location of schemekeydef.xml -->
  593. <xsl:variable name="KEYDEF-FILE" select="concat($WORKDIR,$PATH2PROJ,'schemekeydef.xml')"/>
  594. <!--keydef.xml contains the val -->
  595. <xsl:if test="(document($KEYDEF-FILE, /)//*[@keys=$val])">
  596. <!-- copy needed elements -->
  597. <xsl:apply-templates select="(document($KEYDEF-FILE, /)//*[@keys=$val])" mode="copy-element">
  598. <xsl:with-param name="att" select="$flag-att"/>
  599. <xsl:with-param name="bgcolor" select="$backcolor"/>
  600. <xsl:with-param name="fcolor" select="$color"/>
  601. <xsl:with-param name="style" select="$style"/>
  602. <xsl:with-param name="value" select="$val"/>
  603. <xsl:with-param name="flag" select="$firstflag"/>
  604. <xsl:with-param name="childnodes" select="$childnode"/>
  605. </xsl:apply-templates>
  606. </xsl:if>
  607. </xsl:for-each>
  608. </xsl:when>
  609. <xsl:otherwise/> <!-- that flag not active -->
  610. </xsl:choose>
  611. <!-- keep testing other values -->
  612. <xsl:choose>
  613. <xsl:when test="string-length($moreflags)>0">
  614. <!-- more values - call it again with remaining values -->
  615. <xsl:call-template name="gen-prop">
  616. <xsl:with-param name="flag-att" select="$flag-att"/>
  617. <xsl:with-param name="flag-att-val" select="$moreflags"/>
  618. </xsl:call-template>
  619. </xsl:when>
  620. <xsl:otherwise/> <!-- no more values -->
  621. </xsl:choose>
  622. </xsl:template>
  623. <!-- copy needed elements -->
  624. <xsl:template match="*" mode="copy-element">
  625. <xsl:param name="att"/>
  626. <xsl:param name="bgcolor"/>
  627. <xsl:param name="fcolor"/>
  628. <xsl:param name="style"/>
  629. <xsl:param name="value"/>
  630. <xsl:param name="flag"/>
  631. <xsl:param name="cvffilename" select="@source"/>
  632. <xsl:param name="childnodes"/>
  633. <!--get the location of subject_scheme.dictionary-->
  634. <xsl:variable name="INITIAL-PROPERTIES-FILE" select="concat($WORKDIR , $PATH2PROJ , 'subject_scheme.dictionary')"/>
  635. <xsl:variable name="PROPERTIES-FILE" select="$INITIAL-PROPERTIES-FILE"/>
  636. <!-- get the scheme list -->
  637. <!-- check CURRENT File -->
  638. <xsl:variable name="editedFileName">
  639. <xsl:call-template name="checkFile">
  640. <xsl:with-param name="in" select="$CURRENTFILE"/>
  641. </xsl:call-template>
  642. </xsl:variable>
  643. <xsl:variable name="schemeList">
  644. <xsl:apply-templates select="document($PROPERTIES-FILE,/)//*[@key=$editedFileName]" mode="check"/>
  645. </xsl:variable>
  646. <!-- scheme list contains the scheme file -->
  647. <xsl:if test="contains($schemeList, $cvffilename)">
  648. <!-- get the path of scheme file -->
  649. <xsl:variable name="submfile">
  650. <xsl:value-of select="$cvffilename"/><xsl:text>.subm</xsl:text>
  651. </xsl:variable>
  652. <xsl:variable name="cvffilepath">
  653. <xsl:value-of select="concat($WORKDIR,$PATH2PROJ,$submfile)"/>
  654. </xsl:variable>
  655. <xsl:if test="document($cvffilepath,/)//*[@keys=$value]//*[@keys=$flag]">
  656. <!-- copy the child node for flag and just copy the first element whose keys=$flag-->
  657. <!--xsl:for-each select="document($cvffilepath,/)//*[@keys=$value]/*"-->
  658. <xsl:for-each select="document($cvffilepath,/)//*[@keys=$value]//*[@keys=$flag][1]">
  659. <xsl:element name="prop">
  660. <xsl:attribute name="att">
  661. <xsl:value-of select="$att"/>
  662. </xsl:attribute>
  663. <xsl:attribute name="val">
  664. <xsl:value-of select="@keys"/>
  665. </xsl:attribute>
  666. <xsl:attribute name="action">
  667. <xsl:value-of select="'flag'"/>
  668. </xsl:attribute>
  669. <xsl:attribute name="backcolor">
  670. <xsl:value-of select="$bgcolor"/>
  671. </xsl:attribute>
  672. <xsl:attribute name="color">
  673. <xsl:value-of select="$fcolor"/>
  674. </xsl:attribute>
  675. <xsl:attribute name="style">
  676. <xsl:value-of select="$style"/>
  677. </xsl:attribute>
  678. <xsl:copy-of select="$childnodes"/>
  679. </xsl:element>
  680. </xsl:for-each>
  681. </xsl:if>
  682. </xsl:if>
  683. </xsl:template>
  684. <!-- check CURRENT File -->
  685. <xsl:template name="checkFile" as="xs:string">
  686. <xsl:param name="in" as="xs:string"/>
  687. <xsl:choose>
  688. <xsl:when test="starts-with($in, '.\')">
  689. <xsl:value-of select="substring-after($in, '.\')"/>
  690. </xsl:when>
  691. <!-- The file dir passed in by ant cannot by none -->
  692. <xsl:when test="starts-with($in, './')">
  693. <xsl:value-of select="substring-after($in, './')"/>
  694. </xsl:when>
  695. <xsl:otherwise>
  696. <xsl:value-of select="$in"/>
  697. </xsl:otherwise>
  698. </xsl:choose>
  699. </xsl:template>
  700. <!-- get the scheme list -->
  701. <xsl:template match="*" mode="check" as="xs:string">
  702. <xsl:value-of select="."/>
  703. </xsl:template>
  704. <xsl:template match="*" mode="getVal" as="xs:string">
  705. <xsl:value-of select="@val"/>
  706. </xsl:template>
  707. <!-- get background color -->
  708. <xsl:template match="*" mode="getBgcolor" as="xs:string">
  709. <xsl:choose>
  710. <xsl:when test="@backcolor">
  711. <xsl:value-of select="@backcolor"/>
  712. </xsl:when>
  713. <xsl:otherwise>
  714. <xsl:value-of select="''"/>
  715. </xsl:otherwise>
  716. </xsl:choose>
  717. </xsl:template>
  718. <!-- get font color -->
  719. <xsl:template match="*" mode="getColor" as="xs:string">
  720. <xsl:choose>
  721. <xsl:when test="@color">
  722. <xsl:value-of select="@color"/>
  723. </xsl:when>
  724. <xsl:otherwise>
  725. <xsl:value-of select="''"/>
  726. </xsl:otherwise>
  727. </xsl:choose>
  728. </xsl:template>
  729. <!-- get font style -->
  730. <xsl:template match="*" mode="getStyle" as="xs:string">
  731. <xsl:choose>
  732. <xsl:when test="@style">
  733. <xsl:value-of select="@style"/>
  734. </xsl:when>
  735. <xsl:otherwise>
  736. <xsl:value-of select="''"/>
  737. </xsl:otherwise>
  738. </xsl:choose>
  739. </xsl:template>
  740. <!-- get child nodes -->
  741. <xsl:template match="*" mode="getChildNode">
  742. <xsl:copy-of select="node()"/>
  743. </xsl:template>
  744. <!-- There's a rev attr - test for active rev values -->
  745. <xsl:template name="start-mark-rev">
  746. <xsl:param name="flagrules" as="element()*">
  747. <xsl:call-template name="getrules"/>
  748. </xsl:param>
  749. <xsl:param name="revvalue"/>
  750. <xsl:variable name="revtest" as="xs:integer">
  751. <xsl:call-template name="find-active-rev-flag">
  752. <xsl:with-param name="allrevs" select="$revvalue"/>
  753. </xsl:call-template>
  754. </xsl:variable>
  755. <xsl:if test="$revtest=1">
  756. <xsl:call-template name="start-revision-flag">
  757. <xsl:with-param name="flagrules" select="$flagrules"/>
  758. </xsl:call-template>
  759. </xsl:if>
  760. </xsl:template>
  761. <!-- There's a rev attr - test for active rev values -->
  762. <xsl:template name="end-mark-rev">
  763. <xsl:param name="flagrules" as="element()*">
  764. <xsl:call-template name="getrules"/>
  765. </xsl:param>
  766. <xsl:param name="revvalue"/>
  767. <xsl:variable name="revtest" as="xs:integer">
  768. <xsl:call-template name="find-active-rev-flag">
  769. <xsl:with-param name="allrevs" select="$revvalue"/>
  770. </xsl:call-template>
  771. </xsl:variable>
  772. <xsl:if test="$revtest=1">
  773. <xsl:call-template name="end-revision-flag">
  774. <xsl:with-param name="flagrules" select="$flagrules"/>
  775. </xsl:call-template>
  776. </xsl:if>
  777. </xsl:template>
  778. <!-- output the beginning revision graphic & ALT text -->
  779. <!-- Reverse the artwork for BIDI languages -->
  780. <xsl:template name="start-revision-flag">
  781. <xsl:param name="flagrules" as="element()*">
  782. <xsl:call-template name="getrules"/>
  783. </xsl:param>
  784. <xsl:call-template name="start-revflagit">
  785. <xsl:with-param name="flagrules" select="$flagrules"/>
  786. </xsl:call-template>
  787. </xsl:template>
  788. <xsl:template name="start-revflagit">
  789. <xsl:param name="flagrules" as="element()*">
  790. <xsl:call-template name="getrules"/>
  791. </xsl:param>
  792. <xsl:param name="lang" as="xs:string">
  793. <xsl:call-template name="getLowerCaseLang"/>
  794. </xsl:param>
  795. <xsl:param name="biditest" as="xs:string">
  796. <xsl:call-template name="bidi-area">
  797. <xsl:with-param name="parentlang" select="$lang"/>
  798. </xsl:call-template>
  799. </xsl:param>
  800. <xsl:if test="$flagrules/revprop[1]">
  801. <xsl:apply-templates select="$flagrules/revprop[1]" mode="start-revflagit">
  802. <xsl:with-param name="lang" select="$lang"/>
  803. <xsl:with-param name="biditest" select="$biditest"/>
  804. </xsl:apply-templates>
  805. </xsl:if>
  806. </xsl:template>
  807. <xsl:template name="end-revflagit">
  808. <xsl:param name="flagrules" as="element()*">
  809. <xsl:call-template name="getrules"/>
  810. </xsl:param>
  811. <xsl:param name="lang" as="xs:string">
  812. <xsl:call-template name="getLowerCaseLang"/>
  813. </xsl:param>
  814. <xsl:param name="biditest" as="xs:string">
  815. <xsl:call-template name="bidi-area">
  816. <xsl:with-param name="parentlang" select="$lang"/>
  817. </xsl:call-template>
  818. </xsl:param>
  819. <xsl:if test="$flagrules/revprop[1]">
  820. <xsl:apply-templates select="$flagrules/revprop[last()]" mode="end-revflagit">
  821. <xsl:with-param name="lang" select="$lang"/>
  822. <xsl:with-param name="biditest" select="$biditest"/>
  823. </xsl:apply-templates>
  824. </xsl:if>
  825. </xsl:template>
  826. <!-- output the ending revision graphic & ALT text -->
  827. <!-- Reverse the artwork for BIDI languages -->
  828. <xsl:template name="end-revision-flag">
  829. <xsl:param name="flagrules" as="element()*">
  830. <xsl:call-template name="getrules"/>
  831. </xsl:param>
  832. <xsl:call-template name="end-revflagit">
  833. <xsl:with-param name="flagrules" select="$flagrules"/>
  834. </xsl:call-template>
  835. </xsl:template>
  836. <!-- Use @rev to find the first active flagged revision.
  837. Return 1 for active.
  838. Return 0 for non-active.
  839. NOTE: this template is only called when a filter file is available and
  840. when there is a revision to evaluate. -->
  841. <xsl:template name="find-active-rev-flag" as="xs:integer">
  842. <xsl:param name="allrevs" select="@rev" as="xs:string"/>
  843. <!-- Determine the first rev value, which is the value before the first space -->
  844. <xsl:variable name="firstrev" as="xs:string">
  845. <xsl:choose>
  846. <xsl:when test="contains($allrevs,' ')">
  847. <xsl:value-of select="substring-before($allrevs,' ')"/>
  848. </xsl:when>
  849. <xsl:otherwise> <!-- no space, one value -->
  850. <xsl:value-of select="$allrevs"/>
  851. </xsl:otherwise>
  852. </xsl:choose>
  853. </xsl:variable>
  854. <!-- Determine the other rev value, after the first space -->
  855. <xsl:variable name="morerevs" as="xs:string">
  856. <xsl:choose>
  857. <xsl:when test="contains($allrevs,' ')">
  858. <xsl:value-of select="substring-after($allrevs,' ')"/>
  859. </xsl:when>
  860. <xsl:otherwise>
  861. <xsl:value-of select="''"/>
  862. </xsl:otherwise> <!-- no space, one value -->
  863. </xsl:choose>
  864. </xsl:variable>
  865. <xsl:choose>
  866. <xsl:when test="$FILTERDOC/val/revprop[@val=$firstrev][@action='flag']">
  867. <xsl:value-of select="1"/> <!-- rev active -->
  868. </xsl:when>
  869. <xsl:when test="string-length($morerevs) > 0">
  870. <!-- more values - call it again with remaining values -->
  871. <xsl:call-template name="find-active-rev-flag">
  872. <xsl:with-param name="allrevs" select="$morerevs"/>
  873. </xsl:call-template>
  874. </xsl:when>
  875. <xsl:otherwise> <!-- no more values - none found -->
  876. <xsl:value-of select="0"/>
  877. </xsl:otherwise>
  878. </xsl:choose>
  879. </xsl:template>
  880. <!-- Use @rev to find the first active styled revision.
  881. Return color setting when active.
  882. Return null for non-active. -->
  883. <xsl:template name="find-active-rev-style">
  884. <xsl:param name="allrevs" as="xs:string"/>
  885. <!-- Determine the first rev value, which is the value before the first space -->
  886. <xsl:variable name="firstrev" as="xs:string">
  887. <xsl:choose>
  888. <xsl:when test="contains($allrevs,' ')">
  889. <xsl:value-of select="substring-before($allrevs,' ')"/>
  890. </xsl:when>
  891. <xsl:otherwise> <!-- no space, one value -->
  892. <xsl:value-of select="$allrevs"/>
  893. </xsl:otherwise>
  894. </xsl:choose>
  895. </xsl:variable>
  896. <!-- Determine the other rev value, after the first space -->
  897. <xsl:variable name="morerevs" as="xs:string">
  898. <xsl:choose>
  899. <xsl:when test="contains($allrevs,' ')">
  900. <xsl:value-of select="substring-after($allrevs,' ')"/>
  901. </xsl:when>
  902. <xsl:otherwise>
  903. <xsl:value-of select="''"/>
  904. </xsl:otherwise> <!-- no space, one value -->
  905. </xsl:choose>
  906. </xsl:variable>
  907. <xsl:choose>
  908. <xsl:when test="$FILTERDOC/val/revprop[@val=$firstrev]/@style">
  909. <!-- rev active -->
  910. <xsl:value-of select="$FILTERDOC/val/revprop[@val=$firstrev]/@style"/>
  911. </xsl:when>
  912. <xsl:when test="string-length($morerevs)>0">
  913. <!-- more values - call it again with remaining values -->
  914. <xsl:call-template name="find-active-rev-style">
  915. <xsl:with-param name="allrevs" select="$morerevs"/>
  916. </xsl:call-template>
  917. </xsl:when>
  918. <xsl:otherwise/> <!-- no more values - none found -->
  919. </xsl:choose>
  920. </xsl:template>
  921. <xsl:template name="conflict-check" as="xs:boolean">
  922. <xsl:param name="flagrules" as="element()*">
  923. <xsl:call-template name="getrules"/>
  924. </xsl:param>
  925. <xsl:choose>
  926. <xsl:when test="normalize-space($FILTERFILEURL)=''">
  927. <xsl:sequence select="false()"/>
  928. </xsl:when>
  929. <xsl:when test="$flagrules/*">
  930. <xsl:apply-templates select="$flagrules/*[1]" mode="conflict-check"/>
  931. </xsl:when>
  932. <xsl:otherwise>
  933. <xsl:sequence select="false()"/>
  934. </xsl:otherwise>
  935. </xsl:choose>
  936. </xsl:template>
  937. <xsl:template match="prop|revprop" mode="conflict-check" as="xs:boolean">
  938. <xsl:param name="color"/>
  939. <xsl:param name="backcolor"/>
  940. <xsl:choose>
  941. <xsl:when test="(@color and @color!='' and $color!='' and $color!=@color)or(@backcolor and @backcolor!='' and $backcolor!='' and $backcolor!=@backcolor)">
  942. <xsl:sequence select="true()"/>
  943. </xsl:when>
  944. <xsl:when test="following-sibling::*">
  945. <xsl:apply-templates select="following-sibling::*[1]" mode="conflict-check">
  946. <xsl:with-param name="color" select="@color"/>
  947. <xsl:with-param name="backcolor" select="@backcolor"/>
  948. </xsl:apply-templates>
  949. </xsl:when>
  950. <xsl:otherwise>
  951. <xsl:sequence select="false()"/>
  952. </xsl:otherwise>
  953. </xsl:choose>
  954. </xsl:template>
  955. <!-- In earlier versions of the DITA-OT, conflictexist was always passed in as
  956. a parameter. Seems it would be better to make it a variable and move into
  957. the "if filterfile" section. Leaving alone now in case of any legacy overrides,
  958. and only trivial improvement from moving. -->
  959. <xsl:template match="*" mode="gen-style" as="attribute(outputclass)?">
  960. <xsl:param name="flagrules" as="element()*">
  961. <xsl:call-template name="getrules"/>
  962. </xsl:param>
  963. <xsl:param name="conflictexist" as="xs:boolean">
  964. <xsl:call-template name="conflict-check">
  965. <xsl:with-param name="flagrules" select="$flagrules"/>
  966. </xsl:call-template>
  967. </xsl:param>
  968. <!-- Skip all further checking if there is no filter file -->
  969. <xsl:if test="normalize-space($FILTERFILEURL)!=''">
  970. <xsl:variable name="validstyle" as="xs:boolean">
  971. <!-- This variable is used to prevent using pre-OASIS or unrecognized ditaval styles -->
  972. <xsl:choose>
  973. <xsl:when test="not($conflictexist) and $flagrules/*[@style]">
  974. <xsl:choose>
  975. <xsl:when test="$flagrules/*/@style='italics'">true</xsl:when>
  976. <xsl:when test="$flagrules/*/@style='bold'">true</xsl:when>
  977. <xsl:when test="$flagrules/*/@style='underline'">true</xsl:when>
  978. <xsl:when test="$flagrules/*/@style='double-underline'">true</xsl:when>
  979. <xsl:when test="$flagrules/*/@style='overline'">true</xsl:when>
  980. <xsl:otherwise>false</xsl:otherwise>
  981. </xsl:choose>
  982. </xsl:when>
  983. <xsl:otherwise>false</xsl:otherwise>
  984. </xsl:choose>
  985. </xsl:variable>
  986. <xsl:choose>
  987. <xsl:when test="$conflictexist and $FILTERDOC/val/style-conflict[@foreground-conflict-color or @background-conflict-color]">
  988. <xsl:apply-templates select="." mode="ditamsg:conflict-text-style-applied"/>
  989. <xsl:attribute name="outputclass">
  990. <xsl:if test="$FILTERDOC/val/style-conflict[@foreground-conflict-color]">
  991. <xsl:text>color:</xsl:text>
  992. <xsl:value-of select="$FILTERDOC/val/style-conflict/@foreground-conflict-color"/>
  993. <xsl:text>;</xsl:text>
  994. </xsl:if>
  995. <xsl:if test="$FILTERDOC/val/style-conflict[@background-conflict-color]">
  996. <xsl:text>background-color:</xsl:text>
  997. <xsl:value-of select="$FILTERDOC/val/style-conflict/@background-conflict-color"/>
  998. <xsl:text>;</xsl:text>
  999. </xsl:if>
  1000. </xsl:attribute>
  1001. </xsl:when>
  1002. <xsl:when test="($flagrules/*[@color or @backcolor] or $validstyle)"><!--not($conflictexist) and -->
  1003. <xsl:attribute name="outputclass">
  1004. <xsl:if test="$flagrules/*[@color]">
  1005. <xsl:text>color:</xsl:text>
  1006. <xsl:value-of select="($flagrules/*[@color])[1]/@color"/>
  1007. <xsl:text>;</xsl:text>
  1008. </xsl:if>
  1009. <xsl:if test="$flagrules/*[@backcolor]">
  1010. <xsl:text>background-color:</xsl:text>
  1011. <xsl:value-of select="($flagrules/*[@backcolor])[1]/@backcolor"/>
  1012. <xsl:text>;</xsl:text>
  1013. </xsl:if>
  1014. <xsl:if test="$flagrules/*/@style='italics'">
  1015. <xsl:text>font-style:italic;</xsl:text>
  1016. </xsl:if>
  1017. <xsl:if test="$flagrules/*/@style='bold'">
  1018. <xsl:text>font-weight:bold;</xsl:text>
  1019. </xsl:if>
  1020. <xsl:if test="$flagrules/*/@style='underline' or
  1021. $flagrules/*/@style='double-underline'">
  1022. <!-- For double-underline, style="border-bottom: 3px double;" seems to work
  1023. in some cases, but not in all. For now, treat it as underline. -->
  1024. <xsl:text>text-decoration:underline;</xsl:text>
  1025. </xsl:if>
  1026. <xsl:if test="$flagrules/*/@style='overline'">
  1027. <xsl:text>text-decoration:overline;</xsl:text>
  1028. </xsl:if>
  1029. </xsl:attribute>
  1030. </xsl:when>
  1031. </xsl:choose>
  1032. </xsl:if>
  1033. </xsl:template>
  1034. <xsl:template match="*" mode="ditamsg:cannot-flag-inline-element">
  1035. <xsl:param name="attr-name"/>
  1036. <xsl:call-template name="output-message">
  1037. <xsl:with-param name="id" select="'DOTX042I'"/>
  1038. <xsl:with-param name="msgparams">%1=<xsl:value-of select="$attr-name"/></xsl:with-param>
  1039. </xsl:call-template>
  1040. </xsl:template>
  1041. <xsl:template match="*" mode="ditamsg:conflict-text-style-applied">
  1042. <xsl:call-template name="output-message">
  1043. <xsl:with-param name="id" select="'DOTX054W'"/>
  1044. </xsl:call-template>
  1045. </xsl:template>
  1046. <!-- ===================================================================== -->
  1047. </xsl:stylesheet>