logupgrade_1.1.74.0.xsl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: fmmd
  5. (C) Copyright IBM Corp. 2003, 2010
  6. US Government Users Restricted Rights - Use, duplication or disclosure
  7. restricted by GSA ADP Schedule Contract with IBM Corp.
  8. -->
  9. <!--XSLT version 1-->
  10. <!--Action Log Upgrade NOTES:
  11. There are 5 user gestures in FM 1.0 RTM that need to be upgraded to run in FM 1.1 GA
  12. (1) Give visibility rights - calls "SetObjectAccess" action
  13. first param - object that exists in the DOM parameter
  14. second param - the roles and rule specified.
  15. third param - "0" indicates not to do anything to the other role-based packages that exist in the model
  16. (2) Remove visibility rights - calls "SetObjectAccess" action
  17. first param - object that exists in the DOM parameter
  18. second param - the roles and rule specified.
  19. third param - "0" indicates not to do anything to the other role-based packages that exist in the model
  20. (3) Clear visibility rights - calls "Modify" action (on "secured" property, setting value to "unsecured").
  21. first param - ID of the object specified in the given property handle ID
  22. second param - the "Everyone" role, together with a rule of "unspecified".
  23. third param - "1" - indicates to remove the rule for any other role-based package as well.
  24. (4) Merge
  25. - drop the first input parameter
  26. - change the value of the last argument to 1
  27. (5) SetPromptValue
  28. - the type of the second argument has changed from string to ccl-node
  29. - example of the old one:
  30. <action seq="30" type="SetPromptValue">
  31. <inputparams>
  32. <param seq="1" type="i18nstring">
  33. <value>abc</value>
  34. </param>
  35. <param seq="2" type="i18nstring">
  36. <value>10</value>
  37. </param>
  38. </inputparams>
  39. ...
  40. </action>
  41. - the second param should change to:
  42. <param seq="2" type="cclnode">
  43. <value><![CDATA[<<item><name>abc</name><type>xsdString</type><value><item xsi:type="bus:simpleParmValueItem"><inclusive>true</inclusive><use>10</use></item></value></item>]]></value>
  44. </param>
  45. -->
  46. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  47. <xsl:output method="xml" indent="yes"/>
  48. <!--root match-->
  49. <xsl:template match="/">
  50. <!--make sure that this transformation is performed on a version 1.0 FM Action Log -->
  51. <xsl:if test="not(/*[local-name() = 'bmtactionlog']) ">
  52. <xsl:message terminate="yes">The input file for this transformer must be a FM Action log. Exiting...
  53. </xsl:message>
  54. </xsl:if>
  55. <xsl:if test="/*[local-name() = 'bmtactionlog']/@version">
  56. <xsl:message terminate="yes">The input file for this transformer must be a FM 1.0 Action log. Exiting...
  57. </xsl:message>
  58. </xsl:if>
  59. <xsl:apply-templates/>
  60. </xsl:template>
  61. <!-- Default copy override: CData fix -->
  62. <xsl:template match="value/text()">
  63. <xsl:if test="name(.) = 'cdata'">
  64. <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
  65. <xsl:value-of disable-output-escaping="yes" select="."/>
  66. <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
  67. </xsl:if>
  68. <xsl:if test="not(name(.) = 'cdata')">
  69. <xsl:value-of disable-output-escaping="no" select="."/>
  70. </xsl:if>
  71. </xsl:template>
  72. <!-- general copy -->
  73. <xsl:template match="*">
  74. <xsl:element name="{name(.)}">
  75. <xsl:for-each select="@*">
  76. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  77. </xsl:for-each>
  78. <xsl:apply-templates select="node()"/>
  79. </xsl:element>
  80. </xsl:template>
  81. <!-- Change the actionlog version to 1.1 version-->
  82. <xsl:template match="*[local-name()='bmtactionlog']">
  83. <xsl:element name="bmtactionlog">
  84. <xsl:for-each select="@*">
  85. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  86. </xsl:for-each>
  87. <!--Insert the version tag v1.0 (there is tag version tag for the FM 1.0 release) to 1.1-->
  88. <xsl:attribute name="version">1.1</xsl:attribute>
  89. <xsl:apply-templates select="node()"/>
  90. </xsl:element>
  91. </xsl:template>
  92. <!-- (1) & (2) Change the Transaction/action for objectaccess to reflect the 1.1 schema changes for adding removing visibility rights-->
  93. <xsl:template match="*[local-name()='action' and @type = 'SetObjectAccess']/inputparams/param">
  94. <xsl:call-template name="CDATA2ParamHandles">
  95. <xsl:with-param name="string" select="./value/text()"/>
  96. <xsl:with-param name="search" select="string('refobj=')"/>
  97. <xsl:with-param name="seq_val" select="1"/>
  98. <xsl:with-param name="cdata_str" select="./value/text()"/>
  99. </xsl:call-template>
  100. </xsl:template>
  101. <!-- Helper template for above: Generate the inputparams/param handles, param cclnode, and param integer using the MR1 param/value/CDATA -->
  102. <xsl:template name="CDATA2ParamHandles">
  103. <xsl:param name="string"/>
  104. <xsl:param name="search"/>
  105. <xsl:param name="seq_val"/>
  106. <xsl:param name="cdata_str"/>
  107. <xsl:if test="contains($string, $search)">
  108. <xsl:element name="param">
  109. <xsl:attribute name="seq"><xsl:value-of select="$seq_val"/></xsl:attribute>
  110. <xsl:attribute name="type">handle</xsl:attribute>
  111. <!-- NOTE: <mappingpath/> elements are optional as there is no mechanism to supply these values from 1.0RTM. The line below is commented out but there for completeness. -->
  112. <!--<xsl:element name="mappingpath">PLACEHOLDER</xsl:element> -->
  113. <xsl:element name="value">
  114. <xsl:value-of select="substring-before(substring-after(substring-after($string, $search), '&quot;'), '&quot;')"/>
  115. </xsl:element>
  116. </xsl:element>
  117. <!-- Recurse through the CDATA for the remaining list of param handles -->
  118. <xsl:call-template name="CDATA2ParamHandles">
  119. <xsl:with-param name="string" select="substring-after($string, $search)"/>
  120. <xsl:with-param name="search" select="$search"/>
  121. <xsl:with-param name="seq_val" select="number($seq_val+1)"/>
  122. <xsl:with-param name="cdata_str" select="$cdata_str"/>
  123. </xsl:call-template>
  124. </xsl:if>
  125. <xsl:if test="not(contains($string, $search))">
  126. <xsl:element name="param">
  127. <xsl:attribute name="seq"><xsl:value-of select="$seq_val"/></xsl:attribute>
  128. <xsl:attribute name="type">cclnode</xsl:attribute>
  129. <xsl:element name="value">
  130. <xsl:call-template name="CDATAreformat">
  131. <xsl:with-param name="cdata_str" select="$cdata_str"/>
  132. </xsl:call-template>
  133. </xsl:element>
  134. </xsl:element>
  135. <xsl:element name="param">
  136. <xsl:attribute name="seq"><xsl:value-of select="number($seq_val+1)"/></xsl:attribute>
  137. <xsl:attribute name="type">int</xsl:attribute>
  138. <xsl:element name="value">0</xsl:element>
  139. </xsl:element>
  140. </xsl:if>
  141. </xsl:template>
  142. <!-- Helper template for above: Reformat the CDATA element for FM 1.1-->
  143. <xsl:template name="CDATAreformat">
  144. <xsl:param name="cdata_str"/>
  145. <xsl:variable name="object" select="substring-before(substring-after($cdata_str, '&lt;object'), '&lt;/object&gt;')"/>
  146. <xsl:variable name="rule" select="substring-before(substring-after($object, 'rule=&quot;'), '&quot;')"/>
  147. <xsl:variable name="rule1">
  148. <xsl:call-template name="substring-replace">
  149. <xsl:with-param name="string" select="$rule"/>
  150. <xsl:with-param name="search" select="string('include')"/>
  151. <xsl:with-param name="replace" select="string('allow')"/>
  152. </xsl:call-template>
  153. </xsl:variable>
  154. <xsl:variable name="rule2">
  155. <xsl:call-template name="substring-replace">
  156. <xsl:with-param name="string" select="$rule1"/>
  157. <xsl:with-param name="search" select="string('hide')"/>
  158. <xsl:with-param name="replace" select="string('deny')"/>
  159. </xsl:call-template>
  160. </xsl:variable>
  161. <xsl:variable name="rule3" select="concat(concat(string('&lt;rule&gt;'), $rule2), string('&lt;/rule&gt;'))"/>
  162. <xsl:variable name="access" select="concat('&lt;access', substring-after($object, '&lt;access'))"/>
  163. <xsl:variable name="securityObject">
  164. <xsl:call-template name="substring-replace">
  165. <xsl:with-param name="string" select="$access"/>
  166. <xsl:with-param name="search" select="string('access')"/>
  167. <xsl:with-param name="replace" select="string('securityObject')"/>
  168. </xsl:call-template>
  169. </xsl:variable>
  170. <xsl:variable name="AddRules">
  171. <xsl:call-template name="substring-replace">
  172. <xsl:with-param name="string" select="$securityObject"/>
  173. <xsl:with-param name="search" select="string('/&gt;')"/>
  174. <xsl:with-param name="replace" select="concat(concat(string('&gt;'), $rule3), string('&lt;/securityObject&gt;'))"/>
  175. </xsl:call-template>
  176. </xsl:variable>
  177. <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
  178. <xsl:element name="objectAccess">
  179. <xsl:value-of disable-output-escaping="yes" select="$AddRules"/>
  180. </xsl:element>
  181. <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
  182. </xsl:template>
  183. <!-- (3) Convert the MR1 Transaction/action modify for removing visibility rights into a 11GA Transaction\action SetObjectAccess call -->
  184. <xsl:template match="*[local-name()='action' and @type = 'Modify']">
  185. <xsl:choose>
  186. <xsl:when test="contains(./inputparams/param/value, '/O/secured')">
  187. <xsl:variable name="handle" select="concat('[', substring-after(./inputparams/param/value, '/['))"/>
  188. <action seq="1" type="SetObjectAccess">
  189. <inputparams>
  190. <param seq="1" type="handle">
  191. <value>
  192. <xsl:value-of select="$handle"/>
  193. </value>
  194. </param>
  195. <param seq="2" type="cclnode">
  196. <value>
  197. <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
  198. <xsl:text disable-output-escaping="yes"><![CDATA[<objectAccess><securityObject type="role" displayPath="Everyone [Directory &gt; Cognos]" cmSearchPath="CAMID(&quot;::Everyone&quot;)"><rule>unspecified</rule></securityObject></objectAccess>]]></xsl:text>
  199. <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
  200. </value>
  201. </param>
  202. <param seq="3" type="int">
  203. <value>1</value>
  204. </param>
  205. </inputparams>
  206. <domchanges/>
  207. </action>
  208. </xsl:when>
  209. <xsl:otherwise>
  210. <!-- standard copy -->
  211. <xsl:element name="{name(.)}">
  212. <xsl:for-each select="@*">
  213. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  214. </xsl:for-each>
  215. <xsl:apply-templates select="node()"/>
  216. </xsl:element>
  217. </xsl:otherwise>
  218. </xsl:choose>
  219. </xsl:template>
  220. <!-- (4) Merge: drop the first input parameter and change the value of the last argument to 1 -->
  221. <xsl:template match="/bmtactionlog/transaction/action[@type = 'Merge']/inputparams">
  222. <xsl:element name="{name(.)}">
  223. <xsl:for-each select="param">
  224. <xsl:variable name="newseq">
  225. <xsl:number count="param[ not (@seq = '1')]"/>
  226. </xsl:variable>
  227. <xsl:choose>
  228. <xsl:when test="@seq = '1'">
  229. <!-- drop the first input param -->
  230. </xsl:when>
  231. <xsl:when test="@seq = last()">
  232. <!-- resequence last param and set it's value to one -->
  233. <xsl:element name="{name(.)}">
  234. <!-- resequence -->
  235. <xsl:attribute name="seq"><xsl:value-of select="$newseq"/></xsl:attribute>
  236. <xsl:attribute name="type">integer</xsl:attribute>
  237. <!-- set value to 1 -->
  238. <xsl:element name="value">1</xsl:element>
  239. </xsl:element>
  240. </xsl:when>
  241. <xsl:otherwise>
  242. <!-- resequence param -->
  243. <xsl:element name="{name(.)}">
  244. <!-- copy old -->
  245. <xsl:for-each select="@*">
  246. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  247. </xsl:for-each>
  248. <!-- resequence -->
  249. <xsl:attribute name="seq"><xsl:value-of select="$newseq"/></xsl:attribute>
  250. <xsl:apply-templates select="node()"/>
  251. </xsl:element>
  252. </xsl:otherwise>
  253. </xsl:choose>
  254. </xsl:for-each>
  255. </xsl:element>
  256. </xsl:template>
  257. <!-- (5) SetPromptValue: The type of the second argument has changed from string to cclnode-->
  258. <xsl:template match="/bmtactionlog/transaction/action[@type = 'SetPromptValue']/inputparams/param[@seq='2' and @type='i18nstring']">
  259. <xsl:element name="param">
  260. <xsl:attribute name="seq">2</xsl:attribute>
  261. <xsl:attribute name="type">cclnode</xsl:attribute>
  262. <xsl:element name="value">
  263. <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
  264. <xsl:text disable-output-escaping="yes"><![CDATA[<item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><name>]]></xsl:text>
  265. <xsl:value-of select="../param[@seq='1']/value"/>
  266. <xsl:text disable-output-escaping="yes"><![CDATA[</name><type>xsdString</type><value><item xsi:type="bus:simpleParmValueItem"><inclusive>true</inclusive><use>]]></xsl:text>
  267. <xsl:value-of select="./value"/>
  268. <xsl:text disable-output-escaping="yes"><![CDATA[</use></item></value></item>]]></xsl:text>
  269. <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
  270. </xsl:element>
  271. </xsl:element>
  272. </xsl:template>
  273. <!-- Helper function: Substring Replace-->
  274. <xsl:template name="substring-replace">
  275. <xsl:param name="string"/>
  276. <xsl:param name="search"/>
  277. <xsl:param name="replace"/>
  278. <xsl:choose>
  279. <xsl:when test="contains($string, $search)">
  280. <xsl:value-of select="concat(substring-before($string, $search), $replace)"/>
  281. <xsl:call-template name="substring-replace">
  282. <xsl:with-param name="string" select="substring-after($string, $search)"/>
  283. <xsl:with-param name="search" select="$search"/>
  284. <xsl:with-param name="replace" select="$replace"/>
  285. </xsl:call-template>
  286. </xsl:when>
  287. <xsl:otherwise>
  288. <xsl:value-of select="$string"/>
  289. </xsl:otherwise>
  290. </xsl:choose>
  291. </xsl:template>
  292. </xsl:stylesheet>