RSUpgradePageSet.xsl 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. <!--
  13. * Detailed mappings for pageSet upgrade:
  14. *
  15. * layout[not(@refQuery)]/pageSet/page -> layout/reportPages/page
  16. *
  17. * NOTE: Since each pageSet actually maps to a pageOverallGroup, pageGroup or detailPages element,
  18. * which have no corresponding attributes, the resetPageNumber and resetPageCount attributes of the v4 pageSet
  19. * will be set on the first page of the corresponding group.
  20. * pageSet/@resetPageNumber -> page/@resetPageNumber
  21. * pageSet/@resetPageCount -> page/@resetPageCount
  22. *
  23. * layout[@refQuery]/pageSet[not(@refLevel)]/headerPageList -> layout/ReportPages/pageSet/pageOverallGroup/headerPages
  24. * layout[@refQuery]/pageSet[not(@refLevel)]/footerPageList -> layout/ReportPages/pageSet/pageOverallGroup/footerPages
  25. * layout[@refQuery]/pageSet[not(@refLevel)]/page -> layout/ReportPages/pageSet/detailPages/page
  26. *
  27. * A pageGroup is generated for each query level up to (and including) the innermost pageSet.
  28. * layout[@refQuery]/pageSet[@refLevel] -> layout/ReportPages/pageSet/pageGroups/pageGroup
  29. *
  30. * Header and footer pages for a given level go to the corresponding pageGroup
  31. * layout[@refQuery]/pageSet[@refLevel]/headerPageList -> layout/ReportPages/pageSet/pageGroups/pageGroup/headerPages
  32. * layout[@refQuery]/pageSet[@refLevel]/footerPageList -> layout/ReportPages/pageSet/pageGroups/pageGroup/footerPages
  33. *
  34. * Only the pageSet for the innermost level has detail pages.
  35. * The pageSets for the outermost levels only have header and footer page lists.
  36. * layout[@refQuery]/pageSet[@refLevel and last()]/page -> layout/ReportPages/pageSet/detailPages/page
  37. *
  38. -->
  39. <xsl:template name="reportPagesTemplate">
  40. <!--The current context must be "baltic:layout". -->
  41. <xsl:if test="./node()">
  42. <reportPages>
  43. <xsl:choose>
  44. <xsl:when test="count(@refQuery) = 1 and @refQuery != ''">
  45. <pageSet name="pageSet1">
  46. <!-- Get the refQuery attribute of the baltic:layout element. -->
  47. <xsl:variable name="var_beringRefQuery">
  48. <xsl:call-template name="getQueryTemplate">
  49. <xsl:with-param name="refQuery" select="@refQuery"/>
  50. </xsl:call-template>
  51. </xsl:variable>
  52. <xsl:attribute name="refQuery"><xsl:value-of select="$var_beringRefQuery"/></xsl:attribute>
  53. <!-- originalRefQuery is used by the property list adjuster and will be removed later on. -->
  54. <xsl:attribute name="originalRefQuery"><xsl:value-of select="@refQuery"/></xsl:attribute>
  55. <xsl:if test="baltic:pageSet/@resetPageNumber">
  56. <xsl:call-template name="resetPageTemplate">
  57. <xsl:with-param name="attribute" select="baltic:pageSet/@resetPageNumber"/>
  58. <xsl:with-param name="targetName" select="'resetPageNumber'"/>
  59. </xsl:call-template>
  60. </xsl:if>
  61. <xsl:if test="baltic:pageSet/@resetPageCount">
  62. <xsl:call-template name="resetPageTemplate">
  63. <xsl:with-param name="attribute" select="baltic:pageSet/@resetPageCount"/>
  64. <xsl:with-param name="targetName" select="'resetPageCount'"/>
  65. </xsl:call-template>
  66. </xsl:if>
  67. <xsl:call-template name="pageOverallGroupTemplate"/>
  68. <xsl:call-template name="pageGroupsTemplate"/>
  69. <xsl:call-template name="detailPagesTemplate"/>
  70. <xsl:call-template name="generateMasterDetailLinks2">
  71. <xsl:with-param name="p_frame" select="."/>
  72. </xsl:call-template>
  73. <xsl:variable name="v_cube">
  74. <xsl:call-template name="getCube">
  75. <xsl:with-param name="p_queryName" select="@refQuery"/>
  76. </xsl:call-template>
  77. </xsl:variable>
  78. <xsl:element name="propertyList"/>
  79. </pageSet>
  80. </xsl:when>
  81. <xsl:otherwise>
  82. <xsl:apply-templates select="baltic:pageSet" mode="detail"/>
  83. </xsl:otherwise>
  84. </xsl:choose>
  85. </reportPages>
  86. </xsl:if>
  87. </xsl:template>
  88. <xsl:template name="pageOverallGroupTemplate">
  89. <xsl:apply-templates select="baltic:pageSet[not(@refLevel)]"/>
  90. </xsl:template>
  91. <xsl:template name="pageGroupsTemplate">
  92. <!-- The structure of the V5 page grouping is derived from the V4 Cube Dimension Levels. -->
  93. <xsl:variable name="var_refQuery" select="@refQuery"/>
  94. <xsl:apply-templates select="/baltic:report/baltic:querySet/baltic:BIQuery[@name=$var_refQuery]" mode="pageSet">
  95. <xsl:with-param name="p_layout" select="."/>
  96. <xsl:with-param name="p_refLevel">
  97. <xsl:value-of select="baltic:pageSet[last()]/@refLevel"/>
  98. </xsl:with-param>
  99. </xsl:apply-templates>
  100. </xsl:template>
  101. <xsl:template name="detailPagesTemplate">
  102. <detailPages>
  103. <xsl:apply-templates select="baltic:pageSet[@refLevel and last()]" mode="detail"/>
  104. <xsl:apply-templates select="baltic:pageSet[not(@refLevel)]" mode="detail"/>
  105. </detailPages>
  106. </xsl:template>
  107. <xsl:template match="baltic:layout[@refQuery]/baltic:pageSet[not(@refLevel)]">
  108. <pageOverallGroup>
  109. <xsl:variable name="var_refQuery">
  110. <xsl:call-template name="getRefQuery">
  111. <xsl:with-param name="p_frame" select="."/>
  112. </xsl:call-template>
  113. </xsl:variable>
  114. <!-- originalRefQuery is used by the property list adjuster and will be removed later on. -->
  115. <xsl:attribute name="originalRefQuery"><xsl:value-of select="$var_refQuery"/></xsl:attribute>
  116. <xsl:apply-templates select="baltic:headerPageList"/>
  117. <xsl:apply-templates select="baltic:footerPageList"/>
  118. <xsl:element name="propertyList"/>
  119. </pageOverallGroup>
  120. </xsl:template>
  121. <xsl:template match="baltic:layout[@refQuery]/baltic:pageSet[@refLevel]">
  122. <xsl:apply-templates select="baltic:headerPageList"/>
  123. <xsl:apply-templates select="baltic:footerPageList"/>
  124. </xsl:template>
  125. <xsl:template match="baltic:pageSet" mode="detail">
  126. <xsl:call-template name="pageTemplate"/>
  127. </xsl:template>
  128. <xsl:template match="baltic:headerPageList">
  129. <headerPages>
  130. <xsl:call-template name="pageTemplate"/>
  131. </headerPages>
  132. </xsl:template>
  133. <xsl:template match="baltic:footerPageList">
  134. <footerPages>
  135. <xsl:call-template name="pageTemplate"/>
  136. </footerPages>
  137. </xsl:template>
  138. <xsl:template name="pageTemplate">
  139. <xsl:apply-templates select="baltic:page[1]">
  140. <xsl:with-param name="p_resetPageNumber">
  141. <xsl:choose>
  142. <xsl:when test="@resetPageNumber">
  143. <xsl:value-of select="@resetPageNumber"/>
  144. </xsl:when>
  145. <xsl:when test="../@resetPageNumber">
  146. <!--From the parent pageSet -->
  147. <xsl:value-of select="../@resetPageNumber"/>
  148. </xsl:when>
  149. <xsl:otherwise>
  150. <xsl:value-of select="''"/>
  151. </xsl:otherwise>
  152. </xsl:choose>
  153. </xsl:with-param>
  154. <xsl:with-param name="p_resetPageCount">
  155. <xsl:choose>
  156. <xsl:when test="@resetPageCount">
  157. <xsl:value-of select="@resetPageCount"/>
  158. </xsl:when>
  159. <xsl:when test="../@resetPageCount">
  160. <!--From the parent pageSet -->
  161. <xsl:value-of select="../@resetPageCount"/>
  162. </xsl:when>
  163. <xsl:otherwise>
  164. <xsl:value-of select="''"/>
  165. </xsl:otherwise>
  166. </xsl:choose>
  167. </xsl:with-param>
  168. </xsl:apply-templates>
  169. <xsl:apply-templates select="baltic:page[position() &gt; 1]"/>
  170. </xsl:template>
  171. <xsl:template match="/baltic:report/baltic:querySet/baltic:BIQuery" mode="pageSet">
  172. <xsl:param name="p_layout"/>
  173. <xsl:param name="p_refLevel"/>
  174. <xsl:variable name="var_cube">
  175. <xsl:call-template name="getCubeOrCubeReference"/>
  176. </xsl:variable>
  177. <xsl:variable name="var_pageGroups">
  178. <xsl:for-each select="$var_cube/baltic:cube/baltic:dimension/baltic:level[@name=$p_refLevel]/preceding-sibling::baltic:level">
  179. <xsl:apply-templates select="." mode="pageSet">
  180. <xsl:with-param name="p_layout" select="$p_layout"/>
  181. </xsl:apply-templates>
  182. </xsl:for-each>
  183. <xsl:apply-templates select="$var_cube/baltic:cube/baltic:dimension/baltic:level[@name=$p_refLevel]" mode="pageSet">
  184. <xsl:with-param name="p_layout" select="$p_layout"/>
  185. </xsl:apply-templates>
  186. </xsl:variable>
  187. <xsl:if test="count($var_cube/baltic:cube/baltic:dimension/baltic:level[@name=$p_refLevel]) &gt; 0">
  188. <pageGroups>
  189. <xsl:copy-of select="$var_pageGroups"/>
  190. </pageGroups>
  191. </xsl:if>
  192. <!-- Generate the sortList from the baltic:cube/baltic:factList/baltic:item sort attributes. -->
  193. <sortList>
  194. <xsl:apply-templates select="$var_cube/baltic:cube/baltic:factList/baltic:item" mode="generate_sortItems"/>
  195. </sortList>
  196. </xsl:template>
  197. <xsl:template match="baltic:cube/baltic:dimension/baltic:level" mode="pageSet">
  198. <xsl:param name="p_layout"/>
  199. <xsl:variable name="var_refLevel" select="@name"/>
  200. <xsl:variable name="v_refDataItem">
  201. <xsl:call-template name="getKeyItemNameForLevel"/>
  202. </xsl:variable>
  203. <xsl:choose>
  204. <xsl:when test="$v_refDataItem='ERROR: Cannot find item or dataItem for the level referenced.'">
  205. <xsl:comment>
  206. <xsl:call-template name="logError2">
  207. <xsl:with-param name="p_msgId" select="'RSU_SPC_LEVEL_KEYITEM_MISSING'"/>
  208. <xsl:with-param name="p_param1" select="'pageGroup'"/>
  209. <xsl:with-param name="p_param2" select="$var_refLevel"/>
  210. </xsl:call-template>
  211. </xsl:comment>
  212. </xsl:when>
  213. <xsl:otherwise>
  214. <pageGroup refDataItem="{$v_refDataItem}">
  215. <!-- Generate headerPages and footerPages from the baltic:pageSet with a matching refLevel attribute. -->
  216. <xsl:apply-templates select="$p_layout/baltic:pageSet[@refLevel=$var_refLevel]"/>
  217. <!-- Generate sortList from the baltic:item sort attributes up to this level in the current dimension. -->
  218. <sortList>
  219. <xsl:apply-templates select="baltic:item" mode="generate_sortItems"/>
  220. </sortList>
  221. <xsl:element name="propertyList"/>
  222. </pageGroup>
  223. </xsl:otherwise>
  224. </xsl:choose>
  225. </xsl:template>
  226. </xsl:stylesheet>