flag-rules.xsl 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- This file is part of the DITA Open Toolkit project hosted on
  3. Sourceforge.net. See the accompanying license.txt file for
  4. applicable licenses.-->
  5. <!-- (c) Copyright IBM Corp. 2007 All Rights Reserved. -->
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  7. <!-- ========== Flagging with flags & revisions ========== -->
  8. <!-- Flags - based on audience, product, platform, and otherprops in the source
  9. AND prop elements in the val file:
  10. Flag the text with the artwork from the val file & insert the ALT text from the val file.
  11. For multiple attr values, output each flag in turn.
  12. -->
  13. <xsl:template match="*" mode="getrules">
  14. <xsl:variable name="domains">
  15. <xsl:value-of select="normalize-space(ancestor-or-self::*[contains(@class,' topic/topic ')][1]/@domains)"/>
  16. </xsl:variable>
  17. <xsl:variable name="tmp_props">
  18. <xsl:call-template name="getExtProps">
  19. <xsl:with-param name="domains" select="$domains"/>
  20. </xsl:call-template>
  21. </xsl:variable>
  22. <xsl:variable name="props">
  23. <xsl:value-of select="substring-after($tmp_props, ',')"/>
  24. </xsl:variable>
  25. <!-- Test for the flagging attributes. If found, call 'gen-prop' with the values to use. Otherwise return -->
  26. <xsl:if test="@audience and not($filterFile='')">
  27. <xsl:call-template name="gen-prop">
  28. <xsl:with-param name="flag-att" select="'audience'"/>
  29. <xsl:with-param name="flag-att-val" select="@audience"/>
  30. </xsl:call-template>
  31. </xsl:if>
  32. <xsl:if test="@platform and not($filterFile='')">
  33. <xsl:call-template name="gen-prop">
  34. <xsl:with-param name="flag-att" select="'platform'"/>
  35. <xsl:with-param name="flag-att-val" select="@platform"/>
  36. </xsl:call-template>
  37. </xsl:if>
  38. <xsl:if test="@product and not($filterFile='')">
  39. <xsl:call-template name="gen-prop">
  40. <xsl:with-param name="flag-att" select="'product'"/>
  41. <xsl:with-param name="flag-att-val" select="@product"/>
  42. </xsl:call-template>
  43. </xsl:if>
  44. <xsl:if test="@otherprops and not($filterFile='')">
  45. <xsl:call-template name="gen-prop">
  46. <xsl:with-param name="flag-att" select="'otherprops'"/>
  47. <xsl:with-param name="flag-att-val" select="@otherprops"/>
  48. </xsl:call-template>
  49. </xsl:if>
  50. <xsl:if test="@rev and not($filterFile='')">
  51. <xsl:call-template name="gen-prop">
  52. <xsl:with-param name="flag-att" select="'rev'"/>
  53. <xsl:with-param name="flag-att-val" select="@rev"/>
  54. </xsl:call-template>
  55. </xsl:if>
  56. <xsl:if test="not($props='') and not($filterFile='')">
  57. <xsl:call-template name="ext-getrules">
  58. <xsl:with-param name="props" select="$props"/>
  59. </xsl:call-template>
  60. </xsl:if>
  61. </xsl:template>
  62. <xsl:template name="getExtProps">
  63. <xsl:param name="domains"/>
  64. <xsl:choose>
  65. <xsl:when test="contains($domains, 'a(props')">
  66. <xsl:text>,</xsl:text><xsl:value-of select="normalize-space(concat('props',substring-before(substring-after($domains,'a(props'), ')')))"/>
  67. <xsl:call-template name="getExtProps">
  68. <xsl:with-param name="domains" select="substring-after(substring-after($domains,'a(props'), ')')"/>
  69. </xsl:call-template>
  70. </xsl:when>
  71. <xsl:otherwise/>
  72. </xsl:choose>
  73. </xsl:template>
  74. <xsl:template name="ext-getrules">
  75. <xsl:param name="props"/>
  76. <xsl:param name="node"/>
  77. <xsl:choose>
  78. <xsl:when test="contains($props,',')">
  79. <xsl:variable name="propsValue">
  80. <xsl:call-template name="getPropsValue">
  81. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  82. </xsl:call-template>
  83. </xsl:variable>
  84. <xsl:variable name="propName">
  85. <xsl:call-template name="getLastPropName">
  86. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  87. </xsl:call-template>
  88. </xsl:variable>
  89. <xsl:if test="not($propsValue='')">
  90. <xsl:call-template name="ext-gen-prop">
  91. <xsl:with-param name="flag-att-path" select="substring-before($props,',')"/>
  92. <xsl:with-param name="flag-att-val" select="$propsValue"/>
  93. </xsl:call-template>
  94. </xsl:if>
  95. <xsl:call-template name="ext-getrules">
  96. <xsl:with-param name="props" select="substring-after($props,',')"/>
  97. </xsl:call-template>
  98. </xsl:when>
  99. <xsl:otherwise>
  100. <xsl:variable name="propsValue">
  101. <xsl:call-template name="getPropsValue">
  102. <xsl:with-param name="propsPath" select="$props"/>
  103. </xsl:call-template>
  104. </xsl:variable>
  105. <xsl:variable name="propName">
  106. <xsl:call-template name="getLastPropName">
  107. <xsl:with-param name="propsPath" select="$props"/>
  108. </xsl:call-template>
  109. </xsl:variable>
  110. <xsl:if test="not($propsValue='')">
  111. <xsl:call-template name="ext-gen-prop">
  112. <xsl:with-param name="flag-att-path" select="$props"/>
  113. <xsl:with-param name="flag-att-val" select="$propsValue"/>
  114. </xsl:call-template>
  115. </xsl:if>
  116. </xsl:otherwise>
  117. </xsl:choose>
  118. </xsl:template>
  119. <xsl:template name="getPropsValue">
  120. <xsl:param name="propsPath"/>
  121. <xsl:variable name="propName">
  122. <xsl:call-template name="getLastPropName">
  123. <xsl:with-param name="propsPath" select="$propsPath"/>
  124. </xsl:call-template>
  125. </xsl:variable>
  126. <xsl:choose>
  127. <xsl:when test="@*[name()=$propName]">
  128. <xsl:value-of select="@*[name()=$propName]"/>
  129. </xsl:when>
  130. <xsl:otherwise>
  131. <xsl:call-template name="getGeneralValue">
  132. <xsl:with-param name="propName" select="$propName"/>
  133. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propName))"/>
  134. </xsl:call-template>
  135. </xsl:otherwise>
  136. </xsl:choose>
  137. </xsl:template>
  138. <xsl:template name="getGeneralValue">
  139. <xsl:param name="propsPath"/>
  140. <xsl:param name="propName"/>
  141. <xsl:variable name="propParentName">
  142. <xsl:call-template name="getLastPropName">
  143. <xsl:with-param name="propsPath" select="$propsPath"/>
  144. </xsl:call-template>
  145. </xsl:variable>
  146. <xsl:choose>
  147. <xsl:when test="contains(@*[name()=$propParentName],concat($propName,'('))">
  148. <xsl:value-of select="substring-before(substring-after(@*[name()=$propParentName],concat($propName,'(')),')')"/>
  149. </xsl:when>
  150. <xsl:otherwise>
  151. <xsl:choose>
  152. <xsl:when test="contains($propsPath,' ')">
  153. <xsl:call-template name="getGeneralValue">
  154. <xsl:with-param name="propName" select="$propName"/>
  155. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propParentName))"/>
  156. </xsl:call-template>
  157. </xsl:when>
  158. <xsl:otherwise/>
  159. </xsl:choose>
  160. </xsl:otherwise>
  161. </xsl:choose>
  162. </xsl:template>
  163. <xsl:template name="getLastPropName">
  164. <xsl:param name="propsPath"/>
  165. <xsl:choose>
  166. <xsl:when test="contains($propsPath,' ')">
  167. <xsl:call-template name="getLastPropName">
  168. <xsl:with-param name="propsPath" select="substring-after($propsPath,' ')"/>
  169. </xsl:call-template>
  170. </xsl:when>
  171. <xsl:otherwise>
  172. <xsl:value-of select="$propsPath"/>
  173. </xsl:otherwise>
  174. </xsl:choose>
  175. </xsl:template>
  176. <!-- No flagging attrs allowed to process in phrases - output a message when in debug mode. -->
  177. <xsl:template name="flagcheck">
  178. </xsl:template>
  179. <xsl:template name="ext-flagcheck">
  180. <xsl:param name="props"/>
  181. <xsl:choose>
  182. <xsl:when test="contains($props,',')">
  183. <xsl:variable name="propsValue">
  184. <xsl:call-template name="getPropsValue">
  185. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  186. </xsl:call-template>
  187. </xsl:variable>
  188. <xsl:variable name="propName">
  189. <xsl:call-template name="getLastPropName">
  190. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  191. </xsl:call-template>
  192. </xsl:variable>
  193. <xsl:if test="not($propsValue='')">
  194. </xsl:if>
  195. <xsl:call-template name="ext-flagcheck">
  196. <xsl:with-param name="props" select="substring-after($props,',')"/>
  197. </xsl:call-template>
  198. </xsl:when>
  199. <xsl:otherwise>
  200. <xsl:variable name="propsValue">
  201. <xsl:call-template name="getPropsValue">
  202. <xsl:with-param name="propsPath" select="$props"/>
  203. </xsl:call-template>
  204. </xsl:variable>
  205. <xsl:variable name="propName">
  206. <xsl:call-template name="getLastPropName">
  207. <xsl:with-param name="propsPath" select="$props"/>
  208. </xsl:call-template>
  209. </xsl:variable>
  210. <xsl:if test="not($propsValue='')">
  211. </xsl:if>
  212. </xsl:otherwise>
  213. </xsl:choose>
  214. </xsl:template>
  215. <xsl:template name="getrules-parent">
  216. <xsl:variable name="domains">
  217. <xsl:value-of select="normalize-space(ancestor::*[contains(@class,' topic/topic ')][1]/@domains)"/>
  218. </xsl:variable>
  219. <xsl:variable name="props">
  220. <xsl:if test="contains($domains, 'a(props')">
  221. <xsl:value-of select="normalize-space(substring-before(substring-after($domains,'a(props'), ')'))"/>
  222. </xsl:if>
  223. </xsl:variable>
  224. <!-- Test for the flagging attributes on the parent.
  225. If found and if the filterFile name was passed in,
  226. call 'gen-prop' with the values to use. Otherwise return -->
  227. <xsl:if test="../@audience and not($filterFile='')">
  228. <xsl:call-template name="gen-prop">
  229. <xsl:with-param name="flag-att" select="'audience'"/>
  230. <xsl:with-param name="flag-att-val" select="../@audience"/>
  231. </xsl:call-template>
  232. </xsl:if>
  233. <xsl:if test="../@platform and not($filterFile='')">
  234. <xsl:call-template name="gen-prop">
  235. <xsl:with-param name="flag-att" select="'platform'"/>
  236. <xsl:with-param name="flag-att-val" select="../@platform"/>
  237. </xsl:call-template>
  238. </xsl:if>
  239. <xsl:if test="../@product and not($filterFile='')">
  240. <xsl:call-template name="gen-prop">
  241. <xsl:with-param name="flag-att" select="'product'"/>
  242. <xsl:with-param name="flag-att-val" select="../@product"/>
  243. </xsl:call-template>
  244. </xsl:if>
  245. <xsl:if test="../@otherprops and not($filterFile='')">
  246. <xsl:call-template name="gen-prop">
  247. <xsl:with-param name="flag-att" select="'otherprops'"/>
  248. <xsl:with-param name="flag-att-val" select="../@otherprops"/>
  249. </xsl:call-template>
  250. </xsl:if>
  251. <xsl:if test="../@rev and not(@rev) and not($filterFile='')">
  252. <xsl:call-template name="gen-prop">
  253. <xsl:with-param name="flag-att" select="'rev'"/>
  254. <xsl:with-param name="flag-att-val" select="../@rev"/>
  255. </xsl:call-template>
  256. </xsl:if>
  257. <xsl:if test="not($props='') and not($filterFile='')">
  258. <xsl:call-template name="ext-getrules-parent">
  259. <xsl:with-param name="props" select="$props"/>
  260. </xsl:call-template>
  261. </xsl:if>
  262. </xsl:template>
  263. <xsl:template name="ext-getrules-parent">
  264. <xsl:param name="props"/>
  265. <xsl:choose>
  266. <xsl:when test="contains($props,',')">
  267. <xsl:variable name="propsValue">
  268. <xsl:call-template name="getPropsValue-parent">
  269. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  270. </xsl:call-template>
  271. </xsl:variable>
  272. <xsl:variable name="propName">
  273. <xsl:call-template name="getLastPropName">
  274. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  275. </xsl:call-template>
  276. </xsl:variable>
  277. <xsl:if test="not($propsValue='')">
  278. <xsl:call-template name="ext-gen-prop">
  279. <xsl:with-param name="flag-att-path" select="substring-before($props,',')"/>
  280. <xsl:with-param name="flag-att-val" select="$propsValue"/>
  281. </xsl:call-template>
  282. </xsl:if>
  283. <xsl:call-template name="ext-getrules-parent">
  284. <xsl:with-param name="props" select="substring-after($props,',')"/>
  285. </xsl:call-template>
  286. </xsl:when>
  287. <xsl:otherwise>
  288. <xsl:variable name="propsValue">
  289. <xsl:call-template name="getPropsValue-parent">
  290. <xsl:with-param name="propsPath" select="$props"/>
  291. </xsl:call-template>
  292. </xsl:variable>
  293. <xsl:variable name="propName">
  294. <xsl:call-template name="getLastPropName">
  295. <xsl:with-param name="propsPath" select="$props"/>
  296. </xsl:call-template>
  297. </xsl:variable>
  298. <xsl:if test="not($propsValue='')">
  299. <xsl:call-template name="ext-gen-prop">
  300. <xsl:with-param name="flag-att-path" select="$props"/>
  301. <xsl:with-param name="flag-att-val" select="$propsValue"/>
  302. </xsl:call-template>
  303. </xsl:if>
  304. </xsl:otherwise>
  305. </xsl:choose>
  306. </xsl:template>
  307. <xsl:template name="getPropsValue-parent">
  308. <xsl:param name="propsPath"/>
  309. <xsl:variable name="propName">
  310. <xsl:call-template name="getLastPropName">
  311. <xsl:with-param name="propsPath" select="$propsPath"/>
  312. </xsl:call-template>
  313. </xsl:variable>
  314. <xsl:choose>
  315. <xsl:when test="../@*[name()=$propName]">
  316. <xsl:value-of select="../@*[name()=$propName]"/>
  317. </xsl:when>
  318. <xsl:otherwise>
  319. <xsl:call-template name="getGeneralValue-parent">
  320. <xsl:with-param name="propName" select="$propName"/>
  321. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propName))"/>
  322. </xsl:call-template>
  323. </xsl:otherwise>
  324. </xsl:choose>
  325. </xsl:template>
  326. <xsl:template name="getGeneralValue-parent">
  327. <xsl:param name="propsPath"/>
  328. <xsl:param name="propName"/>
  329. <xsl:variable name="propParentName">
  330. <xsl:call-template name="getLastPropName">
  331. <xsl:with-param name="propsPath" select="$propsPath"/>
  332. </xsl:call-template>
  333. </xsl:variable>
  334. <xsl:choose>
  335. <xsl:when test="contains(../@*[name()=$propParentName],concat($propName,'('))">
  336. <xsl:value-of select="substring-before(substring-after(../@*[name()=$propParentName],concat($propName,'(')),')')"/>
  337. </xsl:when>
  338. <xsl:otherwise>
  339. <xsl:choose>
  340. <xsl:when test="contains($propsPath,' ')">
  341. <xsl:call-template name="getGeneralValue-parent">
  342. <xsl:with-param name="propName" select="$propName"/>
  343. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propParentName))"/>
  344. </xsl:call-template>
  345. </xsl:when>
  346. <xsl:otherwise/>
  347. </xsl:choose>
  348. </xsl:otherwise>
  349. </xsl:choose>
  350. </xsl:template>
  351. <!-- Use passed attr value to mark each active flag. -->
  352. <xsl:template name="ext-gen-prop">
  353. <xsl:param name="flag-att-path"/>
  354. <xsl:param name="flag-att-val"/>
  355. <xsl:variable name="propName">
  356. <xsl:call-template name="getLastPropName">
  357. <xsl:with-param name="propsPath" select="$flag-att-path"/>
  358. </xsl:call-template>
  359. </xsl:variable>
  360. <xsl:variable name="flag-result">
  361. <xsl:call-template name="gen-prop">
  362. <xsl:with-param name="flag-att" select="$propName"/>
  363. <xsl:with-param name="flag-att-val" select="$flag-att-val"/>
  364. </xsl:call-template>
  365. </xsl:variable>
  366. <xsl:choose>
  367. <xsl:when test="$flag-result/prop">
  368. <xsl:copy-of select="$flag-result"/>
  369. </xsl:when>
  370. <xsl:otherwise>
  371. <xsl:if test="contains($flag-att-path,' ')">
  372. <xsl:call-template name="ext-gen-prop">
  373. <xsl:with-param name="flag-att-path" select="normalize-space(substring-before($flag-att-path, $propName))"/>
  374. <xsl:with-param name="flag-att-val" select="$flag-att-val"/>
  375. </xsl:call-template>
  376. </xsl:if>
  377. </xsl:otherwise>
  378. </xsl:choose>
  379. </xsl:template>
  380. <xsl:template name="gen-prop">
  381. <xsl:param name="flag-att"/> <!-- attribute name -->
  382. <xsl:param name="flag-att-val"/> <!-- content of attribute -->
  383. <!-- Determine the first flag value, which is the value before the first space -->
  384. <xsl:variable name="firstflag">
  385. <xsl:choose>
  386. <xsl:when test="contains($flag-att-val,' ')">
  387. <xsl:value-of select="substring-before($flag-att-val,' ')"/>
  388. </xsl:when>
  389. <xsl:otherwise> <!-- no space, one value -->
  390. <xsl:value-of select="$flag-att-val"/>
  391. </xsl:otherwise>
  392. </xsl:choose>
  393. </xsl:variable>
  394. <!-- Determine the other flag values, after the first space -->
  395. <xsl:variable name="moreflags">
  396. <xsl:choose>
  397. <xsl:when test="contains($flag-att-val,' ')">
  398. <xsl:value-of select="substring-after($flag-att-val,' ')"/>
  399. </xsl:when>
  400. <xsl:otherwise/> <!-- no space, one value -->
  401. </xsl:choose>
  402. </xsl:variable>
  403. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  404. <xsl:when test="$flag-att='rev' and $flagsParams/val/revprop[@val=$firstflag][@action='flag']">
  405. <xsl:copy-of select="$flagsParams/val/revprop[@val=$firstflag][@action='flag']"/>
  406. </xsl:when>
  407. <xsl:when test="$flagsParams/val/prop[@att=$flag-att][@val=$firstflag][@action='flag']">
  408. <xsl:copy-of select="$flagsParams/val/prop[@att=$flag-att][@val=$firstflag][@action='flag']"/>
  409. </xsl:when>
  410. <xsl:otherwise/> <!-- that flag not active -->
  411. </xsl:choose>
  412. <!-- keep testing other values -->
  413. <xsl:choose>
  414. <xsl:when test="string-length($moreflags)>0">
  415. <!-- more values - call it again with remaining values -->
  416. <xsl:call-template name="gen-prop">
  417. <xsl:with-param name="flag-att"><xsl:value-of select="$flag-att"/></xsl:with-param>
  418. <xsl:with-param name="flag-att-val"><xsl:value-of select="$moreflags"/></xsl:with-param>
  419. </xsl:call-template>
  420. </xsl:when>
  421. <xsl:otherwise/> <!-- no more values -->
  422. </xsl:choose>
  423. </xsl:template>
  424. <!-- Use @rev to find the first active flagged revision.
  425. Return 1 for active.
  426. Return 0 for non-active. -->
  427. <xsl:template name="find-active-rev-flag">
  428. <xsl:param name="allrevs"/>
  429. <!-- Determine the first rev value, which is the value before the first space -->
  430. <xsl:variable name="firstrev">
  431. <xsl:choose>
  432. <xsl:when test="contains($allrevs,' ')">
  433. <xsl:value-of select="substring-before($allrevs,' ')"/>
  434. </xsl:when>
  435. <xsl:otherwise> <!-- no space, one value -->
  436. <xsl:value-of select="$allrevs"/>
  437. </xsl:otherwise>
  438. </xsl:choose>
  439. </xsl:variable>
  440. <!-- Determine the other rev value, after the first space -->
  441. <xsl:variable name="morerevs">
  442. <xsl:choose>
  443. <xsl:when test="contains($allrevs,' ')">
  444. <xsl:value-of select="substring-after($allrevs,' ')"/>
  445. </xsl:when>
  446. <xsl:otherwise/> <!-- no space, one value -->
  447. </xsl:choose>
  448. </xsl:variable>
  449. <xsl:choose>
  450. <xsl:when test="$flagsParams/val/revprop[@val=$firstrev][@action='flag']">
  451. <xsl:value-of select="1"/> <!-- rev active -->
  452. </xsl:when>
  453. <xsl:otherwise> <!-- rev not active -->
  454. <!-- keep testing other values -->
  455. <xsl:choose>
  456. <xsl:when test="string-length($morerevs)>0">
  457. <!-- more values - call it again with remaining values -->
  458. <xsl:call-template name="find-active-rev-flag">
  459. <xsl:with-param name="allrevs"><xsl:value-of select="$morerevs"/></xsl:with-param>
  460. </xsl:call-template>
  461. </xsl:when>
  462. <xsl:otherwise> <!-- no more values - none found -->
  463. <xsl:value-of select="0"/>
  464. </xsl:otherwise>
  465. </xsl:choose>
  466. </xsl:otherwise>
  467. </xsl:choose>
  468. </xsl:template>
  469. <!-- Use @rev to find the first active styled revision.
  470. Return color setting when active.
  471. Return null for non-active. -->
  472. <xsl:template name="find-active-rev-style">
  473. <xsl:param name="allrevs"/>
  474. <!-- Determine the first rev value, which is the value before the first space -->
  475. <xsl:variable name="firstrev">
  476. <xsl:choose>
  477. <xsl:when test="contains($allrevs,' ')">
  478. <xsl:value-of select="substring-before($allrevs,' ')"/>
  479. </xsl:when>
  480. <xsl:otherwise> <!-- no space, one value -->
  481. <xsl:value-of select="$allrevs"/>
  482. </xsl:otherwise>
  483. </xsl:choose>
  484. </xsl:variable>
  485. <!-- Determine the other rev value, after the first space -->
  486. <xsl:variable name="morerevs">
  487. <xsl:choose>
  488. <xsl:when test="contains($allrevs,' ')">
  489. <xsl:value-of select="substring-after($allrevs,' ')"/>
  490. </xsl:when>
  491. <xsl:otherwise/> <!-- no space, one value -->
  492. </xsl:choose>
  493. </xsl:variable>
  494. <xsl:choose>
  495. <xsl:when test="$flagsParams/val/revprop[@val=$firstrev]/@style">
  496. <!-- rev active -->
  497. <xsl:value-of select="$flagsParams/val/revprop[@val=$firstrev]/@style"/>
  498. </xsl:when>
  499. <xsl:otherwise> <!-- rev not active -->
  500. <!-- keep testing other values -->
  501. <xsl:choose>
  502. <xsl:when test="string-length($morerevs)>0">
  503. <!-- more values - call it again with remaining values -->
  504. <xsl:call-template name="find-active-rev-style">
  505. <xsl:with-param name="allrevs"><xsl:value-of select="$morerevs"/></xsl:with-param>
  506. </xsl:call-template>
  507. </xsl:when>
  508. <xsl:otherwise/> <!-- no more values - none found -->
  509. </xsl:choose>
  510. </xsl:otherwise>
  511. </xsl:choose>
  512. </xsl:template>
  513. <xsl:template match="*" mode="conflict-check">
  514. <xsl:param name="flagrules"/>
  515. <xsl:choose>
  516. <xsl:when test="$flagrules/*">
  517. <xsl:apply-templates select="$flagrules/*[1]" mode="conflict-check"/>
  518. </xsl:when>
  519. <xsl:otherwise>
  520. <xsl:value-of select="'false'"/>
  521. </xsl:otherwise>
  522. </xsl:choose>
  523. </xsl:template>
  524. <xsl:template match="prop|revprop" mode="conflict-check">
  525. <xsl:param name="color"/>
  526. <xsl:param name="backcolor"/>
  527. <xsl:choose>
  528. <xsl:when test="(@color and @color!='' and $color!='' and $color!=@color)or(@backcolor and @backcolor!='' and $backcolor!='' and $backcolor!=@backcolor)">
  529. <xsl:value-of select="'true'"/>
  530. </xsl:when>
  531. <xsl:when test="following-sibling::*">
  532. <xsl:apply-templates select="following-sibling::*[1]" mode="conflict-check">
  533. <xsl:with-param name="color" select="@color"/>
  534. <xsl:with-param name="backcolor" select="@backcolor"/>
  535. </xsl:apply-templates>
  536. </xsl:when>
  537. <xsl:otherwise>
  538. <xsl:value-of select="'false'"/>
  539. </xsl:otherwise>
  540. </xsl:choose>
  541. </xsl:template>
  542. <!-- ===================================================================== -->
  543. </xsl:stylesheet>