logupgrade_2.0.371.0.xsl 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. <!--
  11. =============================================================
  12. Action Log Upgrade 1.1.377.0 Notes:
  13. The level and hierarchy properties under a query subject have been renamed to _level and _hierarchy.
  14. This was done to avoid naming conflicts with the new level and hierarchy objects.
  15. ModifyComplex actions that modify either the level or hierarchy properties will be modified to modify
  16. the _level or _hierarchy properties.
  17. =============================================================
  18. -->
  19. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  20. <xsl:output method="xml" indent="yes"/>
  21. <!--root match -->
  22. <xsl:template match="/">
  23. <!--make sure that this transformation is performed on the correct version of FM Action Log -->
  24. <xsl:if test="not(/*[local-name() = 'bmtactionlog']) ">
  25. <xsl:message terminate="yes">The input file for this transformer must be a FM Action log. Exiting...</xsl:message>
  26. </xsl:if>
  27. <xsl:apply-templates/>
  28. </xsl:template>
  29. <!-- Default copy override: CData fix -->
  30. <xsl:template match="value/text()">
  31. <xsl:if test="name(.) = 'cdata'">
  32. <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
  33. <xsl:value-of disable-output-escaping="yes" select="."/>
  34. <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
  35. </xsl:if>
  36. <xsl:if test="not(name(.) = 'cdata')">
  37. <xsl:value-of disable-output-escaping="no" select="."/>
  38. </xsl:if>
  39. </xsl:template>
  40. <!-- general copy -->
  41. <xsl:template match="*">
  42. <xsl:element name="{name(.)}">
  43. <xsl:for-each select="@*">
  44. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  45. </xsl:for-each>
  46. <xsl:apply-templates select="node()"/>
  47. </xsl:element>
  48. </xsl:template>
  49. <!-- Change the actionlog version to latest version-->
  50. <xsl:template match="*[local-name()='bmtactionlog']">
  51. <xsl:element name="bmtactionlog">
  52. <xsl:for-each select="@*">
  53. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  54. </xsl:for-each>
  55. <!--Insert/Update the version tag-->
  56. <xsl:attribute name="version">2.0.377.0</xsl:attribute>
  57. <xsl:apply-templates select="node()"/>
  58. </xsl:element>
  59. </xsl:template>
  60. <!-- Helper function: Substring Replace-->
  61. <xsl:template name="substring-replace">
  62. <xsl:param name="string"/>
  63. <xsl:param name="search"/>
  64. <xsl:param name="replace"/>
  65. <xsl:choose>
  66. <xsl:when test="contains($string, $search)">
  67. <xsl:value-of select="concat(substring-before($string, $search), $replace)"/>
  68. <xsl:call-template name="substring-replace">
  69. <xsl:with-param name="string" select="substring-after($string, $search)"/>
  70. <xsl:with-param name="search" select="$search"/>
  71. <xsl:with-param name="replace" select="$replace"/>
  72. </xsl:call-template>
  73. </xsl:when>
  74. <xsl:otherwise>
  75. <xsl:value-of select="$string"/>
  76. </xsl:otherwise>
  77. </xsl:choose>
  78. </xsl:template>
  79. <!-- Action Log Upgrade 2.0.377.0: change level and hierarchy to _level and _hierarchy -->
  80. <xsl:template match="/bmtactionlog/transaction/action[@type = 'ModifyComplex']/inputparams/param[@seq='2']/value">
  81. <!-- standard copy -->
  82. <xsl:choose>
  83. <xsl:when test="contains(., '&lt;level&gt;')">
  84. <xsl:element name="value">
  85. <xsl:call-template name="substring-replace">
  86. <xsl:with-param name="string" select="."/>
  87. <xsl:with-param name="search" select="string('level&gt;')"/>
  88. <xsl:with-param name="replace" select="string('_level&gt;')"/>
  89. </xsl:call-template>
  90. </xsl:element>
  91. </xsl:when>
  92. <xsl:when test="contains(., '&lt;hierarchy&gt;')">
  93. <xsl:element name="value">
  94. <xsl:call-template name="substring-replace">
  95. <xsl:with-param name="string" select="."/>
  96. <xsl:with-param name="search" select="string('hierarchy&gt;')"/>
  97. <xsl:with-param name="replace" select="string('_hierarchy&gt;')"/>
  98. </xsl:call-template>
  99. </xsl:element>
  100. </xsl:when>
  101. <xsl:when test="contains(.,'&lt;functionSetID&gt;')">
  102. <xsl:variable name="newValue">
  103. <xsl:call-template name="substring-replace">
  104. <xsl:with-param name="string" select="."/>
  105. <xsl:with-param name="search">
  106. <xsl:text disable-output-escaping="no">&lt;functionSetID&gt;</xsl:text>
  107. </xsl:with-param>
  108. <xsl:with-param name="replace">
  109. <xsl:text disable-output-escaping="no">&lt;functionSet&gt;&lt;functionSetID&gt;</xsl:text>
  110. </xsl:with-param>
  111. </xsl:call-template>
  112. </xsl:variable>
  113. <xsl:variable name="newValue2">
  114. <xsl:call-template name="substring-replace">
  115. <xsl:with-param name="string" select="$newValue"/>
  116. <xsl:with-param name="search">
  117. <xsl:text disable-output-escaping="no">&lt;/functionSetID&gt;</xsl:text>
  118. </xsl:with-param>
  119. <xsl:with-param name="replace">
  120. <xsl:text disable-output-escaping="no">&lt;/functionSetID&gt;&lt;/functionSet&gt;</xsl:text>
  121. </xsl:with-param>
  122. </xsl:call-template>
  123. </xsl:variable>
  124. <xsl:element name="value">
  125. <xsl:value-of select="$newValue2" disable-output-escaping="no"/>
  126. </xsl:element>
  127. </xsl:when>
  128. <xsl:otherwise>
  129. <xsl:element name="{name(.)}">
  130. <xsl:for-each select="@*">
  131. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  132. </xsl:for-each>
  133. <xsl:apply-templates select="node()"/>
  134. </xsl:element>
  135. </xsl:otherwise>
  136. </xsl:choose>
  137. </xsl:template>
  138. </xsl:stylesheet>