outputs.xslt 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2011
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  13. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  14. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  15. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  16. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  17. <xsl:key name="system-param" match="/root/system/param" use="@name"/>
  18. <xsl:key name="env-param" match="/root/env/param" use="@name"/>
  19. <xsl:template match="/root">
  20. <!-- Contains the values entered by the User in the pagers Entries input fields -->
  21. <xsl:variable name="pagerToValueEntered" select="key('env-param', 'm_pagertorecentoutputs')"/>
  22. <xsl:variable name="pagerFromValueEntered" select="key('env-param', 'm_pagerfromrecentoutputs')"/>
  23. <!-- If a lang filter is specified then use it otherwise use the user's content locale -->
  24. <xsl:variable name="locale">
  25. <xsl:choose>
  26. <!-- Language flag set to 'all' or not set means no language filter -->
  27. <xsl:when test="key('env-param', 'cur_lang') = 'all'"></xsl:when>
  28. <!-- Language flag set to 'all' or not set means no language filter -->
  29. <xsl:when test="(string(key('env-param', 'cur_lang')) = '') and /root/outputs"></xsl:when>
  30. <!-- This dialog is being called for the first time from a schedule management tool -->
  31. <xsl:when test="not(key('env-param', 'cur_lang')) and key('env-param', 'runHistoryRequestedTime')"></xsl:when>
  32. <!-- An explicit language filter is specified -->
  33. <xsl:when test="string(key('env-param', 'cur_lang')) != ''"><xsl:value-of select="key('env-param', 'cur_lang')"/></xsl:when>
  34. <!-- Default to the user's content locale -->
  35. <xsl:otherwise><xsl:value-of select="/root/user/param[@name = 'contentLocale']"/></xsl:otherwise>
  36. </xsl:choose>
  37. </xsl:variable>
  38. <!-- The CM locale filter -->
  39. <xsl:variable name="localeFilter">
  40. <xsl:if test="$locale != ''">[@locale = '<xsl:value-of select="$locale"/>']</xsl:if>
  41. </xsl:variable>
  42. <xsl:variable name="maxObjects">
  43. <xsl:choose>
  44. <xsl:when test="string($pagerToValueEntered) !='' and string($pagerFromValueEntered) !=''">
  45. <xsl:value-of select="($pagerToValueEntered - $pagerFromValueEntered) + 1"/>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <xsl:value-of select="/root/session/param[@name='linesPerPage']"/>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. </xsl:variable>
  52. <xsl:variable name="skipObjects">
  53. <xsl:choose>
  54. <xsl:when test="$pagerFromValueEntered and $pagerFromValueEntered!=''">
  55. <xsl:value-of select="($pagerFromValueEntered)-1"/>
  56. </xsl:when>
  57. <xsl:when test="key('env-param', 'm_recentoutputssection')!=''">
  58. <xsl:choose>
  59. <xsl:when test="key('env-param', 'm_recentoutputssection')!='-1'">
  60. <xsl:value-of select="((key('env-param', 'm_recentoutputssection')) -1)"/>
  61. </xsl:when>
  62. <xsl:otherwise>
  63. <xsl:value-of select="($maxObjects) * -1"/>
  64. </xsl:otherwise>
  65. </xsl:choose>
  66. </xsl:when>
  67. <xsl:otherwise>0</xsl:otherwise>
  68. </xsl:choose>
  69. </xsl:variable>
  70. <xts:sequence>
  71. <!-- If this is a second attempt at fetching outputs, then clean up after the first one. -->
  72. <xsl:if test="/root/outputs">
  73. <xts:delete select="/root/outputs"/>
  74. <xts:delete select="/root/localeFilter"/>
  75. </xsl:if>
  76. <!-- Remember the locale we filtered on so we can use it in the presentation -->
  77. <xts:append select="/root">
  78. <localeFilter><xsl:value-of select="$locale"/></localeFilter>
  79. </xts:append>
  80. <!-- If this page is being accessed for the first time for "administrative" purposes then set the language filter to 'all' -->
  81. <xsl:if test="(not(key('env-param', 'cur_lang')) and key('env-param', 'runHistoryRequestedTime'))">
  82. <xts:append select="/root/env">
  83. <param name="cur_lang">all</param>
  84. </xts:append>
  85. </xsl:if>
  86. <xsl:variable name="vn" select="key('env-param', 'versionName')"/>
  87. <xsl:variable name="sq">'</xsl:variable>
  88. <xsl:variable name="path">
  89. <xsl:choose>
  90. <xsl:when test="key('env-param', 'reportVersionPath') and key('env-param', 'reportVersionPath') != ''">
  91. <xsl:value-of select="key('env-param', 'reportVersionPath')"/>
  92. </xsl:when>
  93. <xsl:when test="$vn != '' and not( contains($vn, '/') or contains($vn, '*') or contains($vn, $sq))">
  94. <xsl:value-of select="key('env-param', 'm_obj')"/>/*[@defaultName='<xsl:value-of select="$vn"/>']<xsl:text/>
  95. </xsl:when>
  96. <xsl:when test="key('env-param', 'm_class') = 'document'">
  97. <xsl:value-of select="/root/objectVersions/cm:queryResponse/cm:queryReply[2]/cm:documentVersion[1]/cm:searchPath"/>
  98. </xsl:when>
  99. <xsl:otherwise>
  100. <xsl:value-of select="/root/objectVersions/cm:queryResponse/cm:queryReply[2]/cm:reportVersion[1]/cm:searchPath"/>
  101. </xsl:otherwise>
  102. </xsl:choose>
  103. </xsl:variable>
  104. <xsl:variable name="validFormats">
  105. <xsl:for-each select="key('system-param', 'reportFormats')/format">
  106. <xsl:choose>
  107. <xsl:when test="position() = last()"><xsl:value-of select="concat('@format = &quot;', @id, '&quot;')"/></xsl:when>
  108. <xsl:otherwise><xsl:value-of select="concat('@format = &quot;', @id, '&quot; or ')"/></xsl:otherwise>
  109. </xsl:choose>
  110. </xsl:for-each>
  111. </xsl:variable>
  112. <xsl:variable name="formatFilter">
  113. <xsl:if test="key('env-param', 'm_class') != 'document' and $validFormats != '' ">
  114. <xsl:choose>
  115. <xsl:when test="key('env-param', 'm_class') = 'interactiveReport'">
  116. <xsl:text>[@format='XHTML']</xsl:text>
  117. </xsl:when>
  118. <xsl:otherwise>[<xsl:value-of select="$validFormats"/>]</xsl:otherwise>
  119. </xsl:choose>
  120. </xsl:if>
  121. </xsl:variable>
  122. <xts:append>
  123. <outputs>
  124. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  125. <send:request provider="cm">
  126. <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
  127. <cm:query>
  128. <cm:search>
  129. <xsl:value-of select="$path"/>/*[permission('read')]<xsl:value-of select="$localeFilter"/><xsl:value-of select="$formatFilter"/>
  130. </cm:search>
  131. <cm:properties>
  132. <cm:property name="defaultName"/>
  133. <cm:property name="searchPath"/>
  134. <cm:property name="storeID"/>
  135. <cm:property name="format"/>
  136. <cm:property name="locale"/>
  137. <cm:property name="burstKey"/>
  138. <cm:property name="dataType"/>
  139. <cm:property name="dataSize"/>
  140. <cm:property name="position"/>
  141. </cm:properties>
  142. <cm:sortBy>
  143. <cm:sort name="burstKey" order="ascending"/>
  144. <cm:sort name="locale" order="ascending"/>
  145. </cm:sortBy>
  146. <cm:options maxObjects="{($maxObjects)+1}" skipObjects="{$skipObjects}"/>
  147. </cm:query>
  148. </xts:transform>
  149. </send:request>
  150. </xts:transform>
  151. </outputs>
  152. <versionInfo>
  153. <xsl:choose>
  154. <xsl:when test="key('env-param', 'm_class') = 'document'"><xsl:copy-of select="/root/objectVersions/cm:queryResponse/cm:queryReply[2]/cm:documentVersion[string(./cm:searchPath) = $path]/*"/></xsl:when>
  155. <xsl:otherwise><xsl:copy-of select="/root/objectVersions/cm:queryResponse/cm:queryReply[2]/cm:reportVersion[string(./cm:searchPath) = $path]/*"/></xsl:otherwise>
  156. </xsl:choose>
  157. </versionInfo>
  158. </xts:append>
  159. <xts:delete select="/root/env/param[@name='pagerfromrecentoutputs' or @name='pagertorecentoutputs' or @name='pagerfrom_drecentoutputs' or @name='pagerto_drecentoutputs']"/>
  160. </xts:sequence>
  161. </xsl:template>
  162. </xsl:stylesheet>