gen_rss.xslt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  15. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  16. xmlns:pm="http://developer.cognos.com/schemas/xts/pm"
  17. xmlns:mt="http://developer.cognos.com/schemas/xts/logicsheets/presentation/main/mt"
  18. xmlns:mf="http://developer.cognos.com/schemas/xts/logicsheets/presentation/main/mf"
  19. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  20. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  21. xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/"
  22. xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/"
  23. xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
  24. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  25. xmlns:rss="http://developer.cognos.com/schemas/xts/rss/"
  26. xmlns:out="dummy-uri"
  27. xmlns:cps="http://developer.cognos.com/schemas/cps/asm/objects/1/"
  28. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  29. exclude-result-prefixes="xsl cps cm pf pm mt mf xts xtsext cf cp rss out bus xts SOAP-ENV">
  30. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  31. <pf:variables/>
  32. <mf:variables mode="main"/>
  33. <mf:main-variables/>
  34. <rss:variables/>
  35. <xsl:variable name="source-url">
  36. <!-- link back to the actual CC page -->
  37. <xsl:value-of select="$abs-gateway"/>
  38. <xsl:for-each select="/root/env/param[@name != 'feed']">
  39. <xsl:choose>
  40. <xsl:when test="position() = 1">?</xsl:when>
  41. <xsl:otherwise>&amp;</xsl:otherwise>
  42. </xsl:choose>
  43. <xsl:value-of select="@name"/>=<xsl:value-of select="xtsext:protect(xtsext:urlencode(string(.)),'url', concat('NAME',@name),'getdata')"/>
  44. </xsl:for-each>
  45. </xsl:variable>
  46. <!-- start the output -->
  47. <xsl:template match="/root">
  48. <xsl:processing-instruction name="xml-stylesheet">
  49. <xsl:text/>type="text/xsl" href="<xsl:value-of select="$gateway"/>?b_action=xts.run<xsl:text/>
  50. <xsl:choose>
  51. <xsl:when test="$browser = 'ie'">&amp;amp;</xsl:when> <!-- ie seems to need this double encoded -->
  52. <xsl:otherwise>&amp;</xsl:otherwise>
  53. </xsl:choose>
  54. <xsl:text/>m=portal/rssxsl.xts"<xsl:text/>
  55. </xsl:processing-instruction>
  56. <xsl:variable name="linesPerPage">
  57. <xsl:value-of select="/root/session/param[@name='linesPerPage']"/>
  58. </xsl:variable>
  59. <rss version="2.0">
  60. <channel>
  61. <title><xsl:value-of select="title"/></title>
  62. <link><xsl:value-of select="$source-url"/></link>
  63. <description><xsl:value-of select="description"/></description>
  64. <language><xsl:value-of select="$contentLocale"/></language>
  65. <xsl:for-each select="objs/*">
  66. <xsl:if test="position() &lt;= $linesPerPage">
  67. <xsl:apply-templates select="."/>
  68. </xsl:if>
  69. </xsl:for-each>
  70. </channel>
  71. </rss>
  72. </xsl:template>
  73. <xsl:template match="nav:item">
  74. <xsl:if test="nav:defaultAction">
  75. <item>
  76. <xsl:call-template name="common-stuff">
  77. <xsl:with-param name="isNavContent" select="true()"/>
  78. </xsl:call-template>
  79. <link>
  80. <xsl:value-of select="$abs-gateway"/>?<xsl:text/>
  81. <xsl:for-each select="nav:defaultAction/nav:urlParts/nav:param">
  82. <xsl:text/>&amp;<xsl:value-of select="@name"/>=<xsl:text/>
  83. <xsl:choose>
  84. <xsl:when test="@name='m_path' or @name='m_obj'">
  85. <xsl:value-of select="xtsext:protect(xtsext:urlencode(string(.)),'url','searchPath','getdata')"/>
  86. </xsl:when>
  87. <xsl:when test="@name='@m_name'">
  88. <xsl:value-of select="xtsext:protect(xtsext:urlencode(string(.)),'url','userData','getdata')"/>
  89. </xsl:when>
  90. <xsl:otherwise>
  91. <xsl:value-of select="xtsext:urlencode(string(.))"/>
  92. </xsl:otherwise>
  93. </xsl:choose>
  94. </xsl:for-each>
  95. </link>
  96. </item>
  97. </xsl:if>
  98. </xsl:template>
  99. <xsl:template match="cm:query | cm:report | cm:analysis | cm:reportView">
  100. <xsl:if test="cm:defaultOutputFormat/* or contains(cm:permissions, 'execute')">
  101. <item>
  102. <xsl:call-template name="common-stuff"/>
  103. <link>
  104. <xsl:value-of select="$abs-gateway"/>?<xsl:text/>
  105. <xsl:text/>b_action=xts.run&amp;m=portal/launch.xts<xsl:text/>
  106. <xsl:text/>&amp;ui.tool=CognosViewer<xsl:text/>
  107. <xsl:choose>
  108. <xsl:when test="cm:defaultOutputFormat/*">
  109. <xsl:text/>&amp;ui.action=view<xsl:text/>
  110. <xsl:text/>&amp;ui.object=<xsl:value-of select="xtsext:protect(xtsext:urlencode( concat('defaultOutput(', cm:searchPath, ')' ) ),'url','searchPath','getdata')"/><xsl:text/>
  111. </xsl:when>
  112. <xsl:when test="contains(cm:permissions, 'execute')">
  113. <xsl:text/>&amp;ui.action=run<xsl:text/>
  114. <xsl:text/>&amp;ui.object=<xsl:value-of select="xtsext:protect(xtsext:urlencode( string( cm:searchPath ) ),'url','searchPath','getdata')"/>
  115. </xsl:when>
  116. </xsl:choose>
  117. </link>
  118. </item>
  119. </xsl:if>
  120. </xsl:template>
  121. <xsl:template match="cm:output">
  122. <item>
  123. <xsl:call-template name="common-stuff"/>
  124. <link>
  125. <xsl:value-of select="$abs-gateway"/>?<xsl:text/>
  126. <xsl:text/>b_action=xts.run&amp;m=portal/launch.xts<xsl:text/>
  127. <xsl:text/>&amp;ui.tool=CognosViewer<xsl:text/>
  128. <xsl:text/>&amp;ui.action=view<xsl:text/>
  129. <xsl:text/>&amp;ui.object=<xsl:value-of select="xtsext:protect(xtsext:urlencode( string( cm:searchPath ) ),'url','searchPath','getdata')"/>
  130. <xsl:if test="contains(string(../../cm:target/*/*[local-name()='searchPath']),'agentOutputHotList')">
  131. <xsl:text/>&amp;cv.toolbar=false<xsl:text/>
  132. </xsl:if>
  133. </link>
  134. </item>
  135. </xsl:template>
  136. <xsl:template match="cm:folder | cm:package">
  137. <xsl:choose>
  138. <xsl:when test="cm:userInterfaces[cm:uiComponentEnum = 'metricStudio'] and cm:defaultPortalAction = 'run'">
  139. <item>
  140. <xsl:call-template name="common-stuff"/>
  141. <link>
  142. <xsl:value-of select="$abs-gateway"/>?<xsl:text/>
  143. <xsl:text/>b_action=xts.run&amp;m=portal/launch.xts<xsl:text/>
  144. <xsl:text/>&amp;ui.tool=MetricStudio<xsl:text/>
  145. <xsl:text/>&amp;ui.object=<xsl:value-of select="xtsext:protect(xtsext:urlencode( string( cm:searchPath ) ),'url','searchPath','getdata')"/>
  146. <xsl:text/>&amp;ui.action=run<xsl:text/>
  147. </link>
  148. </item>
  149. </xsl:when>
  150. <xsl:otherwise>
  151. <xsl:if test="contains(cm:permissions, 'traverse')">
  152. <item>
  153. <xsl:call-template name="common-stuff"/>
  154. <link>
  155. <xsl:value-of select="$abs-gateway"/>?<xsl:text/>
  156. <xsl:text/>b_action=xts.run&amp;m=portal/cc.xts<xsl:text/>
  157. <xsl:text/>&amp;m_path=<xsl:value-of select="xtsext:protect(xtsext:urlencode( string( cm:searchPath ) ),'url','searchPath','getdata')"/>
  158. </link>
  159. </item>
  160. </xsl:if>
  161. </xsl:otherwise>
  162. </xsl:choose>
  163. </xsl:template>
  164. <xsl:template match="*[cm:uri]">
  165. <item>
  166. <xsl:call-template name="common-stuff"/>
  167. <link><xsl:value-of select="cm:uri"/></link>
  168. </item>
  169. </xsl:template>
  170. <xsl:template match="cm:powerPlayCube | cm:powerPlayReport | cm:powerPlay8Report">
  171. <xsl:if test="contains(cm:permissions, 'read') or contains(cm:permissions, 'execute')">
  172. <item>
  173. <xsl:call-template name="common-stuff"/>
  174. <link>
  175. <xsl:choose>
  176. <xsl:when test="cm:objectClass = 'powerPlay8Report'">
  177. <xsl:call-template name="buildpp8">
  178. <xsl:with-param name="thisnode" select="."/>
  179. <xsl:with-param name="target-path" select="cm:searchPath"/>
  180. <xsl:with-param name="action" select="'run'"/>
  181. </xsl:call-template>
  182. </xsl:when>
  183. <xsl:otherwise>
  184. <xsl:call-template name="buildpp">
  185. <xsl:with-param name="thisnode" select="."/>
  186. <xsl:with-param name="target-path" select="cm:searchPath"/>
  187. <xsl:with-param name="action" select="'run'"/>
  188. </xsl:call-template>
  189. </xsl:otherwise>
  190. </xsl:choose>
  191. </link>
  192. </item>
  193. </xsl:if>
  194. </xsl:template>
  195. <xsl:template match="cm:shortcut">
  196. <xsl:apply-templates select="cm:target/*"/>
  197. </xsl:template>
  198. <xsl:template match="cm:history">
  199. <item>
  200. <title><xsl:value-of select="cm:parent/*/cm:defaultName"/></title>
  201. <description>
  202. <xsl:choose>
  203. <xsl:when test="cm:parent/*/cm:defaultDescription != ''"><xsl:value-of select="cm:parent/*/cm:defaultDescription"/></xsl:when>
  204. <xsl:when test="cm:parent/*/cm:defaultScreenTip != ''"><xsl:value-of select="cm:parent/*/cm:defaultScreenTip"/></xsl:when>
  205. <xsl:otherwise><xsl:value-of select="cm:parent/*/cm:defaultName"/></xsl:otherwise>
  206. </xsl:choose>
  207. </description>
  208. <pubDate>
  209. <xsl:value-of select="xtsext:formatDateFromUTC( string( cm:actualCompletionTime ), 'E, d MMM yyyy HH:mm:ss zz', string( $timeZone ), string( $contentLocale ) )"/>
  210. </pubDate>
  211. <link>
  212. <xsl:value-of select="$abs-gateway"/>?<xsl:text/>
  213. <xsl:text/>b_action=xts.run&amp;m=portal/history/view_details.xts<xsl:text/>
  214. <xsl:text/>&amp;m_class=<xsl:value-of select="cm:parent/*/cm:objectClass"/>
  215. <xsl:text/>&amp;m_obj=<xsl:value-of select="xtsext:protect(xtsext:urlencode( string( cm:searchPath ) ),'url','searchPath','getdata')"/>
  216. </link>
  217. </item>
  218. </xsl:template>
  219. <xsl:template match="cm:pagelet">
  220. <item>
  221. <xsl:call-template name="common-stuff"/>
  222. <link>
  223. <xsl:value-of select="$abs-gateway"/>?<xsl:text/>
  224. <xsl:text/>b_action=dashboard&amp;pathinfo=/cm<xsl:text/>
  225. <xsl:text/>&amp;path=storeID(&quot;<xsl:value-of select="cm:storeID"/>&quot;)<xsl:text/>
  226. </link>
  227. </item>
  228. </xsl:template>
  229. <xsl:template match="*"/>
  230. <xsl:template name="common-stuff">
  231. <xsl:param name="isNavContent" select="false()"/>
  232. <xsl:variable name="is-shortcut-tgt" select="ancestor::*[1][name() = 'cm:target']"/>
  233. <xsl:choose>
  234. <xsl:when test="$is-shortcut-tgt">
  235. <xsl:for-each select="ancestor::*[2]">
  236. <xsl:call-template name="common-stuff">
  237. <xsl:with-param name="isNavContent" select="$isNavContent"/>
  238. </xsl:call-template>
  239. </xsl:for-each>
  240. </xsl:when>
  241. <xsl:otherwise>
  242. <title>
  243. <xsl:choose>
  244. <xsl:when test="$isNavContent"><xsl:value-of select="nav:name"/></xsl:when>
  245. <xsl:otherwise><xsl:value-of select="cm:defaultName"/></xsl:otherwise>
  246. </xsl:choose>
  247. </title>
  248. <description>
  249. <xsl:choose>
  250. <xsl:when test="$isNavContent">
  251. <xsl:choose>
  252. <xsl:when test="nav:description != ''"><xsl:value-of select="nav:description"/></xsl:when>
  253. <xsl:when test="nav:screenTip != ''"><xsl:value-of select="nav:screenTip"/></xsl:when>
  254. <xsl:otherwise><xsl:value-of select="nav:name"/></xsl:otherwise>
  255. </xsl:choose>
  256. </xsl:when>
  257. <xsl:otherwise>
  258. <xsl:choose>
  259. <xsl:when test="cm:defaultDescription != ''"><xsl:value-of select="cm:defaultDescription"/></xsl:when>
  260. <xsl:when test="cm:defaultScreenTip != ''"><xsl:value-of select="cm:defaultScreenTip"/></xsl:when>
  261. <xsl:otherwise><xsl:value-of select="cm:defaultName"/></xsl:otherwise>
  262. </xsl:choose>
  263. </xsl:otherwise>
  264. </xsl:choose>
  265. </description>
  266. <pubDate>
  267. <xsl:choose>
  268. <xsl:when test="$isNavContent"><xsl:value-of select="nav:lastModifiedDate"/></xsl:when>
  269. <xsl:otherwise><xsl:value-of select="xtsext:formatDateFromUTC( string( cm:modificationTime ), 'E, d MMM yyyy HH:mm:ss zz', string( $timeZone ), string( $contentLocale ) )"/></xsl:otherwise>
  270. </xsl:choose>
  271. </pubDate>
  272. </xsl:otherwise>
  273. </xsl:choose>
  274. </xsl:template>
  275. <pf:gen-action/>
  276. <pf:gen-url/>
  277. </xsl:stylesheet>