interaction.xslt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <!--
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: Viewer
  4. (C) Copyright IBM Corp. 2001, 2011
  5. US Government Users Restricted Rights - Use, duplication or
  6. disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/" xmlns:encodingUtils="com.cognos.portal.utils.EncodingUtils">
  9. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  10. <xsl:key name="interParamList" match="/root/interactions/param" use="@name"/>
  11. <xsl:variable name="customs" select="/root/customs/param"/>
  12. <xsl:variable name="interactions" select="/root/interactions/param"/>
  13. <xsl:template name="buildVariable">
  14. <xsl:param name="name" select="."/>
  15. <xsl:choose>
  16. <xsl:when test="$interactions[@name = concat('p_',$name)]">
  17. <xsl:value-of select="$interactions[@name = concat('p_',$name)]"/>
  18. </xsl:when>
  19. <xsl:otherwise>
  20. <xsl:value-of select="$customs[@name = $name]"/>
  21. </xsl:otherwise>
  22. </xsl:choose>
  23. </xsl:template>
  24. <xsl:template match="/">
  25. <xsl:variable name="custProps" select="/root/fragment/meta/customProperties"/>
  26. <xsl:variable name="formAction" select="/root/interactions/param[@name='formaction']"/>
  27. <xsl:variable name="fragMode" select="/root/controllerParams/param[@name='frag-mode']"/>
  28. <xsl:variable name="fragWindowState" select="/root/controllerParams/param[@name='frag-windowState']"/>
  29. <xsl:variable name="fragEvent" select="/root/controllerParams/param[@name='frag-event']"/>
  30. <xsl:variable name="config" select="/root/input[@name='configurationResponse']/config/param[@name='contentLocales']"/>
  31. <response>
  32. <xsl:choose>
  33. <xsl:when test="$fragMode='edit' and $formAction = 'save'">
  34. <customs>
  35. <xsl:for-each select="$custProps">
  36. <xsl:choose>
  37. <xsl:when test="@name = 'title'">
  38. <xsl:variable name="cpName" select="@name"/>
  39. <param name="{$cpName}">
  40. <xsl:for-each select="$config/locale">
  41. <xsl:variable name="lid" select="@id"/>
  42. <xsl:for-each select="/root/interactions/param[@name = concat($cpName,'-',$lid)]">
  43. <xsl:if test="not(contains(string(/root/interactions/param[@name='removeLang']),concat($lid,';')))">
  44. <value xml:lang="{$lid}">
  45. <xsl:value-of select="string(.)"/>
  46. </value>
  47. </xsl:if>
  48. </xsl:for-each>
  49. </xsl:for-each>
  50. </param>
  51. </xsl:when>
  52. <xsl:otherwise>
  53. <param name="{@name}">
  54. <xsl:value-of select="key('interParamList', concat('p_', @name))"/>
  55. </param>
  56. </xsl:otherwise>
  57. </xsl:choose>
  58. </xsl:for-each>
  59. </customs>
  60. <state>
  61. </state>
  62. </xsl:when>
  63. <xsl:when test="$fragMode='edit' and $formAction = 'objectSelect'">
  64. <state>
  65. <xsl:for-each select="$custProps">
  66. <xsl:choose>
  67. <xsl:when test="@name = 'title'">
  68. <xsl:for-each select="$interactions[starts-with(@name,'title-')]">
  69. <xsl:copy-of select="."/>
  70. </xsl:for-each>
  71. </xsl:when>
  72. <xsl:otherwise>
  73. <param name="{@name}">
  74. <xsl:value-of select="key('interParamList', concat('p_', @name))"/>
  75. </param>
  76. </xsl:otherwise>
  77. </xsl:choose>
  78. </xsl:for-each>
  79. </state>
  80. </xsl:when>
  81. </xsl:choose>
  82. <fragment>
  83. <xsl:variable name="objectName">
  84. <xsl:value-of select="$interactions[@name='object-name']"/>
  85. </xsl:variable>
  86. <xsl:variable name="reportSpec">
  87. <xsl:value-of select="$interactions[@name='ui.spec']"/>
  88. </xsl:variable>
  89. <xsl:variable name="reportpart_id">
  90. <xsl:value-of select="$interactions[@name='reportpart_id']"/>
  91. </xsl:variable>
  92. <xsl:variable name="containerApp">
  93. <xsl:value-of select="$interactions[@name='cv.containerApp']"/>
  94. </xsl:variable>
  95. <xsl:variable name="titleSelection">
  96. <xsl:choose>
  97. <xsl:when test="$interactions[@name='formaction'] = 'save'">
  98. <xsl:value-of select="$interactions[@name='viewerTitleOptions']"/>
  99. </xsl:when>
  100. <xsl:otherwise>
  101. <xsl:value-of select="$customs[@name='viewerTitleOptions']"/>
  102. </xsl:otherwise>
  103. </xsl:choose>
  104. </xsl:variable>
  105. <xsl:variable name="promptOption">
  106. <xsl:call-template name="buildVariable">
  107. <xsl:with-param name="name">promptOption</xsl:with-param>
  108. </xsl:call-template>
  109. </xsl:variable>
  110. <xsl:variable name="reportLaunchOption">
  111. <xsl:call-template name="buildVariable">
  112. <xsl:with-param name="name">reportLaunchOption</xsl:with-param>
  113. </xsl:call-template>
  114. </xsl:variable>
  115. <xsl:variable name="reportLaunchSubOption">
  116. <xsl:call-template name="buildVariable">
  117. <xsl:with-param name="name">reportLaunchSubOption</xsl:with-param>
  118. </xsl:call-template>
  119. </xsl:variable>
  120. <xsl:variable name="reportAction">
  121. <xsl:value-of select="$interactions[@name = 'p_reportAction']"/>
  122. </xsl:variable>
  123. <xsl:choose>
  124. <xsl:when test="(not ($fragMode = 'edit') or ($formAction = 'save'))">
  125. <xsl:variable name="selectionId">
  126. <xsl:choose>
  127. <xsl:when test="$interactions[@name='obj_id'] and $interactions[@name = 'obj_id'] != ''">
  128. <xsl:value-of select="$interactions[@name='obj_id']"/>
  129. </xsl:when>
  130. <xsl:otherwise>
  131. <xsl:value-of select="$customs[@name='navSelectionId']"/>
  132. </xsl:otherwise>
  133. </xsl:choose>
  134. </xsl:variable>
  135. <xsl:variable name="viewerToolbarMaximizeMode">
  136. <xsl:call-template name="buildVariable">
  137. <xsl:with-param name="name">viewerToolbarMaximizeMode</xsl:with-param>
  138. </xsl:call-template>
  139. </xsl:variable>
  140. <xsl:variable name="viewerToolbarNormalMode">
  141. <xsl:call-template name="buildVariable">
  142. <xsl:with-param name="name">viewerToolbarNormalMode</xsl:with-param>
  143. </xsl:call-template>
  144. </xsl:variable>
  145. <xsl:variable name="sharePromptValues">
  146. <xsl:call-template name="buildVariable">
  147. <xsl:with-param name="name">sharePromptValues</xsl:with-param>
  148. </xsl:call-template>
  149. </xsl:variable>
  150. <xsl:variable name="matchOnParameterNameOnly">
  151. <xsl:call-template name="buildVariable">
  152. <xsl:with-param name="name">matchOnParameterNameOnly</xsl:with-param>
  153. </xsl:call-template>
  154. </xsl:variable>
  155. <xsl:variable name="usePromptChannel">
  156. <xsl:call-template name="buildVariable">
  157. <xsl:with-param name="name">usePromptChannel</xsl:with-param>
  158. </xsl:call-template>
  159. </xsl:variable>
  160. <xsl:variable name="promptEventChannel">
  161. <xsl:call-template name="buildVariable">
  162. <xsl:with-param name="name">promptEventChannel</xsl:with-param>
  163. </xsl:call-template>
  164. </xsl:variable>
  165. <xsl:variable name="shareDrillEvents">
  166. <xsl:call-template name="buildVariable">
  167. <xsl:with-param name="name">shareDrillEvents</xsl:with-param>
  168. </xsl:call-template>
  169. </xsl:variable>
  170. <xsl:variable name="useDrillChannel">
  171. <xsl:call-template name="buildVariable">
  172. <xsl:with-param name="name">useDrillChannel</xsl:with-param>
  173. </xsl:call-template>
  174. </xsl:variable>
  175. <xsl:variable name="drillChannel">
  176. <xsl:call-template name="buildVariable">
  177. <xsl:with-param name="name">drillChannel</xsl:with-param>
  178. </xsl:call-template>
  179. </xsl:variable>
  180. <xsl:variable name="shareAuthoredDrillEvents">
  181. <xsl:call-template name="buildVariable">
  182. <xsl:with-param name="name">shareAuthoredDrillEvents</xsl:with-param>
  183. </xsl:call-template>
  184. </xsl:variable>
  185. <xsl:variable name="authoredDrillChannel">
  186. <xsl:call-template name="buildVariable">
  187. <xsl:with-param name="name">authoredDrillChannel</xsl:with-param>
  188. </xsl:call-template>
  189. </xsl:variable>
  190. <xsl:variable name="transientSpecification">
  191. <xsl:call-template name="buildVariable">
  192. <xsl:with-param name="name">transientSpecification</xsl:with-param>
  193. </xsl:call-template>
  194. </xsl:variable>
  195. <xsl:variable name="href">
  196. <xsl:choose>
  197. <xsl:when test="$selectionId != ''">
  198. <xsl:text>/rv/</xsl:text>
  199. <xsl:value-of select="$selectionId"/>
  200. </xsl:when>
  201. <xsl:otherwise>
  202. <xsl:text>/rv</xsl:text>
  203. </xsl:otherwise>
  204. </xsl:choose>
  205. <xsl:text>?</xsl:text>
  206. <xsl:choose>
  207. <xsl:when test="$promptOption='true'">
  208. <xsl:text>&amp;run.prompt=true</xsl:text>
  209. </xsl:when>
  210. <xsl:when test="$promptOption='false'">
  211. <xsl:text>&amp;run.prompt=false</xsl:text>
  212. </xsl:when>
  213. <xsl:when test="$promptOption='hide'">
  214. <xsl:text>&amp;fragment.waitForPromptValues=true</xsl:text>
  215. </xsl:when>
  216. </xsl:choose>
  217. <xsl:choose>
  218. <xsl:when test="$reportSpec != ''">
  219. <xsl:text>&amp;ui.action=runSpecification</xsl:text>
  220. </xsl:when>
  221. <xsl:when test="$reportAction = 'run'">
  222. <xsl:text>&amp;ui.action=run</xsl:text>
  223. </xsl:when>
  224. <xsl:when test="$reportLaunchOption = 'runIcon'">
  225. <xsl:text>&amp;ui.action=runIcon</xsl:text>
  226. </xsl:when>
  227. <xsl:when test="$reportLaunchOption = 'output' and $reportLaunchSubOption = 'runIcon'">
  228. <xsl:text>&amp;ui.action=output&amp;ui.subaction=runIcon</xsl:text>
  229. </xsl:when>
  230. <xsl:when test="$reportLaunchOption != ''">
  231. <xsl:text>&amp;ui.action=</xsl:text>
  232. <xsl:value-of select="$reportLaunchOption"/>
  233. </xsl:when>
  234. </xsl:choose>
  235. <xsl:if test="$reportSpec != ''">
  236. <xsl:text>&amp;ui.spec=</xsl:text>
  237. <xsl:value-of select="encodingUtils:urlencode(string($reportSpec), string('UTF-8'), true())"/>
  238. </xsl:if>
  239. <xsl:if test="$reportpart_id != ''">
  240. <xsl:text>&amp;reportpart_id=</xsl:text>
  241. <xsl:value-of select="encodingUtils:urlencode(string($reportpart_id), string('UTF-8'), true())"/>
  242. </xsl:if>
  243. <xsl:if test="$containerApp != ''">
  244. <xsl:text>&amp;cv.containerApp=</xsl:text>
  245. <xsl:value-of select="$containerApp"/>
  246. </xsl:if>
  247. <xsl:choose>
  248. <xsl:when test="$viewerToolbarNormalMode = 'showNormal' and $viewerToolbarMaximizeMode = 'showMaximize'">
  249. <xsl:text>&amp;fragment.toolbarProperties=show</xsl:text>
  250. </xsl:when>
  251. <xsl:when test="$viewerToolbarNormalMode = 'showNormal'">
  252. <xsl:text>&amp;fragment.toolbarProperties=showNormal</xsl:text>
  253. </xsl:when>
  254. <xsl:when test="$viewerToolbarMaximizeMode = 'showMaximize'">
  255. <xsl:text>&amp;fragment.toolbarProperties=showMaximized</xsl:text>
  256. </xsl:when>
  257. <xsl:otherwise>
  258. <xsl:text>&amp;fragment.toolbarProperties=hidden</xsl:text>
  259. </xsl:otherwise>
  260. </xsl:choose>
  261. <xsl:if test="$fragMode = 'preview'">
  262. <xsl:text>&amp;run.data=previewWithNoData</xsl:text>
  263. </xsl:if>
  264. <xsl:if test="$sharePromptValues='true'">
  265. <xsl:text>&amp;fragment.sharePromptValues=true</xsl:text>
  266. <xsl:text>&amp;cv.transientSpec=</xsl:text>
  267. <xsl:value-of select="$transientSpecification"/>
  268. <xsl:if test="$usePromptChannel='true' and string($promptEventChannel) != ''">
  269. <xsl:text>&amp;fragment.promptChannel=</xsl:text>
  270. <xsl:value-of select="encodingUtils:urlencode(string($promptEventChannel), string('UTF-8'), true())"/>
  271. </xsl:if>
  272. <xsl:text>&amp;fragment.matchOnParameterNameOnly=</xsl:text>
  273. <xsl:choose>
  274. <xsl:when test="$matchOnParameterNameOnly='true'"><xsl:text>true</xsl:text></xsl:when>
  275. <xsl:otherwise><xsl:text>false</xsl:text></xsl:otherwise>
  276. </xsl:choose>
  277. </xsl:if>
  278. <xsl:if test="$shareDrillEvents='true'">
  279. <xsl:text>&amp;fragment.shareDrillEvents=true</xsl:text>
  280. <xsl:if test="$useDrillChannel='true' and string($drillChannel) != ''">
  281. <xsl:text>&amp;fragment.drillChannel=</xsl:text>
  282. <xsl:value-of select="encodingUtils:urlencode(string($drillChannel), string('UTF-8'), true())"/>
  283. </xsl:if>
  284. </xsl:if>
  285. <xsl:if test="$shareAuthoredDrillEvents='true'">
  286. <xsl:text>&amp;fragment.shareAuthoredDrillEvents=true</xsl:text>
  287. <xsl:text>&amp;fragment.authoredDrillChannel=</xsl:text>
  288. <xsl:value-of select="encodingUtils:urlencode(string($authoredDrillChannel), string('UTF-8'), true())"/>
  289. </xsl:if>
  290. <xsl:text>&amp;cv.header=false</xsl:text>
  291. <xsl:if test="$interactions[@name='viewer-height']!=''">
  292. <xsl:text>&amp;fragment.height=</xsl:text>
  293. <xsl:value-of select="$interactions[@name='viewer-height']"/>
  294. </xsl:if>
  295. <xsl:if test="$fragEvent != ''">
  296. <xsl:text>&amp;frag-event=</xsl:text><xsl:value-of select="$fragEvent"/>
  297. </xsl:if>
  298. <xsl:text>&amp;asynch.secondaryWaitThreshold=10</xsl:text>
  299. <xsl:if test="$selectionId = '' and $reportSpec = ''">
  300. <xsl:text>&amp;ui.action=noOp&amp;fragment.outputHint=showProgress</xsl:text>
  301. </xsl:if>
  302. </xsl:variable>
  303. <subfragment id="rvCanvas" href="{$href}">
  304. <params>
  305. <param name="frag-channel"/>
  306. <param name="frag-windowState">
  307. <xsl:choose>
  308. <xsl:when test="$fragWindowState">
  309. <xsl:value-of select="$fragWindowState"/>
  310. </xsl:when>
  311. <xsl:otherwise>
  312. <xsl:text>normal</xsl:text>
  313. </xsl:otherwise>
  314. </xsl:choose>
  315. </param>
  316. </params>
  317. </subfragment>
  318. </xsl:when>
  319. </xsl:choose>
  320. <xsl:if test="/root/controllerParams/param[@name='frag-mode']='edit' and /root/interactions/param[@name='formaction'] = 'save'">
  321. <newMode>view</newMode>
  322. </xsl:if>
  323. <xsl:if test="($titleSelection = 'entryName') and ($objectName != '') ">
  324. <preferredTitle>
  325. <xsl:value-of select="$objectName"/>
  326. </preferredTitle>
  327. </xsl:if>
  328. </fragment>
  329. </response>
  330. </xsl:template>
  331. <xsl:template match="param" mode="state">
  332. <xsl:if test="/root/input[@name='stateParams']/stateParams/param/@name=current()/@name">
  333. <xsl:copy-of select="."/>
  334. </xsl:if>
  335. </xsl:template>
  336. </xsl:stylesheet>