RSUpgradePostProcessing.xsl 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. * The input is a bering report specification. The output is a
  13. * cleaned up bering report specification.
  14. -->
  15. <xsl:stylesheet version="1.0" xmlns="http://developer.cognos.com/schemas/report/2.0/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:baltic="http://developer.cognos.com/schemas/report/1/" xmlns:bering="http://developer.cognos.com/schemas/report/2.0/" xmlns:date="http://exslt.org/dates-and-times" xmlns:exsl="http://exslt.org/common" xmlns:xalan="http://xml.apache.org/xalan" xmlns:java="http://xml.apache.org/xalan/java" extension-element-prefixes="xalan date exsl" exclude-result-prefixes="xalan java baltic date exsl">
  16. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" xalan:indent-amount="2" omit-xml-declaration="yes"/>
  17. <!--
  18. * Return the name of the query that is being used for the node.
  19. *
  20. * @param p_node Node to find the enclosing query for.
  21. -->
  22. <xsl:template name="getRefQuery">
  23. <xsl:param name="p_node"/>
  24. <xsl:choose>
  25. <xsl:when test="$p_node/@refQuery">
  26. <xsl:value-of select="$p_node/@refQuery"/>
  27. </xsl:when>
  28. <xsl:otherwise>
  29. <xsl:if test="$p_node/..">
  30. <xsl:call-template name="getRefQuery">
  31. <xsl:with-param name="p_node" select="$p_node/.."/>
  32. </xsl:call-template>
  33. </xsl:if>
  34. </xsl:otherwise>
  35. </xsl:choose>
  36. </xsl:template>
  37. <!-- Check if the node or its ancestor has as a child that is an asOfTime element.
  38. * If it does, and it is attached to the same query then do not ouput the asOfTime.
  39. * Otherwise output p_asOfTime.
  40. -->
  41. <xsl:template name="hasAsOfTime">
  42. <xsl:param name="p_node"/>
  43. <xsl:param name="p_refQuery"/>
  44. <xsl:param name="p_asOfTime"/>
  45. <xsl:choose>
  46. <xsl:when test="$p_node/bering:asOfTime">
  47. <xsl:variable name="v_nodeRefQuery">
  48. <xsl:call-template name="getRefQuery">
  49. <xsl:with-param name="p_node" select="$p_node/.."/>
  50. </xsl:call-template>
  51. </xsl:variable>
  52. <xsl:if test="not($v_nodeRefQuery = $p_refQuery)">
  53. <xsl:copy-of select="$p_asOfTime"/>
  54. </xsl:if>
  55. </xsl:when>
  56. <xsl:otherwise>
  57. <xsl:choose>
  58. <xsl:when test="$p_node/..">
  59. <xsl:call-template name="hasAsOfTime">
  60. <xsl:with-param name="p_node" select="$p_node/.."/>
  61. <xsl:with-param name="p_refQuery" select="$p_refQuery"/>
  62. <xsl:with-param name="p_asOfTime" select="$p_asOfTime"/>
  63. </xsl:call-template>
  64. </xsl:when>
  65. <xsl:otherwise>
  66. <xsl:copy-of select="$p_asOfTime"/>
  67. </xsl:otherwise>
  68. </xsl:choose>
  69. </xsl:otherwise>
  70. </xsl:choose>
  71. </xsl:template>
  72. <!--
  73. * Check that there is not already an enclosing element that has as a child an asOfTime element.
  74. -->
  75. <xsl:template match="bering:asOfTime">
  76. <xsl:comment>AsOfTime</xsl:comment>
  77. <xsl:variable name="v_refQuery">
  78. <xsl:call-template name="getRefQuery">
  79. <xsl:with-param name="p_node" select="."/>
  80. </xsl:call-template>
  81. </xsl:variable>
  82. <xsl:call-template name="hasAsOfTime">
  83. <xsl:with-param name="p_node" select="../.."/>
  84. <xsl:with-param name="p_refQuery" select="$v_refQuery"/>
  85. <xsl:with-param name="p_asOfTime" select="."/>
  86. </xsl:call-template>
  87. </xsl:template>
  88. <!-- sort the propertyItems so they compare the same
  89. * in test cases.
  90. -->
  91. <xsl:template match="bering:propertyList">
  92. <xsl:element name="propertyList">
  93. <xsl:apply-templates select="@*"/>
  94. <xsl:for-each select="./bering:propertyItem">
  95. <xsl:sort select="@refDataItem"/>
  96. <xsl:apply-templates select="."/>
  97. </xsl:for-each>
  98. <xsl:apply-templates select="bering:XMLAttributes"/>
  99. <xsl:apply-templates select="comment()"/>
  100. </xsl:element>
  101. </xsl:template>
  102. <!-- sort the reportVariable's so they compare the same
  103. * in test cases.
  104. -->
  105. <xsl:template match="bering:reportVariables">
  106. <xsl:element name="reportVariables">
  107. <xsl:apply-templates select="@*"/>
  108. <xsl:for-each select="./bering:reportVariable">
  109. <xsl:sort select="@name"/>
  110. <xsl:apply-templates select="."/>
  111. </xsl:for-each>
  112. <xsl:apply-templates select="bering:XMLAttributes"/>
  113. <xsl:apply-templates select="comment()"/>
  114. </xsl:element>
  115. </xsl:template>
  116. <!-- Remove the artificial 'originalRefQuery' attribute that does not
  117. belong to the v5 report specification.
  118. -->
  119. <xsl:template match="@originalRefQuery">
  120. </xsl:template>
  121. <!-- Remove the artificial 'originalRefItem' attribute that does not
  122. belong to the v5 report specification.
  123. -->
  124. <xsl:template match="@originalRefItem">
  125. </xsl:template>
  126. <!-- Remove the artifical 'originalRefLevel' attribute that does not
  127. belong to the v5 report specification.
  128. -->
  129. <xsl:template match="@originalRefLevel">
  130. </xsl:template>
  131. <!-- Remove the artificial 'layoutRefQuery' attribute that does not
  132. belong to the v5 report specification.
  133. -->
  134. <xsl:template match="@layoutRefQuery">
  135. </xsl:template>
  136. <!-- Remove the artificial 'querySet' element that does not
  137. belong to the v5 report specification.
  138. -->
  139. <xsl:template match="baltic:querySet">
  140. </xsl:template>
  141. <!-- Remove the artificial 'ret' element that does not
  142. belong to the v5 report specification.
  143. -->
  144. <xsl:template match="ret">
  145. </xsl:template>
  146. <!-- If maxCharacters is 0 then change it to have the CSS style
  147. * visibility: none.
  148. * See trakker 520732
  149. -->
  150. <xsl:template match="bering:textItem[./@maxCharacters &lt; 1 and not(./bering:style)]">
  151. <xsl:element name="textItem">
  152. <xsl:apply-templates select="@*[not(local-name()='maxCharacters')]"/>
  153. <xsl:element name="style">
  154. <xsl:element name="CSS">
  155. <xsl:attribute name="value">visibility:hidden</xsl:attribute>
  156. </xsl:element>
  157. </xsl:element>
  158. <xsl:apply-templates/>
  159. </xsl:element>
  160. </xsl:template>
  161. <xsl:template match="bering:textItem[./@maxCharacters &lt; 1 and ./bering:style]">
  162. <xsl:element name="textItem">
  163. <xsl:apply-templates select="@*[not(local-name()='maxCharacters')]"/>
  164. <xsl:apply-templates/>
  165. </xsl:element>
  166. </xsl:template>
  167. <xsl:template match="bering:textItem/bering:style[../@maxCharacters &lt; 1 and not(bering:CSS)]">
  168. <xsl:element name="style">
  169. <xsl:apply-templates select="@*"/>
  170. <xsl:element name="CSS">
  171. <xsl:attribute name="value">visibility:hidden</xsl:attribute>
  172. </xsl:element>
  173. <xsl:apply-templates/>
  174. </xsl:element>
  175. </xsl:template>
  176. <xsl:template match="bering:textItem/bering:style/bering:CSS/@value[../../../@maxCharacters &lt; 1]">
  177. <xsl:attribute name="value"><xsl:value-of select="."/>;visibility:hidden</xsl:attribute>
  178. </xsl:template>
  179. <!-- Copy anything that is unmatched over to output. -->
  180. <xsl:template match="@*|node()">
  181. <xsl:copy>
  182. <xsl:apply-templates select="@*|node()"/>
  183. </xsl:copy>
  184. </xsl:template>
  185. </xsl:stylesheet>