RSUpgradeLayout.xsl 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:baltic="http://developer.cognos.com/schemas/report/1/" xmlns="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">
  12. <xsl:variable name="v_asOfTime">
  13. <xsl:if test="count(/baltic:report/baltic:asOfTime)">
  14. <asOfTime>
  15. <xsl:apply-templates select="comment()"/>
  16. <!-- Harvest comments in case there were expression parsing errors. -->
  17. <xsl:apply-templates select="/baltic:report/baltic:asOfTime/baltic:expression"/>
  18. </asOfTime>
  19. </xsl:if>
  20. </xsl:variable>
  21. <xsl:template match="baltic:layoutList[@refVariable]">
  22. <layouts>
  23. <!-- Default layout. -->
  24. <xsl:apply-templates select="baltic:layout[not(@refVariableValue)]"/>
  25. <!-- Conditional layouts. -->
  26. <xsl:if test="count(baltic:layout[@refVariableValue]) &gt; 0">
  27. <xsl:variable name="v_refVariableExists">
  28. <xsl:call-template name="checkRefVariableTemplate"/>
  29. </xsl:variable>
  30. <xsl:if test="$v_refVariableExists = 'true'">
  31. <conditionalLayouts>
  32. <xsl:attribute name="refVariable"><xsl:value-of select="@refVariable"/></xsl:attribute>
  33. <xsl:apply-templates select="baltic:layout[@refVariableValue]"/>
  34. </conditionalLayouts>
  35. </xsl:if>
  36. </xsl:if>
  37. </layouts>
  38. </xsl:template>
  39. <xsl:template match="baltic:layoutList[not(@refVariable)]">
  40. <layouts>
  41. <xsl:apply-templates select="baltic:layout[not(@refVariableValue)]"/>
  42. </layouts>
  43. </xsl:template>
  44. <xsl:template match="baltic:layout[@refVariableValue]">
  45. <conditionalLayout>
  46. <xsl:attribute name="refVariableValue"><xsl:value-of select="@refVariableValue"/></xsl:attribute>
  47. <xsl:call-template name="layoutCommonTemplate"/>
  48. </conditionalLayout>
  49. </xsl:template>
  50. <xsl:template match="baltic:layout[not(@refVariableValue)]">
  51. <layout>
  52. <xsl:call-template name="layoutCommonTemplate"/>
  53. </layout>
  54. </xsl:template>
  55. <xsl:template name="layoutCommonTemplate">
  56. <!-- NOTE: The name, localeList, id and class attributes of the V4 layout element are dropped. -->
  57. <!-- NOTE: The V4 refQuery attribute of the layout moves down to the V5 pageSet element. -->
  58. <!-- NOTE: Adding attribute "layoutRefQuery" as a temporary annotation to the v5 layout element
  59. to help the upgrade keep track of the query context for prompt pages.
  60. This temporary attribute will be removed by the RSUpgradePostProcessing.xsl stylesheet. -->
  61. <xsl:call-template name="addAttr">
  62. <xsl:with-param name="p_name" select="'refQuery'"/>
  63. <xsl:with-param name="p_newName" select="'layoutRefQuery'"/>
  64. </xsl:call-template>
  65. <xsl:call-template name="reportPagesTemplate"/>
  66. <xsl:apply-templates select="baltic:promptPageList"/>
  67. <xsl:if test="count(baltic:pageSetup) &gt; 1">
  68. <xsl:comment>
  69. <xsl:call-template name="logWarning2">
  70. <xsl:with-param name="p_msgId" select="'RSU_SPC_EXTRA_ELEMENTS_IGNORED'"/>
  71. <xsl:with-param name="p_param1" select="'pageSetup'"/>
  72. <xsl:with-param name="p_param2" select="'layout'"/>
  73. </xsl:call-template>
  74. </xsl:comment>
  75. </xsl:if>
  76. <xsl:apply-templates select="baltic:pageSetup[1]"/>
  77. <xsl:call-template name="defaultDataFormatsTemplate"/>
  78. </xsl:template>
  79. <xsl:template name="layoutContainerTemplate">
  80. <xsl:param name="p_cur" select="."/>
  81. <xsl:call-template name="layoutContainerGroupTemplate">
  82. <xsl:with-param name="p_cur" select="$p_cur"/>
  83. </xsl:call-template>
  84. <xsl:call-template name="simpleLayoutGroupTemplate">
  85. <xsl:with-param name="p_cur" select="$p_cur"/>
  86. </xsl:call-template>
  87. </xsl:template>
  88. <xsl:template name="layoutContainerGroupTemplate">
  89. <xsl:param name="p_cur" select="."/>
  90. <contents>
  91. <xsl:copy-of select="$v_asOfTime"/>
  92. <xsl:call-template name="layoutContainerGroupNoContentsTemplate">
  93. <xsl:with-param name="p_cur" select="$p_cur"/>
  94. </xsl:call-template>
  95. </contents>
  96. </xsl:template>
  97. <xsl:template name="layoutContainerGroupNoContentsTemplate">
  98. <xsl:param name="p_cur" select="."/>
  99. <xsl:for-each select="$p_cur/*">
  100. <xsl:choose>
  101. <xsl:when test="namespace-uri(.) = 'http://cognos.com/rspecupgrade/passthrough/'">
  102. <xsl:copy-of select="."/>
  103. </xsl:when>
  104. <xsl:when test="local-name(.) = 'list'">
  105. <xsl:apply-templates select="."/>
  106. </xsl:when>
  107. <xsl:when test="local-name(.) = 'crosstab'">
  108. <xsl:apply-templates select="."/>
  109. </xsl:when>
  110. <xsl:when test="local-name(.) = 'chart'">
  111. <xsl:apply-templates select="."/>
  112. </xsl:when>
  113. <xsl:when test="local-name(.) = 'repeater'">
  114. <xsl:apply-templates select="."/>
  115. </xsl:when>
  116. <xsl:when test="local-name(.) = 'layoutComponentRef'">
  117. <xsl:apply-templates select="."/>
  118. </xsl:when>
  119. <xsl:when test="local-name(.) = 'fieldSet'">
  120. <xsl:apply-templates select="."/>
  121. </xsl:when>
  122. <xsl:when test="local-name(.) = 'table'">
  123. <xsl:apply-templates select="."/>
  124. </xsl:when>
  125. <xsl:when test="local-name(.) = 'block'">
  126. <xsl:apply-templates select="."/>
  127. </xsl:when>
  128. <xsl:when test="local-name(.) = 'conditionalBlockList'">
  129. <xsl:apply-templates select="."/>
  130. </xsl:when>
  131. <xsl:when test="local-name(.) = 'textItem'">
  132. <xsl:apply-templates select="."/>
  133. </xsl:when>
  134. <xsl:when test="local-name(.) = 'image'">
  135. <xsl:apply-templates select="."/>
  136. </xsl:when>
  137. <xsl:when test="local-name(.) = 'hyperlink'">
  138. <xsl:apply-templates select="."/>
  139. </xsl:when>
  140. <xsl:when test="local-name(.) = 'button'">
  141. <xsl:apply-templates select="."/>
  142. </xsl:when>
  143. <xsl:when test="local-name(.) = 'promptButton'">
  144. <xsl:apply-templates select="."/>
  145. </xsl:when>
  146. <xsl:when test="local-name(.) = 'HTMLItem'">
  147. <xsl:apply-templates select="."/>
  148. </xsl:when>
  149. <xsl:when test="local-name(.) = 'XMLItem'">
  150. <xsl:apply-templates select="."/>
  151. </xsl:when>
  152. <xsl:when test="local-name(.) = 'bookmark'">
  153. <xsl:apply-templates select="."/>
  154. </xsl:when>
  155. <xsl:when test="local-name(.) = 'textBox'">
  156. <xsl:apply-templates select="."/>
  157. </xsl:when>
  158. <xsl:when test="local-name(.) = 'selectValue'">
  159. <xsl:apply-templates select="."/>
  160. </xsl:when>
  161. <xsl:when test="local-name(.) = 'selectWithSearch'">
  162. <xsl:apply-templates select="."/>
  163. </xsl:when>
  164. <xsl:when test="local-name(.) = 'selectDate'">
  165. <xsl:apply-templates select="."/>
  166. </xsl:when>
  167. <xsl:when test="local-name(.) = 'selectTime'">
  168. <xsl:apply-templates select="."/>
  169. </xsl:when>
  170. <xsl:when test="local-name(.) = 'selectDateTime'">
  171. <xsl:apply-templates select="."/>
  172. </xsl:when>
  173. <xsl:when test="local-name(.) = 'selectInterval'">
  174. <xsl:apply-templates select="."/>
  175. </xsl:when>
  176. <xsl:when test="local-name(.) = 'generatedPrompt'">
  177. <xsl:apply-templates select="."/>
  178. </xsl:when>
  179. </xsl:choose>
  180. </xsl:for-each>
  181. </xsl:template>
  182. <xsl:template name="simpleLayoutGroupTemplate">
  183. <xsl:param name="p_cur" select="."/>
  184. <xsl:param name="p_recursive"/>
  185. <xsl:param name="p_addValue" select="''"/>
  186. <xsl:param name="p_prependValue" select="''"/>
  187. <xsl:choose>
  188. <xsl:when test="not($p_cur/baltic:style[1]) and $p_addValue != ''">
  189. <style>
  190. <CSS>
  191. <xsl:attribute name="value"><xsl:value-of select="$p_addValue"/></xsl:attribute>
  192. </CSS>
  193. </style>
  194. </xsl:when>
  195. <xsl:when test="not($p_cur/baltic:style[1]) and $p_prependValue != ''">
  196. <style>
  197. <CSS>
  198. <xsl:attribute name="value"><xsl:value-of select="$p_prependValue"/></xsl:attribute>
  199. </CSS>
  200. </style>
  201. </xsl:when>
  202. <xsl:otherwise>
  203. <xsl:apply-templates select="$p_cur/baltic:style[1]">
  204. <xsl:with-param name="p_recursive" select="$p_recursive"/>
  205. <xsl:with-param name="p_addValue" select="$p_addValue"/>
  206. <xsl:with-param name="p_prependValue" select="$p_prependValue"/>
  207. </xsl:apply-templates>
  208. </xsl:otherwise>
  209. </xsl:choose>
  210. <xsl:if test="count($p_cur/baltic:XMLAttribute) &gt; 0">
  211. <xsl:variable name="var_XMLAttributes">
  212. <xsl:apply-templates select="$p_cur/baltic:XMLAttribute"/>
  213. </xsl:variable>
  214. <XMLAttributes>
  215. <xsl:copy-of select="$var_XMLAttributes"/>
  216. </XMLAttributes>
  217. </xsl:if>
  218. <xsl:apply-templates select="$p_cur/baltic:conditionalStyle[1]">
  219. <xsl:with-param name="p_recursive" select="$p_recursive"/>
  220. </xsl:apply-templates>
  221. </xsl:template>
  222. <xsl:template name="defaultDataFormatsTemplate">
  223. <defaultDataFormats>
  224. <xsl:apply-templates select="baltic:style" mode="defaultDataFormats"/>
  225. </defaultDataFormats>
  226. </xsl:template>
  227. <xsl:template match="baltic:style" mode="defaultDataFormats">
  228. <xsl:call-template name="formatGroupTemplate">
  229. <xsl:with-param name="p_includeDataFormatElement" select="'false'"/>
  230. </xsl:call-template>
  231. </xsl:template>
  232. </xsl:stylesheet>