interaction.xslt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cpscrn
  5. (C) Copyright IBM Corp. 2005, 2013
  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:xts="http://developer.cognos.com/schemas/xts/"
  15. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  16. xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/">
  17. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  18. <xsl:key name="interParamList" match="/root/interactions/param" use="@name"/>
  19. <xsl:variable name="config" select="/root/input[@name='configurationResponse']/config/param[@name='contentLocales']"/>
  20. <xsl:template match="/">
  21. <xsl:variable name="controller-params" select="/root/controllerParams/param"/>
  22. <xsl:variable name="customs" select="/root/customs/param"/>
  23. <xsl:variable name="interactions" select="/root/interactions/param"/>
  24. <xsl:variable name="transients" select="/root/transients/param"/>
  25. <xsl:variable name="constRemoveHead" select="'remove-'"/>
  26. <xsl:variable name="constRemoveTail" select="'form-remove'"/>
  27. <xsl:variable name="lenRemoveTail" select="string-length($constRemoveTail)-1"/>
  28. <xsl:variable name="custProps" select="/root/fragment/meta/customProperties"/>
  29. <xsl:variable name="formAction" select="/root/interactions/param[@name='formaction']"/>
  30. <xsl:variable name="fragMode" select="/root/controllerParams/param[@name='frag-mode']"/>
  31. <xsl:variable name="is-edit-mode" select="$fragMode='edit' or $fragMode='config'"/>
  32. <xsl:variable name="fragWindowState" select="/root/controllerParams/param[@name='frag-windowState']"/>
  33. <xsl:variable name="navItemResponse" select="/root/init/objectResponse/nav:getItemResponse"/>
  34. <response>
  35. <xsl:choose>
  36. <xsl:when test="$is-edit-mode and $formAction = 'save'">
  37. <customs>
  38. <xsl:for-each select="$custProps">
  39. <xsl:choose>
  40. <xsl:when test="@name = 'title'">
  41. <param name="title">
  42. <xsl:for-each select="$config/locale">
  43. <xsl:variable name="lid" select="@id"/>
  44. <xsl:if test="$interactions[@name = concat('title-',$lid)]">
  45. <xsl:if test="not(contains(string(/root/interactions/param[@name='removeLang']),concat($lid,';')))">
  46. <value xml:lang="{$lid}">
  47. <xsl:value-of select="$interactions[@name = concat('title-',$lid)]"/>
  48. </value>
  49. </xsl:if>
  50. </xsl:if>
  51. </xsl:for-each>
  52. </param>
  53. </xsl:when>
  54. <xsl:otherwise>
  55. <param name="{@name}">
  56. <xsl:value-of select="key('interParamList', concat('p_', @name))"/>
  57. </param>
  58. </xsl:otherwise>
  59. </xsl:choose>
  60. </xsl:for-each>
  61. </customs>
  62. <state/>
  63. </xsl:when>
  64. <xsl:when test="$is-edit-mode and $formAction = 'objectSelect'">
  65. <state>
  66. <xsl:for-each select="$custProps">
  67. <xsl:choose>
  68. <xsl:when test="@name = 'title'">
  69. <xsl:for-each select="$interactions[starts-with(@name,'title-')]">
  70. <xsl:copy-of select="."/>
  71. </xsl:for-each>
  72. </xsl:when>
  73. <xsl:otherwise>
  74. <param name="{@name}">
  75. <xsl:value-of select="key('interParamList', concat('p_', @name))"/>
  76. </param>
  77. </xsl:otherwise>
  78. </xsl:choose>
  79. </xsl:for-each>
  80. </state>
  81. </xsl:when>
  82. </xsl:choose>
  83. <xsl:variable name="delayExecutionSetting">
  84. <xsl:choose>
  85. <xsl:when test="$formAction = 'save' and $is-edit-mode">
  86. <xsl:value-of select="$interactions[@name='p_delayExecution']"/>
  87. </xsl:when>
  88. <xsl:otherwise>
  89. <xsl:value-of select="$customs[@name='delayExecution']"/>
  90. </xsl:otherwise>
  91. </xsl:choose>
  92. </xsl:variable>
  93. <!--
  94. We delay the exection when:
  95. the delayExecution setting is enabled and the getContent parameter does not exist
  96. -->
  97. <xsl:variable name="delayExecution" select="$delayExecutionSetting = 'true' and not($interactions[@name='getContent']) "/>
  98. <fragment>
  99. <!-- We will only add a sub-fragment if we are not in edit mode or exiting the edit mode.-->
  100. <xsl:variable name="objectName">
  101. <xsl:if test="$navItemResponse != ''">
  102. <xsl:value-of select="$navItemResponse/*/nav:name"/>
  103. </xsl:if>
  104. </xsl:variable>
  105. <xsl:if test=" not($delayExecution) and (not ($is-edit-mode) or ($formAction = 'save') )">
  106. <xsl:variable name="selectionId">
  107. <xsl:choose>
  108. <xsl:when test="$transients[@name='display_id'] and $transients[@name = 'display_id'] != ''">
  109. <xsl:value-of select="$transients[@name='display_id']"/>
  110. </xsl:when>
  111. <xsl:when test="$formAction = 'save' and $is-edit-mode">
  112. <xsl:value-of select="$interactions[@name='p_navSelectionId']"/>
  113. </xsl:when>
  114. <xsl:otherwise>
  115. <xsl:value-of select="$customs[@name='navSelectionId']"/>
  116. </xsl:otherwise>
  117. </xsl:choose>
  118. </xsl:variable>
  119. <xsl:variable name="dlgCustomParams">
  120. <xsl:choose>
  121. <xsl:when test="$formAction = 'save' and $is-edit-mode">
  122. <xsl:value-of select="$interactions[@name='p_dialogCustomizations']"/>
  123. </xsl:when>
  124. <xsl:otherwise>
  125. <xsl:value-of select="$customs[@name='dialogCustomizations']"/>
  126. </xsl:otherwise>
  127. </xsl:choose>
  128. </xsl:variable>
  129. <xsl:variable name="viewerHeight">
  130. <xsl:choose>
  131. <xsl:when test="$formAction = 'save' and $is-edit-mode">
  132. <xsl:value-of select="$interactions[@name='p_viewerFragmentHeight']"/>
  133. </xsl:when>
  134. <xsl:otherwise>
  135. <xsl:value-of select="$customs[@name='viewerFragmentHeight']"/>
  136. </xsl:otherwise>
  137. </xsl:choose>
  138. </xsl:variable>
  139. <xsl:variable name="channel">
  140. <xsl:choose>
  141. <xsl:when test="$formAction = 'save' and $is-edit-mode">
  142. <xsl:value-of select="$interactions[@name='p_channel']"/>
  143. </xsl:when>
  144. <xsl:otherwise>
  145. <xsl:value-of select="$customs[@name='channel']"/>
  146. </xsl:otherwise>
  147. </xsl:choose>
  148. </xsl:variable>
  149. <!--
  150. Use the selected objects's defaultPortalAction setting iff:
  151. - there is no prior customization done on the viewer
  152. - the target viewer does NOT already have a selected entry
  153. - the target object is being selected at runtime (e.g.: in a Navigator with channel setup)
  154. - the default action is 'run' (otherwise, leave it up to the viewer's default)
  155. -->
  156. <xsl:variable name="useDefaultPortalAction" select="$dlgCustomParams = '' and string($transients[@name='display_id']) != '' and string($customs[@name='navSelectionId']) = '' and $navItemResponse/*/nav:defaultPortalAction = 'run'"/>
  157. <xsl:if test="$selectionId != ''">
  158. <xsl:variable name="href">
  159. <xsl:choose>
  160. <xsl:when test="$navItemResponse/nav:item/nav:type = 'package' and $navItemResponse/nav:item/nav:subType = 'adaptiveAnalytics' ">
  161. <xsl:text>/AApackage/</xsl:text>
  162. </xsl:when>
  163. <xsl:when test="$navItemResponse/nav:shortcut">
  164. <xsl:text>/shortcut/</xsl:text>
  165. <xsl:value-of select="$navItemResponse/nav:shortcut/*/nav:type"/>
  166. <xsl:text>/</xsl:text>
  167. </xsl:when>
  168. <xsl:when test="$navItemResponse/*/nav:type != '' ">
  169. <xsl:text>/</xsl:text>
  170. <xsl:value-of select="$navItemResponse/*/nav:type"/>
  171. <xsl:text>/</xsl:text>
  172. </xsl:when>
  173. <xsl:otherwise>
  174. <xsl:text>/cm/</xsl:text>
  175. </xsl:otherwise>
  176. </xsl:choose>
  177. <xsl:value-of select="$selectionId"/>
  178. <xsl:if test="$navItemResponse/nav:shortcut">
  179. <!-- if it's a shortcut , we need to include the id of the target -->
  180. <xsl:text>/</xsl:text>
  181. <xsl:value-of select="$navItemResponse/nav:shortcut/*/nav:internalId"/>
  182. </xsl:if>
  183. <xsl:if test="$dlgCustomParams != ''">
  184. <xsl:text>?</xsl:text>
  185. <xsl:value-of select="$dlgCustomParams"/>
  186. </xsl:if>
  187. </xsl:variable>
  188. <subfragment id="frame1{$selectionId}" href="{$href}">
  189. <params>
  190. <param name="frag-windowState">
  191. <xsl:choose>
  192. <xsl:when test="$fragWindowState">
  193. <xsl:value-of select="$fragWindowState"/>
  194. </xsl:when>
  195. <xsl:otherwise>
  196. <xsl:text>normal</xsl:text>
  197. </xsl:otherwise>
  198. </xsl:choose>
  199. </param>
  200. <xsl:if test="$formAction = 'save'">
  201. <param name="frag-event">
  202. <xsl:text>name=fragment.customization.changed</xsl:text>
  203. </param>
  204. </xsl:if>
  205. <xsl:if test="$fragMode = 'preview'">
  206. <param name="frag-mode">
  207. <xsl:value-of select="$fragMode"/>
  208. </param>
  209. </xsl:if>
  210. <xsl:variable name="calculated-height">
  211. <xsl:choose>
  212. <xsl:when test="(string($viewerHeight) != '')">
  213. <xsl:value-of select="$viewerHeight"/>
  214. </xsl:when>
  215. <xsl:otherwise>
  216. <xsl:text>365</xsl:text>
  217. </xsl:otherwise>
  218. </xsl:choose>
  219. </xsl:variable>
  220. <param name="viewer-height">
  221. <xsl:value-of select="$calculated-height"/>
  222. </param>
  223. <param name="cpscp_display_height">100%</param>
  224. <param name="output-height">100%</param>
  225. <param name="object-name">
  226. <xsl:value-of select="$objectName"/>
  227. </param>
  228. <param name="frag-channel">
  229. <xsl:value-of select="$channel"/>
  230. </param>
  231. <xsl:if test="$useDefaultPortalAction">
  232. <param name="p_reportLaunchOption">
  233. <xsl:value-of select="$navItemResponse/*/nav:defaultPortalAction"/>
  234. </param>
  235. </xsl:if>
  236. </params>
  237. </subfragment>
  238. </xsl:if>
  239. </xsl:if>
  240. <xsl:variable name="titleSelection">
  241. <xsl:choose>
  242. <xsl:when test="$formAction = 'save' and $is-edit-mode">
  243. <xsl:value-of select="$interactions[@name='p_viewerTitleOptions']"/>
  244. </xsl:when>
  245. <xsl:otherwise>
  246. <xsl:value-of select="$customs[@name='viewerTitleOptions']"/>
  247. </xsl:otherwise>
  248. </xsl:choose>
  249. </xsl:variable>
  250. <xsl:choose>
  251. <xsl:when test="$is-edit-mode and not($formAction = 'save')">
  252. <preferredTitle/>
  253. </xsl:when>
  254. <xsl:when test="($titleSelection = 'entryName') and ($objectName != '') ">
  255. <preferredTitle>
  256. <xsl:value-of select="$objectName"/>
  257. </preferredTitle>
  258. </xsl:when>
  259. </xsl:choose>
  260. <xsl:variable name="errorResponse" select="/root/init/objectResponse/error/*"/>
  261. <xsl:if test="$errorResponse != ''">
  262. <error>
  263. <code>
  264. <xsl:value-of select="$errorResponse/xts:exceptionCode"/>
  265. </code>
  266. <message>
  267. <xsl:value-of select="$errorResponse/xts:exceptionMsg"/>
  268. </message>
  269. <details>
  270. <xsl:value-of select="$errorResponse/xts:exceptionDetail"/>
  271. </details>
  272. </error>
  273. </xsl:if>
  274. <xsl:if test="$is-edit-mode and $formAction = 'save'">
  275. <newMode>view</newMode>
  276. </xsl:if>
  277. </fragment>
  278. </response>
  279. </xsl:template>
  280. <xsl:template match="param" mode="state">
  281. <xsl:if test="/root/input[@name='stateParams']/stateParams/param/@name=current()/@name">
  282. <xsl:copy-of select="."/>
  283. </xsl:if>
  284. </xsl:template>
  285. </xsl:stylesheet>