RSUpgradeMasterDetail.xsl 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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:bering="http://developer.cognos.com/schemas/report/2.0/" 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. * Generate the master detail links for a frame.
  14. *
  15. * p_frame Frame we are generating the links for.
  16. -->
  17. <xsl:template name="generateMasterDetailLinks2">
  18. <xsl:param name="p_frame"/>
  19. <xsl:variable name="v_detailQueryName">
  20. <xsl:call-template name="getRefQuery">
  21. <xsl:with-param name="p_frame" select="$p_frame"/>
  22. </xsl:call-template>
  23. </xsl:variable>
  24. <xsl:if test="string-length(normalize-space($v_detailQueryName))>0">
  25. <xsl:if test="$p_frame/..">
  26. <xsl:variable name="v_masterQueryName">
  27. <xsl:call-template name="getMasterQueryName">
  28. <xsl:with-param name="p_frame" select="$p_frame/.."/>
  29. <xsl:with-param name="p_detailQueryName" select="$v_detailQueryName"/>
  30. </xsl:call-template>
  31. </xsl:variable>
  32. <xsl:if test="$v_masterQueryName != ''">
  33. <!-- map the master and detail query names, so that parameters generated come
  34. * from the new queries.
  35. *
  36. * The ignored queries are no longer generat
  37. -->
  38. <xsl:variable name="v_mappedMasterQueryName">
  39. <xsl:call-template name="getQueryTemplate">
  40. <xsl:with-param name="refQuery" select="$v_masterQueryName"/>
  41. </xsl:call-template>
  42. </xsl:variable>
  43. <xsl:variable name="v_mappedDetailQueryName">
  44. <xsl:call-template name="getQueryTemplate">
  45. <xsl:with-param name="refQuery" select="$v_detailQueryName"/>
  46. </xsl:call-template>
  47. </xsl:variable>
  48. <xsl:for-each select="/baltic:report/masterDetailInfo/masterDetailData">
  49. <xsl:if test="@masterQueryName = $v_mappedMasterQueryName">
  50. <xsl:if test="@detailQueryName = $v_mappedDetailQueryName">
  51. <xsl:if test="masterDetailLink">
  52. <xsl:element name="masterDetailLinks">
  53. <xsl:apply-templates mode="masterDetail" select="masterDetailLink"/>
  54. </xsl:element>
  55. </xsl:if>
  56. </xsl:if>
  57. </xsl:if>
  58. </xsl:for-each>
  59. </xsl:if>
  60. </xsl:if>
  61. </xsl:if>
  62. </xsl:template>
  63. <!--
  64. * Copy over the detailFilter's from the master-detail information.
  65. *
  66. * p_queryName of the query in the master-detail information file to copy the
  67. * filters from.
  68. *
  69. -->
  70. <xsl:template name="copyDetailFilter">
  71. <xsl:param name="p_queryName"/>
  72. <xsl:for-each select="/baltic:report/masterDetailInfo/masterDetailData">
  73. <xsl:if test="@detailQueryName = $p_queryName">
  74. <xsl:apply-templates mode="masterDetail" select="detailFilter"/>
  75. </xsl:if>
  76. </xsl:for-each>
  77. </xsl:template>
  78. <!--
  79. * Copy over the detailFilter's from the master-detail information.
  80. *
  81. * p_refQuery Name of the detail query.
  82. -->
  83. <xsl:template name="generateMasterDetailFilter">
  84. <xsl:param name="p_detailQueryName"/>
  85. <!-- copy the original query -->
  86. <xsl:call-template name="copyDetailFilter">
  87. <xsl:with-param name="p_queryName" select="$p_detailQueryName"/>
  88. </xsl:call-template>
  89. </xsl:template>
  90. <!--
  91. * Generate a detailFilters section from the master-detail information.
  92. *
  93. * p_refQuery Name of the detail query.
  94. -->
  95. <xsl:template name="generateMasterDetailFilters">
  96. <xsl:param name="p_detailQueryName"/>
  97. <xsl:variable name="v_filters">
  98. <xsl:call-template name="generateMasterDetailFilter">
  99. <xsl:with-param name="p_detailQueryName" select="$p_detailQueryName"/>
  100. </xsl:call-template>
  101. </xsl:variable>
  102. <xsl:if test="$v_filters != ''">
  103. <xsl:element name="detailFilters">
  104. <xsl:copy-of select="$v_filters"/>
  105. </xsl:element>
  106. </xsl:if>
  107. </xsl:template>
  108. <!-- Find the name of the query that contains the current frame, such that the query is different
  109. * then the detail query.
  110. *
  111. * p_frame frame, and its ancestors to look for refQuery.
  112. * p_detailQueryName Name of the detail query we already have, we want a query that nests this one.
  113. *
  114. * Return the name of the nesting query, or nothing.
  115. -->
  116. <xsl:template name="getMasterQueryName">
  117. <xsl:param name="p_frame"/>
  118. <xsl:param name="p_detailQueryName"/>
  119. <xsl:variable name="v_outterQueryName">
  120. <xsl:call-template name="getRefQuery">
  121. <xsl:with-param name="p_frame" select="$p_frame"/>
  122. </xsl:call-template>
  123. </xsl:variable>
  124. <xsl:if test="string-length($v_outterQueryName)>0">
  125. <xsl:choose>
  126. <xsl:when test="$v_outterQueryName = $p_detailQueryName">
  127. <xsl:call-template name="getMasterQueryName">
  128. <xsl:with-param name="p_frame" select="$p_frame/.."/>
  129. <xsl:with-param name="p_detailQueryName" select="$p_detailQueryName"/>
  130. </xsl:call-template>
  131. </xsl:when>
  132. <xsl:otherwise>
  133. <xsl:value-of select="$v_outterQueryName"/>
  134. </xsl:otherwise>
  135. </xsl:choose>
  136. </xsl:if>
  137. </xsl:template>
  138. <!-- Return the ref query that immediatly encloses the frame.
  139. * p_frame Frame in layout to examine.
  140. *
  141. * If no refQuery is found then nothing will be returned.
  142. -->
  143. <xsl:template name="getRefQuery">
  144. <xsl:param name="p_frame"/>
  145. <xsl:choose>
  146. <xsl:when test="$p_frame/@refQuery">
  147. <xsl:value-of select="$p_frame/@refQuery"/>
  148. </xsl:when>
  149. <xsl:when test="$p_frame/..">
  150. <xsl:call-template name="getRefQuery">
  151. <xsl:with-param name="p_frame" select="$p_frame/.."/>
  152. </xsl:call-template>
  153. </xsl:when>
  154. </xsl:choose>
  155. </xsl:template>
  156. <!-- Copy master-detail information into the Bering namespace without using namespace attributes
  157. which can not be handled by report studio.
  158. _____________________________________________
  159. From: McCully, Eric
  160. Sent: Friday, August 19, 2005 10:43 AM
  161. To: Pawlowsky, Marc
  162. Subject: RE: Report Studio can not handle namespace attributes
  163. RS does not handle namespace attributes, never has. There are too many issues with IE and namespaces.
  164. -->
  165. <xsl:template mode="masterDetail" match="masterDetailLink">
  166. <xsl:element name="masterDetailLink">
  167. <xsl:apply-templates mode="masterDetail"/>
  168. </xsl:element>
  169. </xsl:template>
  170. <xsl:template mode="masterDetail" match="masterDetailLink">
  171. <xsl:element name="masterDetailLink">
  172. <xsl:apply-templates mode="masterDetail" select="node()|@*"/>
  173. </xsl:element>
  174. </xsl:template>
  175. <xsl:template mode="masterDetail" match="masterContext">
  176. <xsl:element name="masterContext">
  177. <xsl:apply-templates mode="masterDetail" select="node()|@*"/>
  178. </xsl:element>
  179. </xsl:template>
  180. <xsl:template mode="masterDetail" match="detailContext">
  181. <xsl:element name="detailContext">
  182. <xsl:apply-templates mode="masterDetail" select="node()|@*"/>
  183. </xsl:element>
  184. </xsl:template>
  185. <xsl:template mode="masterDetail" match="dataItemContext">
  186. <xsl:element name="dataItemContext">
  187. <xsl:apply-templates mode="masterDetail" select="node()|@*"/>
  188. </xsl:element>
  189. </xsl:template>
  190. <xsl:template mode="masterDetail" match="parameterContext">
  191. <xsl:element name="parameterContext">
  192. <xsl:apply-templates mode="masterDetail" select="node()|@*"/>
  193. </xsl:element>
  194. </xsl:template>
  195. <xsl:template mode="masterDetail" match="detailFilter">
  196. <xsl:element name="detailFilter">
  197. <xsl:apply-templates mode="masterDetail" select="node()|@*"/>
  198. </xsl:element>
  199. </xsl:template>
  200. <xsl:template mode="masterDetail" match="filterExpression">
  201. <xsl:element name="filterExpression">
  202. <xsl:apply-templates mode="masterDetail" select="node()|@*"/>
  203. </xsl:element>
  204. </xsl:template>
  205. <xsl:template mode="masterDetail" match="@*">
  206. <xsl:copy-of select="."/>
  207. </xsl:template>
  208. </xsl:stylesheet>