framework.xsl 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. BI and PM: qs
  5. (C) Copyright IBM Corp. 2001, 2017
  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"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  15. xmlns:af="http://developer.cognos.com/schemas/xts/logicsheets/xslt/async/framework/"
  16. xmlns:out="dummy-uri"
  17. exclude-result-prefixes="xtsext af">
  18. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  19. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  20. <xsl:template match="af:setReportName">
  21. <out:variable name="contentLocale" select="/root/user/param[@name='contentLocale']"/>
  22. <out:variable name="MQLocale">
  23. <out:choose>
  24. <out:when test="/root/QSMiniQuery/CRQReport/@expressionLocale">
  25. <out:value-of select="/root/QSMiniQuery/CRQReport/@expressionLocale"/>
  26. </out:when>
  27. <!-- In Baltic, it was called 'contentLocale' -->
  28. <out:when test="/root/QSMiniQuery/CRQReport/@contentLocale">
  29. <out:value-of select="/root/QSMiniQuery/CRQReport/@contentLocale"/>
  30. </out:when>
  31. </out:choose>
  32. </out:variable>
  33. <out:variable name="CL">
  34. <out:choose>
  35. <out:when test="contains($contentLocale,'-')">
  36. <!-- Use short version of contentLocale (ie. 'en' for 'en-ca') -->
  37. <out:value-of select="substring-before($contentLocale, '-')"/>
  38. </out:when>
  39. <out:otherwise>
  40. <out:value-of select="$contentLocale"/>
  41. </out:otherwise>
  42. </out:choose>
  43. </out:variable>
  44. <out:variable name="MQL">
  45. <out:choose>
  46. <out:when test="contains($MQLocale,'-')">
  47. <!-- Use short version of query's authored locale (ie. 'en' for 'en-ca') -->
  48. <out:value-of select="substring-before($MQLocale, '-')"/>
  49. </out:when>
  50. <out:otherwise>
  51. <out:value-of select="$MQLocale"/>
  52. </out:otherwise>
  53. </out:choose>
  54. </out:variable>
  55. <out:variable name="cmQueryModelReportNameCL">
  56. <out:choose>
  57. <out:when test="/root/env/param[@name='cmQueryModelReportName' and substring-before(.,':::') = $CL]">true</out:when>
  58. <out:when test="/root/cmQueryModelReportName/@locale = $CL">true</out:when>
  59. </out:choose>
  60. </out:variable>
  61. <out:variable name="cmQueryModelReportNameMQ">
  62. <out:choose>
  63. <out:when test="/root/env/param[@name='cmQueryModelReportName' and substring-before(.,':::') = $MQL]">true</out:when>
  64. <out:when test="/root/cmQueryModelReportName/@locale = $MQL">true</out:when>
  65. </out:choose>
  66. </out:variable>
  67. <out:variable name="LocalizedReportName">
  68. <out:choose>
  69. <!-- Use contentLocale -->
  70. <out:when test="$contentLocale != '' and $cmQueryModelReportNameCL != ''">
  71. <out:choose>
  72. <out:when test="/root/env/param[@name='cmQueryModelReportName']">
  73. <out:choose>
  74. <out:when test="/root/env/param[@name='cmQueryModelReportName' and substring-before(., ':::') = $contentLocale]">
  75. <out:value-of select="substring-after(/root/env/param[@name='cmQueryModelReportName' and substring-before(., ':::') = $contentLocale], ':::')"/>
  76. </out:when>
  77. <out:when test="/root/env/param[@name='cmQueryModelReportName' and substring-before(., ':::') = $CL]">
  78. <out:value-of select="substring-after(/root/env/param[@name='cmQueryModelReportName' and substring-before(., ':::') = $CL], ':::')"/>
  79. </out:when>
  80. </out:choose>
  81. </out:when>
  82. <out:otherwise>
  83. <out:choose>
  84. <out:when test="/root/cmQueryModelReportName[@locale=$contentLocale]">
  85. <out:value-of select="/root/cmQueryModelReportName[@locale=$contentLocale]"/>
  86. </out:when>
  87. <out:when test="/root/cmQueryModelReportName[@locale=$CL]">
  88. <out:value-of select="/root/cmQueryModelReportName[@locale=$CL]"/>
  89. </out:when>
  90. </out:choose>
  91. </out:otherwise>
  92. </out:choose>
  93. </out:when>
  94. <!-- Use query's authored locale -->
  95. <out:when test="$MQLocale != '' and $cmQueryModelReportNameMQ != ''">
  96. <out:choose>
  97. <out:when test="/root/env/param[@name='cmQueryModelReportName']">
  98. <out:choose>
  99. <out:when test="/root/env/param[@name='cmQueryModelReportName' and substring-before(., ':::') = $MQLocale]">
  100. <out:value-of select="substring-after(/root/env/param[@name='cmQueryModelReportName' and substring-before(., ':::') = $MQLocale], ':::')"/>
  101. </out:when>
  102. <out:when test="/root/env/param[@name='cmQueryModelReportName' and substring-before(., ':::') = $MQL]">
  103. <out:value-of select="substring-after(/root/env/param[@name='cmQueryModelReportName' and substring-before(., ':::') = $MQL], ':::')"/>
  104. </out:when>
  105. </out:choose>
  106. </out:when>
  107. <out:otherwise>
  108. <out:choose>
  109. <out:when test="/root/cmQueryModelReportName[@locale=$MQLocale]">
  110. <out:value-of select="/root/cmQueryModelReportName[@locale=$MQLocale]"/>
  111. </out:when>
  112. <out:when test="/root/cmQueryModelReportName[@locale=$MQL]">
  113. <out:value-of select="/root/cmQueryModelReportName[@locale=$MQL]"/>
  114. </out:when>
  115. </out:choose>
  116. </out:otherwise>
  117. <out:otherwise>
  118. <out:value-of select="substring-after(/root/cmQueryModelReportName[./@locale=$MQL], ':::')"/>
  119. </out:otherwise>
  120. </out:choose>
  121. </out:when>
  122. <!-- If the default report name is set, use it -->
  123. <out:when test="/root/cmQueryModelDefaultReportName">
  124. <out:value-of select="/root/cmQueryModelDefaultReportName"/>
  125. </out:when>
  126. <!-- Can't find any that matches, take the first one -->
  127. <out:otherwise>
  128. <out:choose>
  129. <out:when test="/root/env/param[@name='cmQueryModelReportName']">
  130. <out:value-of select="substring-after(/root/env/param[@name='cmQueryModelReportName'], ':::')"/>
  131. </out:when>
  132. <out:otherwise>
  133. <out:value-of select="/root/cmQueryModelReportName"/>
  134. </out:otherwise>
  135. </out:choose>
  136. </out:otherwise>
  137. </out:choose>
  138. </out:variable>
  139. <xsl:text/>
  140. if (typeof oAppFrame != "object")
  141. {
  142. oAppFrame = goWindowManager.getApplicationFrame();
  143. }
  144. if (oAppFrame.cfgGet("ReportName") != "<out:value-of select="xtsext:javascriptencode( string( $LocalizedReportName ) )"/>")
  145. {
  146. oAppFrame.cfgSet("ReportName", "<out:value-of select="xtsext:javascriptencode( string( $LocalizedReportName ) )"/>");
  147. oAppFrame.cfgSet("NewReport", false);
  148. }
  149. <xsl:text/>
  150. </xsl:template>
  151. <xsl:template match="*">
  152. <xsl:copy>
  153. <xsl:copy-of select="@*"/>
  154. <xsl:apply-templates/>
  155. </xsl:copy>
  156. </xsl:template>
  157. </xsl:stylesheet>