flag.xsl 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  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, 2009 All Rights Reserved. -->
  6. <!-- Updates:
  7. 20090421 robander: Updated so that "flagrules" in all templates
  8. specifies a default. Can simplify calls from other XSL
  9. to these templates, with a slight trade-off in processing
  10. time. Default for "conflictexist" simplifies XSL
  11. elsewhere with no processing trade-off.
  12. -->
  13. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. version="2.0"
  15. xmlns:dita2html="http://dita-ot.sourceforge.net/ns/200801/dita2html"
  16. xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
  17. exclude-result-prefixes="dita2html ditamsg">
  18. <xsl:template name="getrules">
  19. <xsl:variable name="domains">
  20. <xsl:value-of select="normalize-space(ancestor-or-self::*[contains(@class,' topic/topic ')][1]/@domains)"/>
  21. </xsl:variable>
  22. <xsl:variable name="tmp_props">
  23. <xsl:call-template name="getExtProps">
  24. <xsl:with-param name="domains" select="$domains"/>
  25. </xsl:call-template>
  26. </xsl:variable>
  27. <xsl:variable name="props">
  28. <xsl:value-of select="substring-after($tmp_props, ',')"/>
  29. </xsl:variable>
  30. <!-- Test for the flagging attributes. If found, call 'gen-prop' with the values to use. Otherwise return -->
  31. <xsl:if test="@audience and not($FILTERFILE='')">
  32. <xsl:call-template name="gen-prop">
  33. <xsl:with-param name="flag-att" select="'audience'"/>
  34. <xsl:with-param name="flag-att-val" select="@audience"/>
  35. </xsl:call-template>
  36. </xsl:if>
  37. <xsl:if test="@platform and not($FILTERFILE='')">
  38. <xsl:call-template name="gen-prop">
  39. <xsl:with-param name="flag-att" select="'platform'"/>
  40. <xsl:with-param name="flag-att-val" select="@platform"/>
  41. </xsl:call-template>
  42. </xsl:if>
  43. <xsl:if test="@product and not($FILTERFILE='')">
  44. <xsl:call-template name="gen-prop">
  45. <xsl:with-param name="flag-att" select="'product'"/>
  46. <xsl:with-param name="flag-att-val" select="@product"/>
  47. </xsl:call-template>
  48. </xsl:if>
  49. <xsl:if test="@otherprops and not($FILTERFILE='')">
  50. <xsl:call-template name="gen-prop">
  51. <xsl:with-param name="flag-att" select="'otherprops'"/>
  52. <xsl:with-param name="flag-att-val" select="@otherprops"/>
  53. </xsl:call-template>
  54. </xsl:if>
  55. <xsl:if test="@rev and not($FILTERFILE='')">
  56. <xsl:call-template name="gen-prop">
  57. <xsl:with-param name="flag-att" select="'rev'"/>
  58. <xsl:with-param name="flag-att-val" select="@rev"/>
  59. </xsl:call-template>
  60. </xsl:if>
  61. <xsl:if test="not($props='') and not($FILTERFILE='')">
  62. <xsl:call-template name="ext-getrules">
  63. <xsl:with-param name="props" select="$props"/>
  64. </xsl:call-template>
  65. </xsl:if>
  66. </xsl:template>
  67. <xsl:template name="getExtProps">
  68. <xsl:param name="domains"/>
  69. <xsl:choose>
  70. <xsl:when test="contains($domains, 'a(props')">
  71. <xsl:text>,</xsl:text><xsl:value-of select="normalize-space(concat('props',substring-before(substring-after($domains,'a(props'), ')')))"/>
  72. <xsl:call-template name="getExtProps">
  73. <xsl:with-param name="domains" select="substring-after(substring-after($domains,'a(props'), ')')"/>
  74. </xsl:call-template>
  75. </xsl:when>
  76. <xsl:otherwise/>
  77. </xsl:choose>
  78. </xsl:template>
  79. <xsl:template name="ext-getrules">
  80. <xsl:param name="props"/>
  81. <xsl:choose>
  82. <xsl:when test="contains($props,',')">
  83. <xsl:variable name="propsValue">
  84. <xsl:call-template name="getPropsValue">
  85. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  86. </xsl:call-template>
  87. </xsl:variable>
  88. <xsl:variable name="propName">
  89. <xsl:call-template name="getLastPropName">
  90. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  91. </xsl:call-template>
  92. </xsl:variable>
  93. <xsl:if test="not($propsValue='')">
  94. <xsl:call-template name="ext-gen-prop">
  95. <xsl:with-param name="flag-att-path" select="substring-before($props,',')"/>
  96. <xsl:with-param name="flag-att-val" select="$propsValue"/>
  97. </xsl:call-template>
  98. </xsl:if>
  99. <xsl:call-template name="ext-getrules">
  100. <xsl:with-param name="props" select="substring-after($props,',')"/>
  101. </xsl:call-template>
  102. </xsl:when>
  103. <xsl:otherwise>
  104. <xsl:variable name="propsValue">
  105. <xsl:call-template name="getPropsValue">
  106. <xsl:with-param name="propsPath" select="$props"/>
  107. </xsl:call-template>
  108. </xsl:variable>
  109. <xsl:variable name="propName">
  110. <xsl:call-template name="getLastPropName">
  111. <xsl:with-param name="propsPath" select="$props"/>
  112. </xsl:call-template>
  113. </xsl:variable>
  114. <xsl:if test="not($propsValue='')">
  115. <xsl:call-template name="ext-gen-prop">
  116. <xsl:with-param name="flag-att-path" select="$props"/>
  117. <xsl:with-param name="flag-att-val" select="$propsValue"/>
  118. </xsl:call-template>
  119. </xsl:if>
  120. </xsl:otherwise>
  121. </xsl:choose>
  122. </xsl:template>
  123. <!-- Use passed attr value to mark each active flag. -->
  124. <xsl:template name="ext-gen-prop">
  125. <xsl:param name="flag-att-path"/>
  126. <xsl:param name="flag-att-val"/>
  127. <xsl:variable name="propName">
  128. <xsl:call-template name="getLastPropName">
  129. <xsl:with-param name="propsPath" select="$flag-att-path"/>
  130. </xsl:call-template>
  131. </xsl:variable>
  132. <xsl:variable name="flag-result">
  133. <xsl:call-template name="gen-prop">
  134. <xsl:with-param name="flag-att" select="$propName"/>
  135. <xsl:with-param name="flag-att-val" select="$flag-att-val"/>
  136. </xsl:call-template>
  137. </xsl:variable>
  138. <xsl:choose>
  139. <xsl:when test="$flag-result/prop">
  140. <xsl:copy-of select="$flag-result"/>
  141. </xsl:when>
  142. <xsl:otherwise>
  143. <xsl:if test="contains($flag-att-path,' ')">
  144. <xsl:call-template name="ext-gen-prop">
  145. <xsl:with-param name="flag-att-path" select="normalize-space(substring-before($flag-att-path, $propName))"/>
  146. <xsl:with-param name="flag-att-val" select="$flag-att-val"/>
  147. </xsl:call-template>
  148. </xsl:if>
  149. </xsl:otherwise>
  150. </xsl:choose>
  151. </xsl:template>
  152. <xsl:template name="gen-prop">
  153. <xsl:param name="flag-att"/> <!-- attribute name -->
  154. <xsl:param name="flag-att-val"/> <!-- content of attribute -->
  155. <!-- Determine the first flag value, which is the value before the first space -->
  156. <xsl:variable name="firstflag">
  157. <xsl:choose>
  158. <xsl:when test="contains($flag-att-val,' ')">
  159. <xsl:value-of select="substring-before($flag-att-val,' ')"/>
  160. </xsl:when>
  161. <xsl:otherwise> <!-- no space, one value -->
  162. <xsl:value-of select="$flag-att-val"/>
  163. </xsl:otherwise>
  164. </xsl:choose>
  165. </xsl:variable>
  166. <!-- Determine the other flag values, after the first space -->
  167. <xsl:variable name="moreflags">
  168. <xsl:choose>
  169. <xsl:when test="contains($flag-att-val,' ')">
  170. <xsl:value-of select="substring-after($flag-att-val,' ')"/>
  171. </xsl:when>
  172. <xsl:otherwise/> <!-- no space, one value -->
  173. </xsl:choose>
  174. </xsl:variable>
  175. <xsl:choose> <!-- Ensure there's an image to get, otherwise don't insert anything -->
  176. <xsl:when test="$flag-att='rev' and $FILTERDOC/val/revprop[@val=$firstflag][@action='flag']">
  177. <xsl:copy-of select="$FILTERDOC/val/revprop[@val=$firstflag][@action='flag']"/>
  178. </xsl:when>
  179. <xsl:when test="$FILTERDOC/val/prop[@att=$flag-att][@val=$firstflag][@action='flag']">
  180. <xsl:copy-of select="$FILTERDOC/val/prop[@att=$flag-att][@val=$firstflag][@action='flag']"/>
  181. </xsl:when>
  182. <xsl:when test="$FILTERDOC/val/prop[@att=$flag-att][not(@val=$firstflag)][@action='flag']">
  183. <xsl:for-each select="$FILTERDOC/val/prop[@att=$flag-att][not(@val=$firstflag)][@action='flag']">
  184. <!-- get the val -->
  185. <xsl:variable name="val">
  186. <xsl:apply-templates select="." mode="getVal"/>
  187. </xsl:variable>
  188. <!-- get the backcolor -->
  189. <xsl:variable name="backcolor">
  190. <xsl:apply-templates select="." mode="getBgcolor"/>
  191. </xsl:variable>
  192. <!-- get the color -->
  193. <xsl:variable name="color">
  194. <xsl:apply-templates select="." mode="getColor"/>
  195. </xsl:variable>
  196. <!-- get the style -->
  197. <xsl:variable name="style">
  198. <xsl:apply-templates select="." mode="getStyle"/>
  199. </xsl:variable>
  200. <!-- get child node -->
  201. <xsl:variable name="childnode">
  202. <xsl:apply-templates select="." mode="getChildNode"/>
  203. </xsl:variable>
  204. <!-- get the location of schemekeydef.xml -->
  205. <xsl:variable name="KEYDEF-FILE">
  206. <xsl:value-of select="concat($WORKDIR,$PATH2PROJ,'schemekeydef.xml')"/>
  207. </xsl:variable>
  208. <!--keydef.xml contains the val -->
  209. <xsl:if test="(document($KEYDEF-FILE, /)//*[@keys=$val])">
  210. <!-- copy needed elements -->
  211. <xsl:apply-templates select="(document($KEYDEF-FILE, /)//*[@keys=$val])" mode="copy-element">
  212. <xsl:with-param name="att" select="$flag-att"/>
  213. <xsl:with-param name="bgcolor" select="$backcolor"/>
  214. <xsl:with-param name="fcolor" select="$color"/>
  215. <xsl:with-param name="style" select="$style"/>
  216. <xsl:with-param name="value" select="$val"/>
  217. <xsl:with-param name="flag" select="$firstflag"/>
  218. <xsl:with-param name="childnodes" select="$childnode"/>
  219. </xsl:apply-templates>
  220. </xsl:if>
  221. </xsl:for-each>
  222. </xsl:when>
  223. <xsl:otherwise/> <!-- that flag not active -->
  224. </xsl:choose>
  225. <!-- keep testing other values -->
  226. <xsl:choose>
  227. <xsl:when test="string-length($moreflags)>0">
  228. <!-- more values - call it again with remaining values -->
  229. <xsl:call-template name="gen-prop">
  230. <xsl:with-param name="flag-att"><xsl:value-of select="$flag-att"/></xsl:with-param>
  231. <xsl:with-param name="flag-att-val"><xsl:value-of select="$moreflags"/></xsl:with-param>
  232. </xsl:call-template>
  233. </xsl:when>
  234. <xsl:otherwise/> <!-- no more values -->
  235. </xsl:choose>
  236. </xsl:template>
  237. <!-- copy needed elements -->
  238. <xsl:template match="*" mode="copy-element">
  239. <xsl:param name="att"/>
  240. <xsl:param name="bgcolor"/>
  241. <xsl:param name="fcolor"/>
  242. <xsl:param name="style"/>
  243. <xsl:param name="value"/>
  244. <xsl:param name="flag"/>
  245. <xsl:param name="cvffilename" select="@source"/>
  246. <xsl:param name="childnodes"/>
  247. <!--get the location of dita.xml.properties-->
  248. <xsl:variable name="INITIAL-PROPERTIES-FILE">
  249. <xsl:value-of select="translate(concat($WORKDIR , $PATH2PROJ , 'subject_scheme.dictionary'), '\', '/')"/>
  250. </xsl:variable>
  251. <xsl:variable name="PROPERTIES-FILE">
  252. <xsl:choose>
  253. <xsl:when test="starts-with($INITIAL-PROPERTIES-FILE,'/')">
  254. <xsl:text>file://</xsl:text><xsl:value-of select="$INITIAL-PROPERTIES-FILE"/>
  255. </xsl:when>
  256. <xsl:otherwise>
  257. <xsl:text>file:/</xsl:text><xsl:value-of select="$INITIAL-PROPERTIES-FILE"/>
  258. </xsl:otherwise>
  259. </xsl:choose>
  260. </xsl:variable>
  261. <!-- get the scheme list -->
  262. <!-- check CURRENT File -->
  263. <xsl:variable name="editedFileName">
  264. <xsl:call-template name="checkFile">
  265. <xsl:with-param name="in" select="$CURRENTFILE"/>
  266. </xsl:call-template>
  267. </xsl:variable>
  268. <xsl:variable name="schemeList">
  269. <xsl:apply-templates select="document($PROPERTIES-FILE,/)//*[@key=$editedFileName]" mode="check"/>
  270. </xsl:variable>
  271. <!-- scheme list contains the scheme file -->
  272. <xsl:if test="contains($schemeList, $cvffilename)">
  273. <!-- get the path of scheme file -->
  274. <xsl:variable name="submfile">
  275. <xsl:value-of select="$cvffilename"/><xsl:text>.subm</xsl:text>
  276. </xsl:variable>
  277. <xsl:variable name="cvffilepath">
  278. <xsl:value-of select="concat($WORKDIR,$PATH2PROJ,$submfile)"/>
  279. </xsl:variable>
  280. <xsl:if test="document($cvffilepath,/)//*[@keys=$value]//*[@keys=$flag]">
  281. <!-- copy the child node for flag and just copy the first element whose keys=$flag-->
  282. <!--xsl:for-each select="document($cvffilepath,/)//*[@keys=$value]/*"-->
  283. <xsl:for-each select="document($cvffilepath,/)//*[@keys=$value]//*[@keys=$flag][1]">
  284. <xsl:element name="prop">
  285. <xsl:attribute name="att">
  286. <xsl:value-of select="$att"/>
  287. </xsl:attribute>
  288. <xsl:attribute name="val">
  289. <xsl:value-of select="@keys"/>
  290. </xsl:attribute>
  291. <xsl:attribute name="action">
  292. <xsl:value-of select="'flag'"/>
  293. </xsl:attribute>
  294. <xsl:attribute name="backcolor">
  295. <xsl:value-of select="$bgcolor"/>
  296. </xsl:attribute>
  297. <xsl:attribute name="color">
  298. <xsl:value-of select="$fcolor"/>
  299. </xsl:attribute>
  300. <xsl:attribute name="style">
  301. <xsl:value-of select="$style"/>
  302. </xsl:attribute>
  303. <xsl:copy-of select="$childnodes"/>
  304. </xsl:element>
  305. </xsl:for-each>
  306. </xsl:if>
  307. </xsl:if>
  308. </xsl:template>
  309. <!-- check CURRENT File -->
  310. <xsl:template name="checkFile">
  311. <xsl:param name="in"/>
  312. <xsl:choose>
  313. <xsl:when test="starts-with($in, '.\')">
  314. <xsl:value-of select="substring-after($in, '.\')"/>
  315. </xsl:when>
  316. <!-- The file dir passed in by ant cannot by none -->
  317. <xsl:when test="starts-with($in, './')">
  318. <xsl:value-of select="substring-after($in, './')"/>
  319. </xsl:when>
  320. <xsl:otherwise>
  321. <xsl:value-of select="$in"/>
  322. </xsl:otherwise>
  323. </xsl:choose>
  324. </xsl:template>
  325. <!-- get the scheme list -->
  326. <xsl:template match="*" mode="check">
  327. <xsl:value-of select="."/>
  328. </xsl:template>
  329. <xsl:template match="*" mode="getVal">
  330. <xsl:value-of select="@val"/>
  331. </xsl:template>
  332. <!-- get background color -->
  333. <xsl:template match="*" mode="getBgcolor">
  334. <xsl:choose>
  335. <xsl:when test="@backcolor">
  336. <xsl:value-of select="@backcolor"/>
  337. </xsl:when>
  338. <xsl:otherwise>
  339. <xsl:value-of select="''"/>
  340. </xsl:otherwise>
  341. </xsl:choose>
  342. </xsl:template>
  343. <!-- get font color -->
  344. <xsl:template match="*" mode="getColor">
  345. <xsl:choose>
  346. <xsl:when test="@color">
  347. <xsl:value-of select="@color"/>
  348. </xsl:when>
  349. <xsl:otherwise>
  350. <xsl:value-of select="''"/>
  351. </xsl:otherwise>
  352. </xsl:choose>
  353. </xsl:template>
  354. <!-- get font style -->
  355. <xsl:template match="*" mode="getStyle">
  356. <xsl:choose>
  357. <xsl:when test="@style">
  358. <xsl:value-of select="@style"/>
  359. </xsl:when>
  360. <xsl:otherwise>
  361. <xsl:value-of select="''"/>
  362. </xsl:otherwise>
  363. </xsl:choose>
  364. </xsl:template>
  365. <!-- get child nodes -->
  366. <xsl:template match="*" mode="getChildNode">
  367. <xsl:copy-of select="node()"/>
  368. </xsl:template>
  369. <xsl:template name="getPropsValue">
  370. <xsl:param name="propsPath"/>
  371. <xsl:variable name="propName">
  372. <xsl:call-template name="getLastPropName">
  373. <xsl:with-param name="propsPath" select="$propsPath"/>
  374. </xsl:call-template>
  375. </xsl:variable>
  376. <xsl:choose>
  377. <xsl:when test="@*[name()=$propName]">
  378. <xsl:value-of select="@*[name()=$propName]"/>
  379. </xsl:when>
  380. <xsl:otherwise>
  381. <xsl:call-template name="getGeneralValue">
  382. <xsl:with-param name="propName" select="$propName"/>
  383. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propName))"/>
  384. </xsl:call-template>
  385. </xsl:otherwise>
  386. </xsl:choose>
  387. </xsl:template>
  388. <xsl:template name="getLastPropName">
  389. <xsl:param name="propsPath"/>
  390. <xsl:choose>
  391. <xsl:when test="contains($propsPath,' ')">
  392. <xsl:call-template name="getLastPropName">
  393. <xsl:with-param name="propsPath" select="substring-after($propsPath,' ')"/>
  394. </xsl:call-template>
  395. </xsl:when>
  396. <xsl:otherwise>
  397. <xsl:value-of select="$propsPath"/>
  398. </xsl:otherwise>
  399. </xsl:choose>
  400. </xsl:template>
  401. <xsl:template name="getGeneralValue">
  402. <xsl:param name="propsPath"/>
  403. <xsl:param name="propName"/>
  404. <xsl:variable name="propParentName">
  405. <xsl:call-template name="getLastPropName">
  406. <xsl:with-param name="propsPath" select="$propsPath"/>
  407. </xsl:call-template>
  408. </xsl:variable>
  409. <xsl:choose>
  410. <xsl:when test="contains(@*[name()=$propParentName],concat($propName,'('))">
  411. <xsl:value-of select="substring-before(substring-after(@*[name()=$propParentName],concat($propName,'(')),')')"/>
  412. </xsl:when>
  413. <xsl:otherwise>
  414. <xsl:choose>
  415. <xsl:when test="contains($propsPath,' ')">
  416. <xsl:call-template name="getGeneralValue">
  417. <xsl:with-param name="propName" select="$propName"/>
  418. <xsl:with-param name="propsPath" select="normalize-space(substring-before($propsPath, $propParentName))"/>
  419. </xsl:call-template>
  420. </xsl:when>
  421. <xsl:otherwise/>
  422. </xsl:choose>
  423. </xsl:otherwise>
  424. </xsl:choose>
  425. </xsl:template>
  426. <xsl:template name="conflict-check">
  427. <xsl:param name="flagrules">
  428. <xsl:call-template name="getrules"/>
  429. </xsl:param>
  430. <xsl:choose>
  431. <xsl:when test="$flagrules/*">
  432. <xsl:apply-templates select="$flagrules/*[1]" mode="conflict-check"/>
  433. </xsl:when>
  434. <xsl:otherwise>
  435. <xsl:value-of select="'false'"/>
  436. </xsl:otherwise>
  437. </xsl:choose>
  438. </xsl:template>
  439. <xsl:template match="prop|revprop" mode="conflict-check">
  440. <xsl:param name="color"/>
  441. <xsl:param name="backcolor"/>
  442. <xsl:choose>
  443. <xsl:when test="(@color and @color!='' and $color!='' and $color!=@color)or(@backcolor and @backcolor!='' and $backcolor!='' and $backcolor!=@backcolor)">
  444. <xsl:value-of select="'true'"/>
  445. </xsl:when>
  446. <xsl:when test="following-sibling::*">
  447. <xsl:apply-templates select="following-sibling::*[1]" mode="conflict-check">
  448. <xsl:with-param name="color" select="@color"/>
  449. <xsl:with-param name="backcolor" select="@backcolor"/>
  450. </xsl:apply-templates>
  451. </xsl:when>
  452. <xsl:otherwise>
  453. <xsl:value-of select="'false'"/>
  454. </xsl:otherwise>
  455. </xsl:choose>
  456. </xsl:template>
  457. <xsl:template name="start-flagit">
  458. <xsl:param name="flagrules">
  459. <xsl:call-template name="getrules"/>
  460. </xsl:param>
  461. <xsl:apply-templates select="$flagrules/prop[1]" mode="start-flagit"/>
  462. </xsl:template>
  463. <xsl:template name="end-flagit">
  464. <xsl:param name="flagrules">
  465. <xsl:call-template name="getrules"/>
  466. </xsl:param>
  467. <xsl:apply-templates select="$flagrules/prop[last()]" mode="end-flagit"/>
  468. </xsl:template>
  469. <!-- Use @rev to find the first active flagged revision.
  470. Return 1 for active.
  471. Return 0 for non-active. -->
  472. <xsl:template name="find-active-rev-flag">
  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="$FILTERDOC/val/revprop[@val=$firstrev][@action='flag']">
  496. <xsl:value-of select="1"/> <!-- rev active -->
  497. </xsl:when>
  498. <xsl:otherwise> <!-- rev not active -->
  499. <!-- keep testing other values -->
  500. <xsl:choose>
  501. <xsl:when test="string-length($morerevs)>0">
  502. <!-- more values - call it again with remaining values -->
  503. <xsl:call-template name="find-active-rev-flag">
  504. <xsl:with-param name="allrevs"><xsl:value-of select="$morerevs"/></xsl:with-param>
  505. </xsl:call-template>
  506. </xsl:when>
  507. <xsl:otherwise> <!-- no more values - none found -->
  508. <xsl:value-of select="0"/>
  509. </xsl:otherwise>
  510. </xsl:choose>
  511. </xsl:otherwise>
  512. </xsl:choose>
  513. </xsl:template>
  514. <!-- There's a rev attr - test for active rev values -->
  515. <xsl:template name="start-mark-rev">
  516. <xsl:param name="flagrules">
  517. <xsl:call-template name="getrules"/>
  518. </xsl:param>
  519. <xsl:param name="revvalue"/>
  520. <xsl:variable name="revtest">
  521. <xsl:call-template name="find-active-rev-flag">
  522. <xsl:with-param name="allrevs" select="$revvalue"/>
  523. </xsl:call-template>
  524. </xsl:variable>
  525. <xsl:if test="$revtest=1">
  526. <xsl:call-template name="start-revision-flag">
  527. <xsl:with-param name="flagrules" select="$flagrules"/>
  528. </xsl:call-template>
  529. </xsl:if>
  530. </xsl:template>
  531. <!-- There's a rev attr - test for active rev values -->
  532. <xsl:template name="end-mark-rev">
  533. <xsl:param name="flagrules">
  534. <xsl:call-template name="getrules"/>
  535. </xsl:param>
  536. <xsl:param name="revvalue"/>
  537. <xsl:variable name="revtest">
  538. <xsl:call-template name="find-active-rev-flag">
  539. <xsl:with-param name="allrevs" select="$revvalue"/>
  540. </xsl:call-template>
  541. </xsl:variable>
  542. <xsl:if test="$revtest=1">
  543. <xsl:call-template name="end-revision-flag">
  544. <xsl:with-param name="flagrules" select="$flagrules"/>
  545. </xsl:call-template>
  546. </xsl:if>
  547. </xsl:template>
  548. <!-- output the beginning revision graphic & ALT text -->
  549. <!-- Reverse the artwork for BIDI languages -->
  550. <xsl:template name="start-revision-flag">
  551. <xsl:param name="flagrules">
  552. <xsl:call-template name="getrules"/>
  553. </xsl:param>
  554. <xsl:variable name="biditest">
  555. <xsl:call-template name="bidi-area"/>
  556. </xsl:variable>
  557. <xsl:choose>
  558. <xsl:when test="$biditest='bidi'">
  559. <xsl:call-template name="end-revflagit">
  560. <xsl:with-param name="flagrules" select="$flagrules"/>
  561. </xsl:call-template>
  562. </xsl:when>
  563. <xsl:otherwise>
  564. <xsl:call-template name="start-revflagit">
  565. <xsl:with-param name="flagrules" select="$flagrules"/>
  566. </xsl:call-template>
  567. </xsl:otherwise>
  568. </xsl:choose>
  569. </xsl:template>
  570. <!-- output the ending revision graphic & ALT text -->
  571. <!-- Reverse the artwork for BIDI languages -->
  572. <xsl:template name="end-revision-flag">
  573. <xsl:param name="flagrules">
  574. <xsl:call-template name="getrules"/>
  575. </xsl:param>
  576. <xsl:variable name="biditest">
  577. <xsl:call-template name="bidi-area"/>
  578. </xsl:variable>
  579. <xsl:choose>
  580. <xsl:when test="$biditest='bidi'">
  581. <xsl:call-template name="start-revflagit">
  582. <xsl:with-param name="flagrules" select="$flagrules"/>
  583. </xsl:call-template>
  584. </xsl:when>
  585. <xsl:otherwise>
  586. <xsl:call-template name="end-revflagit">
  587. <xsl:with-param name="flagrules" select="$flagrules"/>
  588. </xsl:call-template>
  589. </xsl:otherwise>
  590. </xsl:choose>
  591. </xsl:template>
  592. <xsl:template name="end-revflagit">
  593. <xsl:param name="flagrules">
  594. <xsl:call-template name="getrules"/>
  595. </xsl:param>
  596. <xsl:apply-templates select="$flagrules/revprop[last()]" mode="end-revflagit"/>
  597. </xsl:template>
  598. <xsl:template match="*" mode="ditamsg:conflict-text-style-applied">
  599. <xsl:call-template name="output-message">
  600. <xsl:with-param name="id" select="'DOTX054W'"/>
  601. </xsl:call-template>
  602. </xsl:template>
  603. <!-- Test for in BIDI area: returns "bidi" when parent's @xml:lang is a bidi language;
  604. Otherwise, leave blank -->
  605. <xsl:template name="bidi-area">
  606. <xsl:param name="parentlang">
  607. <xsl:call-template name="getLowerCaseLang"/>
  608. </xsl:param>
  609. <xsl:variable name="direction">
  610. <xsl:apply-templates select="." mode="get-render-direction">
  611. <xsl:with-param name="lang" select="$parentlang"/>
  612. </xsl:apply-templates>
  613. </xsl:variable>
  614. <xsl:choose>
  615. <xsl:when test="$direction='rtl'">bidi</xsl:when>
  616. <xsl:otherwise/>
  617. </xsl:choose>
  618. </xsl:template>
  619. <!-- No flagging attrs allowed to process in phrases - output a message when in debug mode. -->
  620. <xsl:template name="flagcheck">
  621. <xsl:variable name="domains">
  622. <xsl:value-of select="normalize-space(ancestor-or-self::*[contains(@class,' topic/topic ')][1]/@domains)"/>
  623. </xsl:variable>
  624. <xsl:variable name="props">
  625. <xsl:if test="contains($domains, 'a(props')">
  626. <xsl:value-of select="normalize-space(substring-before(substring-after($domains,'a(props'), ')'))"/>
  627. </xsl:if>
  628. </xsl:variable>
  629. <xsl:if test="$DBG='yes' and not($FILTERFILE='')">
  630. <xsl:if test="@audience">
  631. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  632. <xsl:with-param name="attr-name" select="'audience'"/>
  633. </xsl:apply-templates>
  634. </xsl:if>
  635. <xsl:if test="@platform">
  636. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  637. <xsl:with-param name="attr-name" select="'platform'"/>
  638. </xsl:apply-templates>
  639. </xsl:if>
  640. <xsl:if test="@product">
  641. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  642. <xsl:with-param name="attr-name" select="'product'"/>
  643. </xsl:apply-templates>
  644. </xsl:if>
  645. <xsl:if test="@otherprops">
  646. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  647. <xsl:with-param name="attr-name" select="'otherprops'"/>
  648. </xsl:apply-templates>
  649. </xsl:if>
  650. <xsl:if test="not($props='')">
  651. <xsl:call-template name="ext-flagcheck">
  652. <xsl:with-param name="props" select="$props"/>
  653. </xsl:call-template>
  654. </xsl:if>
  655. </xsl:if>
  656. </xsl:template>
  657. <xsl:template name="ext-flagcheck">
  658. <xsl:param name="props"/>
  659. <xsl:choose>
  660. <xsl:when test="contains($props,',')">
  661. <xsl:variable name="propsValue">
  662. <xsl:call-template name="getPropsValue">
  663. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  664. </xsl:call-template>
  665. </xsl:variable>
  666. <xsl:variable name="propName">
  667. <xsl:call-template name="getLastPropName">
  668. <xsl:with-param name="propsPath" select="substring-before($props,',')"/>
  669. </xsl:call-template>
  670. </xsl:variable>
  671. <xsl:if test="not($propsValue='')">
  672. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  673. <xsl:with-param name="attr-name" select="$propName"/>
  674. </xsl:apply-templates>
  675. </xsl:if>
  676. <xsl:call-template name="ext-flagcheck">
  677. <xsl:with-param name="props" select="substring-after($props,',')"/>
  678. </xsl:call-template>
  679. </xsl:when>
  680. <xsl:otherwise>
  681. <xsl:variable name="propsValue">
  682. <xsl:call-template name="getPropsValue">
  683. <xsl:with-param name="propsPath" select="$props"/>
  684. </xsl:call-template>
  685. </xsl:variable>
  686. <xsl:variable name="propName">
  687. <xsl:call-template name="getLastPropName">
  688. <xsl:with-param name="propsPath" select="$props"/>
  689. </xsl:call-template>
  690. </xsl:variable>
  691. <xsl:if test="not($propsValue='')">
  692. <xsl:apply-templates select="." mode="ditamsg:cannot-flag-inline-element">
  693. <xsl:with-param name="attr-name" select="$propName"/>
  694. </xsl:apply-templates>
  695. </xsl:if>
  696. </xsl:otherwise>
  697. </xsl:choose>
  698. </xsl:template>
  699. <!-- ===================================================================== -->
  700. </xsl:stylesheet>