RSUpgradeV5Layout.xsl 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: rspecupgrade
  5. (C) Copyright IBM Corp. 2005, 2010
  6. US Government Users Restricted Rights - Use, duplication or disclosure
  7. restricted by GSA ADP Schedule Contract with IBM Corp.
  8. -->
  9. <!-- COPYRIGHT_DATA { 'YEAR':[2005, 2009], 'RELEASE':['colorado_wave1'], 'VISIBLE':'YES', 'COMPONENT':'rspecupgrade' }-->
  10. <!--All lines above the COPYRIGHT_DATA line will be replaced when copyright notices are generated. -->
  11. <!--
  12. *
  13. * This stylesheet upgrades the V5 report layout.
  14. *
  15. * WO1730 - Fix solve order of summaries in cross-tabs:
  16. *
  17. * + Update the solveOrder attribute of crosstabNodeMembers based on the corresponding QRD valueSet solveOrder attribute.
  18. * + Remove name attributes from the crosstabNodeMember and defaultMeasure elements. Those attributes were added
  19. * for the sole purpose of mapping QRD valueSet elements back to their corresponding layout elements.
  20. * They are NOT part of the V5 spec.
  21. * + Remove the queryResultDefinitions from the report element. The QRD was added to the report element as an interim
  22. * upgrade step and must be removed.
  23. *
  24. -->
  25. <xsl:stylesheet version="1.0" xmlns:v5="http://developer.cognos.com/schemas/report/2.0/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://developer.cognos.com/schemas/report/2.0/" exclude-result-prefixes="xsl xs xsi v5">
  26. <xsl:output method="xml" encoding="utf-8"/>
  27. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  28. <!-- Keep a map of valueSet elements keyed by the name attribute. -->
  29. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  30. <xsl:key name="valueSet" match="v5:valueSet" use="@name"/>
  31. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  32. <!-- Copy all attributes of the current node, except for annotation attributes that must be stripped out. -->
  33. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  34. <xsl:template name="copyAttributes">
  35. <xsl:for-each select="attribute::*">
  36. <!--Strip out the name attribute. It is not part of V5.-->
  37. <xsl:if test="local-name(.) != 'name'">
  38. <xsl:copy/>
  39. </xsl:if>
  40. </xsl:for-each>
  41. </xsl:template>
  42. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  43. <!-- Copy all attributes of the current node, except for annotation attributes that must be stripped out. -->
  44. <!-- Change the value of the solveOrder attribute to that of p_solveOrder. -->
  45. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  46. <xsl:template name="changeSolveOrder">
  47. <xsl:param name="p_solveOrder"/>
  48. <xsl:for-each select="attribute::*">
  49. <xsl:choose>
  50. <xsl:when test="local-name(.) = 'solveOrder'">
  51. <!-- Change the value of the solveOrder attribute. -->
  52. <xsl:attribute name="solveOrder">
  53. <xsl:value-of select="$p_solveOrder"/>
  54. </xsl:attribute>
  55. </xsl:when>
  56. <xsl:when test="local-name(.) = 'name'">
  57. <!-- Strip out the name attribute. It is not part of V5. -->
  58. </xsl:when>
  59. <xsl:otherwise>
  60. <!-- Copy all other attributes. -->
  61. <xsl:copy/>
  62. </xsl:otherwise>
  63. </xsl:choose>
  64. </xsl:for-each>
  65. </xsl:template>
  66. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  67. <!-- Using v_name as the key, get the value of the solveOrder attribute of a valueSet element. -->
  68. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  69. <xsl:template name="getValueSetSolveOrder">
  70. <xsl:variable name="v_name">
  71. <xsl:value-of select="@name"/>
  72. </xsl:variable>
  73. <xsl:value-of select="key('valueSet', $v_name)[1]/@solveOrder"/>
  74. </xsl:template>
  75. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  76. <!-- Update the solveOrder attribute of the current element based on the corresponding QRD valueSet solveOrder attribute. -->
  77. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  78. <xsl:template name="upgradeCrosstabAttributes">
  79. <xsl:variable name="valueSet_solveOrder">
  80. <xsl:call-template name="getValueSetSolveOrder"/>
  81. </xsl:variable>
  82. <xsl:choose>
  83. <xsl:when test="$valueSet_solveOrder = ''">
  84. <!-- The valueSet does not have a solveOrder specified. -->
  85. <!-- Just copy the existing attributes over. -->
  86. <xsl:call-template name="copyAttributes"/>
  87. </xsl:when>
  88. <xsl:when test="@solveOrder">
  89. <!-- Both the valueSet and the current element have the solveOrder attribute specified. -->
  90. <!-- Copy the existing attributes over, but change the value of the solveOrder attribute. -->
  91. <xsl:call-template name="changeSolveOrder">
  92. <xsl:with-param name="p_solveOrder" select="$valueSet_solveOrder"/>
  93. </xsl:call-template>
  94. </xsl:when>
  95. <xsl:otherwise>
  96. <!-- Only the valueSet has the solveOrder attribute specified. -->
  97. <!-- Add the solveOrder attribute to the current element. -->
  98. <xsl:call-template name="copyAttributes"/>
  99. <xsl:attribute name="solveOrder">
  100. <xsl:value-of select="$valueSet_solveOrder"/>
  101. </xsl:attribute>
  102. </xsl:otherwise>
  103. </xsl:choose>
  104. </xsl:template>
  105. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  106. <!-- Upgrade the crosstab/defaultMeasure element. -->
  107. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  108. <xsl:template match="v5:defaultMeasure">
  109. <xsl:copy>
  110. <xsl:call-template name="upgradeCrosstabAttributes"/>
  111. <xsl:apply-templates select="node()"/>
  112. </xsl:copy>
  113. </xsl:template>
  114. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  115. <!-- Upgrade the crosstabNodeMember element. -->
  116. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  117. <xsl:template match="v5:crosstabNodeMember">
  118. <xsl:copy>
  119. <xsl:call-template name="upgradeCrosstabAttributes"/>
  120. <xsl:apply-templates select="node()"/>
  121. </xsl:copy>
  122. </xsl:template>
  123. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  124. <!-- Strip out queryResultDefinitions. -->
  125. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  126. <xsl:template match="v5:queryResultDefinitions">
  127. </xsl:template>
  128. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  129. <!-- Copy all nodes and attributes by default. -->
  130. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  131. <xsl:template match="@*|node()">
  132. <xsl:copy>
  133. <xsl:apply-templates select="@*|node()"/>
  134. </xsl:copy>
  135. </xsl:template>
  136. </xsl:stylesheet>