flag.xsl 26 KB

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