cps-portlet.xslt 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  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, 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. <!-- $Header: //cpscrn/main/templates/cps4/producer/logicsheets/cps-portlet.xslt#1 $ -->
  13. <!-- $DateTime: 2008/10/22 11:12:04 $ -->
  14. <!-- $Change: 25109 $ -->
  15. <!-- NOTE: nodelist requirements for this logicsheet: envelope,session,system,configProps -->
  16. <xsl:stylesheet version="1.0"
  17. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  18. xmlns:out="dummy-uri"
  19. xmlns:java="java:com.cognos.portal.utils.CCLLocaleUtils"
  20. xmlns:bidi="java:com.cognos.portal.utils.BidiUtils"
  21. xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"
  22. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  23. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  24. xmlns:crn="http://developer.cognos.com/schemas/crconfig/1/"
  25. xmlns:cps="http://developer.cognos.com/schemas/cps/asm/objects/1/"
  26. xmlns:portlet="http://developer.cognos.com/schemas/cps/logic/portlet/1/"
  27. xmlns:soap="http://developer.cognos.com/schemas/cps/logic/soap"
  28. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  29. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  30. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  31. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  32. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  33. <xsl:template match="xsl:stylesheet" priority="1">
  34. <xsl:copy>
  35. <xsl:apply-templates select="@*"/>
  36. <out:variable name="portlet-op" select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Body/*[1]"/>
  37. <out:variable name="portlet-op-name" select="local-name( $portlet-op )"/>
  38. <out:variable name="portlet-markups" select="$portlet-op/wsrp:markupParams"/>
  39. <out:variable name="portlet-session-params" select="/root/session/param"/>
  40. <out:variable name="portlet-state-params" select="$portlet-op/wsrp:portletContext/wsrp:portletState/param"/>
  41. <out:variable name="portlet-registration-params" select="$portlet-op/wsrp:registrationContext/wsrp:registrationState/param"/>
  42. <out:variable name="portlet-navigational-params" select="$portlet-markups/wsrp:navigationalState/param"/>
  43. <out:variable name="portlet-interaction-params" select="$portlet-op/wsrp:interactionParams"/>
  44. <out:variable name="portlet-form-params" select="$portlet-op/wsrp:interactionParams/wsrp:formParameters"/>
  45. <out:variable name="portlet-configuration" select="/root/configProps/param[@name='cps']/property"/>
  46. <out:variable name="portlet-system-params" select="/root/system/param"/>
  47. <out:variable name="portlet-mode" select="$portlet-markups/wsrp:mode"/>
  48. <out:variable name="portlet-window-state" select="$portlet-markups/wsrp:windowState"/>
  49. <out:variable name="portlet-product-locale" select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Header/bus:biBusHeader/bus:userPreferenceVars/item[name='productLocale']/value"/>
  50. <out:variable name="portlet-content-locale" select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Header/bus:biBusHeader/bus:userPreferenceVars/item[name='contentLocale']/value"/>
  51. <out:variable name="portlet-is-ui-rtl" select="bidi:isRTLLocale(string($portlet-product-locale))"/>
  52. <out:variable name="portlet-user-preferences" select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Header/bus:biBusHeader/bus:userPreferenceVars"/>
  53. <out:variable name="portlet-isBidiEnabled">
  54. <out:choose>
  55. <out:when test="$portlet-user-preferences/item[name='http://developer.cognos.com/ceba/constants/biDirectionalOptionEnum#biDirectionalFeaturesEnabled']/value != ''">
  56. <out:value-of select="$portlet-user-preferences/item[name='http://developer.cognos.com/ceba/constants/biDirectionalOptionEnum#biDirectionalFeaturesEnabled']/value = 'true'"/>
  57. </out:when>
  58. <out:otherwise>false()</out:otherwise>
  59. </out:choose>
  60. </out:variable>
  61. <out:variable name="portlet-baseTextDirection">
  62. <out:variable name="ns_name">
  63. <out:value-of select="$portlet-user-preferences/item[name='http://developer.cognos.com/ceba/constants/biDirectionalOptionEnum#baseTextDirection']/value"/>
  64. </out:variable>
  65. <out:choose>
  66. <out:when test="$ns_name != ''">
  67. <out:value-of select="translate(substring-after($ns_name,'#'),'LTRA','ltra')"/>
  68. </out:when>
  69. <out:otherwise>auto</out:otherwise>
  70. </out:choose>
  71. </out:variable>
  72. <out:variable name="portlet-is-cognos-connection" select="$portlet-markups/wsrp:extensions/cps:portalContext/cps:portalAgent = 'cognos'"/>
  73. <out:variable name="portlet-is-myportal" select="$portlet-markups/wsrp:extensions/cps:portalContext/cps:portalAgent = 'cognosFragmentServer'"/>
  74. <xsl:apply-templates select="*|text()|processing-instruction()"/>
  75. <xsl:apply-templates select="//portlet:content" mode="gen-code"/>
  76. <out:template name="portlet-get-property">
  77. <out:param name="property-name"/>
  78. <out:param name="property-exclude-form-input" select="'true'"/>
  79. <out:param name="property-exclude-nav-state" select="'false'"/>
  80. <out:param name="property-exclude-session-state" select="'false'"/>
  81. <out:param name="property-default" select="''"/>
  82. <out:choose>
  83. <!-- level 1: form params (when performBlockingInteraction) -->
  84. <out:when test="not($property-exclude-form-input = 'true') and ($portlet-form-params[@name = string( $property-name )])">
  85. <out:value-of select="$portlet-form-params[@name = string( $property-name )]/wsrp:value"/>
  86. </out:when>
  87. <!-- level 2: navigational params -->
  88. <out:when test="not($property-exclude-nav-state = 'true') and ($portlet-navigational-params[@name = string( $property-name )])">
  89. <out:value-of select="$portlet-navigational-params[@name = string( $property-name )]"/>
  90. </out:when>
  91. <!-- level 3: session states -->
  92. <out:when test="not($property-exclude-session-state = 'true') and ($portlet-session-params[@name = string( $property-name )] != '')">
  93. <out:value-of select="$portlet-session-params[@name = string( $property-name )]"/>
  94. </out:when>
  95. <!-- level 4: portlet states -->
  96. <out:when test="$portlet-state-params[@name = string( $property-name )]">
  97. <out:value-of select="$portlet-state-params[@name = string( $property-name )]"/>
  98. </out:when>
  99. <!-- level 5: registration params -->
  100. <out:when test="$portlet-registration-params[@name = string( $property-name )] != ''">
  101. <out:value-of select="$portlet-registration-params[@name = string( $property-name )]"/>
  102. </out:when>
  103. <!-- level 6: configuration API (either property[@name] or property['CPS']/parameter[@name]) -->
  104. <out:when test="$portlet-configuration[@name = string( $property-name )] != ''">
  105. <out:value-of select="$portlet-configuration[@name = string( $property-name )]"/>
  106. </out:when>
  107. <out:when test="$portlet-configuration[@name = 'CPS']/crn:value/crn:parameter[@name = string( $property-name )]/crn:value != ''">
  108. <out:value-of select="$portlet-configuration[@name = 'CPS']/crn:value/crn:parameter[@name = string( $property-name )]/crn:value"/>
  109. </out:when>
  110. <!-- level 7: system params -->
  111. <out:when test="$portlet-system-params[@name = string( $property-name )] != ''">
  112. <out:value-of select="$portlet-system-params[@name = string( $property-name )]"/>
  113. </out:when>
  114. <!-- level 8: default in the code -->
  115. <out:otherwise>
  116. <out:value-of select="$property-default"/>
  117. </out:otherwise>
  118. </out:choose>
  119. </out:template>
  120. </xsl:copy>
  121. </xsl:template>
  122. <xsl:template match="portlet:passport" priority="1">
  123. <out:variable name="passport">
  124. <out:choose>
  125. <!-- pull the passport out of the bus header -->
  126. <out:when test="/root/credential/param[@name='CAM']/*[local-name() ='CAM']/*[local-name() = 'CAMPassport']/*[local-name() = 'id']">
  127. <out:value-of select="/root/credential/param[@name='CAM']/*[local-name() ='CAM']/*[local-name() = 'CAMPassport']/*[local-name() = 'id']"/>
  128. </out:when>
  129. <!-- For those blocks that specify node list and execlude <credential> node -->
  130. <out:when test="/root/header/*[local-name() = 'biBusHeader']/*[local-name()= 'CAM']/CAMPassport/id">
  131. <out:value-of select="/root/header/*[local-name() = 'biBusHeader']/*[local-name()= 'CAM']/CAMPassport/id"/>
  132. </out:when>
  133. <!-- For those super rare cases where both <credential> and <header> elements are not available - or - the passport is being cleared -->
  134. <out:otherwise>
  135. <out:variable name="CAMPassportCookie">
  136. <out:choose>
  137. <out:when test="/root/setCookies/cookie[@name='cam_passport' and string(@maxAge) != '-1']">
  138. <out:value-of select="string(/root/setCookies/cookie[@name='cam_passport'])"/>
  139. </out:when>
  140. <out:otherwise>
  141. <out:value-of select="string(/root/cookies/cookie[@name='cam_passport'])"/>
  142. </out:otherwise>
  143. </out:choose>
  144. </out:variable>
  145. <out:value-of select="xtsext:camcookie_action('getPassportID', $CAMPassportCookie)"/>
  146. </out:otherwise>
  147. </out:choose>
  148. </out:variable>
  149. </xsl:template>
  150. <xsl:template match="portlet:property" priority="1">
  151. <xsl:choose>
  152. <xsl:when test="@name">
  153. <out:variable name="{ @name }">
  154. <out:call-template name="portlet-get-property">
  155. <out:with-param name="property-name">
  156. <xsl:choose>
  157. <xsl:when test="@select">
  158. <out:value-of select="{ @select }"/>
  159. </xsl:when>
  160. <xsl:otherwise>
  161. <xsl:apply-templates/>
  162. </xsl:otherwise>
  163. </xsl:choose>
  164. </out:with-param>
  165. <xsl:if test="@default">
  166. <out:with-param name="property-default">
  167. <out:value-of select="{ @default }"/>
  168. </out:with-param>
  169. </xsl:if>
  170. <xsl:if test="@exclude-form-input">
  171. <out:with-param name="property-exclude-form-input">
  172. <out:value-of select="{ @exclude-form-input }"/>
  173. </out:with-param>
  174. </xsl:if>
  175. <xsl:if test="@exclude-nav-state">
  176. <out:with-param name="property-exclude-nav-state">
  177. <out:value-of select="{ @exclude-nav-state }"/>
  178. </out:with-param>
  179. </xsl:if>
  180. <xsl:if test="@exclude-session-state">
  181. <out:with-param name="property-exclude-session-state">
  182. <out:value-of select="{ @exclude-session-state }"/>
  183. </out:with-param>
  184. </xsl:if>
  185. </out:call-template>
  186. </out:variable>
  187. </xsl:when>
  188. <xsl:otherwise>
  189. <xsl:call-template name="portlet-compile-error">
  190. <xsl:with-param name="errno">0001</xsl:with-param>
  191. <xsl:with-param name="errmsg">Missing mandatory attribute: name (xsd:string)</xsl:with-param>
  192. </xsl:call-template>
  193. </xsl:otherwise>
  194. </xsl:choose>
  195. </xsl:template>
  196. <xsl:template match="portlet:portlet" priority="1">
  197. <xsl:choose>
  198. <xsl:when test="@handle">
  199. <xsl:apply-templates/>
  200. </xsl:when>
  201. <xsl:otherwise>
  202. <xsl:call-template name="portlet-compile-error">
  203. <xsl:with-param name="errno">0002</xsl:with-param>
  204. <xsl:with-param name="errmsg">Missing mandatory attribute: handle (xsd:string)</xsl:with-param>
  205. </xsl:call-template>
  206. </xsl:otherwise>
  207. </xsl:choose>
  208. </xsl:template>
  209. <xsl:template match="portlet:soap-fault" priority="1">
  210. <xsl:choose>
  211. <xsl:when test="not(ancestor::portlet:soap-response)">
  212. <xsl:call-template name="portlet-compile-error">
  213. <xsl:with-param name="errno">0022</xsl:with-param>
  214. <xsl:with-param name="errmsg">Missing ancestor tag: soap-response</xsl:with-param>
  215. </xsl:call-template>
  216. </xsl:when>
  217. <xsl:when test="not(@select)">
  218. <xsl:call-template name="portlet-compile-error">
  219. <xsl:with-param name="errno">0023</xsl:with-param>
  220. <xsl:with-param name="errmsg">Missing mandatory attribute: select</xsl:with-param>
  221. </xsl:call-template>
  222. </xsl:when>
  223. <xsl:otherwise>
  224. <SOAP-ENV:Fault>
  225. <out:variable name="error" select="{@select}"/>
  226. <out:choose>
  227. <out:when test="$error/@type = 'invalidCookie'">
  228. <faultcode xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types" wsrp:dummy="">wsrp:InvalidCookie</faultcode>
  229. <faultstring><out:value-of select="$error/message"/></faultstring>
  230. <detail>
  231. <wsrp:InvalidCookie xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types" />
  232. </detail>
  233. </out:when>
  234. <out:otherwise>
  235. <faultcode xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types">wsrp:OperationFailed</faultcode>
  236. <faultstring>Normal execution of the operation failed.</faultstring>
  237. <detail>
  238. <wsrp:OperationFailed xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"/>
  239. <out:copy-of select="$error"/>
  240. </detail>
  241. </out:otherwise>
  242. </out:choose>
  243. </SOAP-ENV:Fault>
  244. </xsl:otherwise>
  245. </xsl:choose>
  246. </xsl:template>
  247. <xsl:template match="portlet:soap-response" priority="1">
  248. <xts:sequence>
  249. <xts:append select="/root/output">
  250. <xos:part xmlns:xos="http://developer.cognos.com/schemas/xts/output/">
  251. <xos:entityHeader>
  252. <xos:param name="Content-Type">text/xml; charset=utf-8</xos:param>
  253. </xos:entityHeader>
  254. <xos:entityBody>
  255. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  256. <out:copy-of select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Header"/>
  257. <SOAP-ENV:Body>
  258. <xsl:apply-templates/>
  259. </SOAP-ENV:Body>
  260. </SOAP-ENV:Envelope>
  261. </xos:entityBody>
  262. </xos:part>
  263. </xts:append>
  264. </xts:sequence>
  265. </xsl:template>
  266. <xsl:template match="portlet:response" priority="1">
  267. <out:element name="wsrp:{'{ '}$portlet-op-name{' }'}Response" namespace="urn:oasis:names:tc:wsrp:v1:types">
  268. <xsl:apply-templates/>
  269. </out:element>
  270. </xsl:template>
  271. <xsl:template match="portlet:redirectURL" priority="1">
  272. <xsl:choose>
  273. <xsl:when test="child::node()">
  274. <wsrp:redirectURL>
  275. <xsl:apply-templates/>
  276. </wsrp:redirectURL>
  277. </xsl:when>
  278. <xsl:otherwise>
  279. <xsl:call-template name="portlet-compile-error">
  280. <xsl:with-param name="errno">0003</xsl:with-param>
  281. <xsl:with-param name="errmsg">Empty tag is not allowed here '<xsl:value-of select="name(.)"/>'</xsl:with-param>
  282. </xsl:call-template>
  283. </xsl:otherwise>
  284. </xsl:choose>
  285. </xsl:template>
  286. <xsl:template match="portlet:content" priority="1">
  287. <out:choose>
  288. <out:when test="$portlet-op-name = 'performBlockingInteraction'">
  289. <wsrp:updateResponse>
  290. <out:call-template name="{ generate-id() }"/>
  291. </wsrp:updateResponse>
  292. </out:when>
  293. <out:otherwise>
  294. <out:call-template name="{ generate-id() }"/>
  295. </out:otherwise>
  296. </out:choose>
  297. </xsl:template>
  298. <xsl:template match="portlet:content" mode="gen-code" priority="1">
  299. <out:template name="{ generate-id() }">
  300. <xsl:apply-templates/>
  301. </out:template>
  302. </xsl:template>
  303. <xsl:template match="portlet:session-context" priority="1">
  304. <wsrp:sessionContext>
  305. <xsl:choose>
  306. <xsl:when test="@sessionID">
  307. <wsrp:sessionID>
  308. <out:value-of select="{ @sessionID }"/>
  309. </wsrp:sessionID>
  310. </xsl:when>
  311. <xsl:otherwise>
  312. <xsl:call-template name="portlet-compile-error">
  313. <xsl:with-param name="errno">0004</xsl:with-param>
  314. <xsl:with-param name="errmsg">Missing mandatory attribute: sessionID (xsd:string)</xsl:with-param>
  315. </xsl:call-template>
  316. </xsl:otherwise>
  317. </xsl:choose>
  318. <xsl:choose>
  319. <xsl:when test="@expires">
  320. <wsrp:expires>
  321. <out:value-of select="{ @expires }"/>
  322. </wsrp:expires>
  323. </xsl:when>
  324. <xsl:otherwise>
  325. <xsl:call-template name="portlet-compile-error">
  326. <xsl:with-param name="errno">0005</xsl:with-param>
  327. <xsl:with-param name="errmsg">Missing mandatory attribute: expires (xsd:boolean)</xsl:with-param>
  328. </xsl:call-template>
  329. </xsl:otherwise>
  330. </xsl:choose>
  331. <xsl:apply-templates/>
  332. </wsrp:sessionContext>
  333. </xsl:template>
  334. <xsl:template match="portlet:portlet-context" priority="1">
  335. <out:if test="$portlet-op-name = 'performBlockingInteraction'">
  336. <wsrp:portletContext>
  337. <wsrp:portletHandle>
  338. <out:value-of select="$portlet-op/wsrp:portletContext/wsrp:portletHandle"/>
  339. <out:if test="not( contains( $portlet-op/wsrp:portletContext/wsrp:portletHandle, ':' ) )">
  340. <out:value-of select="concat(':', xtsext:generateGUID())"/>
  341. </out:if>
  342. </wsrp:portletHandle>
  343. <wsrp:portletState>
  344. <xsl:choose>
  345. <xsl:when test="@portletState">
  346. <out:value-of select="xtsext:base64encode(string({ @portletState }), true())"/>
  347. </xsl:when>
  348. <xsl:otherwise>
  349. <out:variable name="portlet-state">
  350. <xsl:apply-templates/>
  351. </out:variable>
  352. <out:value-of select="xtsext:base64encode(string($portlet-state), true())"/>
  353. </xsl:otherwise>
  354. </xsl:choose>
  355. </wsrp:portletState>
  356. </wsrp:portletContext>
  357. </out:if>
  358. </xsl:template>
  359. <xsl:template match="portlet:markup-context" priority="1">
  360. <wsrp:markupContext>
  361. <wsrp:useCachedMarkup>
  362. <xsl:choose>
  363. <xsl:when test="@useCachedMarkup">
  364. <out:value-of select="{ @useCachedMarkup }"/>
  365. </xsl:when>
  366. <xsl:otherwise>false</xsl:otherwise>
  367. </xsl:choose>
  368. </wsrp:useCachedMarkup>
  369. <wsrp:mimeType>
  370. <xsl:choose>
  371. <xsl:when test="@mimeType">
  372. <out:value-of select="{ @mimeType }"/>
  373. </xsl:when>
  374. <xsl:otherwise>text/html</xsl:otherwise>
  375. </xsl:choose>
  376. </wsrp:mimeType>
  377. <xsl:apply-templates/>
  378. <xsl:if test="@preferredTitle">
  379. <wsrp:preferredTitle>
  380. <out:value-of select="{ @preferredTitle }"/>
  381. </wsrp:preferredTitle>
  382. </xsl:if>
  383. </wsrp:markupContext>
  384. </xsl:template>
  385. <xsl:template match="portlet:navigational-state" priority="1">
  386. <out:if test="$portlet-op-name = 'performBlockingInteraction'">
  387. <wsrp:navigationalState>
  388. <out:variable name="portlet-markup">
  389. <xsl:if test="@select">
  390. <out:for-each select="{ @select }">
  391. <out:value-of select="concat('&lt;param name=&quot;', @name, '&quot;&gt;', xtsext:xmlencode(.), '&lt;/param&gt;')"/>
  392. </out:for-each>
  393. </xsl:if>
  394. <xsl:apply-templates/>
  395. </out:variable>
  396. <out:value-of select="xtsext:validator('prepare','portlet-markup',xtsext:base64encode($portlet-markup, true()))"/>
  397. </wsrp:navigationalState>
  398. </out:if>
  399. </xsl:template>
  400. <xsl:template match="portlet:param" priority="1">
  401. <out:variable name="portlet-{generate-id()}value">
  402. <xsl:apply-templates/>
  403. </out:variable>
  404. <out:value-of select="concat('&lt;param name=&quot;', { @name }, '&quot;&gt;', xtsext:xmlencode($portlet-{generate-id()}value), '&lt;/param&gt;')"/>
  405. </xsl:template>
  406. <xsl:template match="portlet:markup-string" priority="1">
  407. <wsrp:markupString>
  408. <xsl:if test="child::node()">
  409. <xts:transform name="XMLEncode" option="content">
  410. <xsl:apply-templates/>
  411. </xts:transform>
  412. </xsl:if>
  413. </wsrp:markupString>
  414. <wsrp:locale>
  415. <xsl:choose>
  416. <xsl:when test="ancestor::portlet:markup-context/@locale">
  417. <out:value-of select="{ ancestor::portlet:markup-context/@locale }"/>
  418. </xsl:when>
  419. <xsl:otherwise>en</xsl:otherwise>
  420. </xsl:choose>
  421. </wsrp:locale>
  422. <xsl:if test="ancestor::portlet:markup-context/@requiresUrlRewriting">
  423. <wsrp:requiresUrlRewriting>
  424. <out:value-of select="{ ancestor::portlet:markup-context/@requiresUrlRewriting }"/>
  425. </wsrp:requiresUrlRewriting>
  426. </xsl:if>
  427. </xsl:template>
  428. <xsl:template match="portlet:markup-transform" priority="1">
  429. <wsrp:markupString>
  430. <xts:transform name="XMLEncode" option="content">
  431. <out:if test="$portlet-registration-params[@name = 'consumerAgent'] = 'liferay'">
  432. <out:text disable-output-escaping="yes">&lt;div style='overflow:auto'&gt;</out:text>
  433. </out:if>
  434. <xsl:choose>
  435. <xsl:when test="@name = 'XML'">
  436. <xts:transform name="XML" cache="false">
  437. <xts:param name="systemId">no-cache-id</xts:param>
  438. <xts:param name="messageBaseLocale">
  439. <out:value-of select="$portlet-product-locale"/>
  440. </xts:param>
  441. <xsl:apply-templates/>
  442. </xts:transform>
  443. </xsl:when>
  444. <xsl:when test="@name = 'XSLT'">
  445. <xsl:choose>
  446. <xsl:when test="@src">
  447. <xts:transform name="XSLT" src="{'{'}{ @src }{'}'}">
  448. <xts:param name="messageBaseLocale">
  449. <out:value-of select="$portlet-product-locale"/>
  450. </xts:param>
  451. <xsl:apply-templates/>
  452. </xts:transform>
  453. </xsl:when>
  454. <xsl:otherwise>
  455. <xsl:call-template name="portlet-compile-error">
  456. <xsl:with-param name="errno">0010</xsl:with-param>
  457. <xsl:with-param name="errmsg">Missing mandatory attribute name: src (xsd:string)</xsl:with-param>
  458. </xsl:call-template>
  459. </xsl:otherwise>
  460. </xsl:choose>
  461. </xsl:when>
  462. <xsl:otherwise>
  463. <xsl:call-template name="portlet-compile-error">
  464. <xsl:with-param name="errno">0011</xsl:with-param>
  465. <xsl:with-param name="errmsg">Unsupported transformation name: '<xsl:value-of select="@name"/>'</xsl:with-param>
  466. </xsl:call-template>
  467. </xsl:otherwise>
  468. </xsl:choose>
  469. <out:if test="$portlet-registration-params[@name = 'consumerAgent'] = 'liferay'">
  470. <out:text disable-output-escaping="yes">&lt;/div&gt;</out:text>
  471. </out:if>
  472. </xts:transform>
  473. </wsrp:markupString>
  474. <wsrp:locale>
  475. <xsl:choose>
  476. <xsl:when test="ancestor::portlet:markup-context/@locale">
  477. <out:value-of select="{ ancestor::portlet:markup-context/@locale }"/>
  478. </xsl:when>
  479. <xsl:otherwise>en</xsl:otherwise>
  480. </xsl:choose>
  481. </wsrp:locale>
  482. <xsl:if test="ancestor::portlet:markup-context/@requiresUrlRewriting">
  483. <wsrp:requiresUrlRewriting>
  484. <out:value-of select="{ ancestor::portlet:markup-context/@requiresUrlRewriting }"/>
  485. </wsrp:requiresUrlRewriting>
  486. </xsl:if>
  487. </xsl:template>
  488. <xsl:template match="portlet:markup-preview" priority="1">
  489. <xsl:choose>
  490. <xsl:when test="not(ancestor::portlet:portlet[1]/@handle)">
  491. <xsl:call-template name="portlet-compile-error">
  492. <xsl:with-param name="errno">0025</xsl:with-param>
  493. <xsl:with-param name="errmsg">Missing ancestor tag: portlet with handle attribute</xsl:with-param>
  494. </xsl:call-template>
  495. </xsl:when>
  496. <xsl:otherwise>
  497. <xts:transform processor="XSLT" src="/cps4/producer/wsrp-impl/transforms/preview-help.xslt">
  498. <xts:param name="messageBaseLocale">
  499. <out:value-of select="$portlet-product-locale"/>
  500. </xts:param>
  501. <xts:param name="logicsheet">/cps4/producer/logicsheets/cps-ui.xslt</xts:param>
  502. <xts:param name="messageBase">/cps4/producer/messages/cpsproducermsgs.xml</xts:param>
  503. <xts:param name="systemId">/cps4/producer/wsrp-impl/transforms/preview-help.xslt</xts:param>
  504. <root>
  505. <xts:queryNode select="/root/envelope | /root/system | /root/configProps | /root/interfaces"/>
  506. <portlet id="{ ancestor::portlet:portlet[1]/@handle }"/>
  507. </root>
  508. </xts:transform>
  509. </xsl:otherwise>
  510. </xsl:choose>
  511. </xsl:template>
  512. <xsl:template match="portlet:markup-help" priority="1">
  513. <xsl:choose>
  514. <xsl:when test="not(ancestor::portlet:portlet[1]/@handle)">
  515. <xsl:call-template name="portlet-compile-error">
  516. <xsl:with-param name="errno">0020</xsl:with-param>
  517. <xsl:with-param name="errmsg">Missing ancestor tag: portlet with handle attribute</xsl:with-param>
  518. </xsl:call-template>
  519. </xsl:when>
  520. <xsl:otherwise>
  521. <wsrp:markupString>
  522. <xts:transform name="XMLEncode" option="content">
  523. <xts:transform name="XSLT" src="/cps4/producer/wsrp-impl/transforms/display-help.xslt">
  524. <xts:param name="messageBaseLocale">
  525. <out:value-of select="$portlet-product-locale"/>
  526. </xts:param>
  527. <xts:param name="logicsheet">/cps4/producer/logicsheets/cps-ui.xslt</xts:param>
  528. <xts:param name="logicsheet">/cps4/producer/logicsheets/cps-formlogic.xslt</xts:param>
  529. <root>
  530. <xts:queryNode select="/root/envelope | /root/system | /root/configProps | /root/interfaces | /root/cookies"/>
  531. <xsl:apply-templates/>
  532. <portlet id="{ ancestor::portlet:portlet[1]/@handle }"/>
  533. </root>
  534. </xts:transform>
  535. </xts:transform>
  536. </wsrp:markupString>
  537. </xsl:otherwise>
  538. </xsl:choose>
  539. </xsl:template>
  540. <xsl:template match="portlet:logicsheet | portlet:messageBase" priority="1">
  541. <xsl:choose>
  542. <xsl:when test="ancestor::portlet:markup-transform">
  543. <xts:param name="{ local-name(.) }"><xsl:apply-templates/></xts:param>
  544. </xsl:when>
  545. <xsl:otherwise>
  546. <xsl:call-template name="portlet-compile-error">
  547. <xsl:with-param name="errno">0015</xsl:with-param>
  548. <xsl:with-param name="errmsg">'<xsl:value-of select="name()"/>' tag misplaced ('markup-transform' ancestor tag not found)</xsl:with-param>
  549. </xsl:call-template>
  550. </xsl:otherwise>
  551. </xsl:choose>
  552. </xsl:template>
  553. <xsl:template match="portlet:source" priority="1">
  554. <xsl:choose>
  555. <xsl:when test="not(ancestor::portlet:markup-transform)">
  556. <xsl:call-template name="portlet-compile-error">
  557. <xsl:with-param name="errno">0012</xsl:with-param>
  558. <xsl:with-param name="errmsg">Missing ancestor tag: markup-transform</xsl:with-param>
  559. </xsl:call-template>
  560. </xsl:when>
  561. <xsl:when test="not(ancestor::portlet:portlet[1]/@handle)">
  562. <xsl:call-template name="portlet-compile-error">
  563. <xsl:with-param name="errno">0014</xsl:with-param>
  564. <xsl:with-param name="errmsg">Missing ancestor tag: portlet with handle attribute</xsl:with-param>
  565. </xsl:call-template>
  566. </xsl:when>
  567. <xsl:otherwise>
  568. <xsl:choose>
  569. <xsl:when test="ancestor::portlet:markup-transform/@name = 'XML'">
  570. <xts:param name="src">
  571. <xsl:apply-templates/>
  572. </xts:param>
  573. </xsl:when>
  574. <xsl:otherwise>
  575. <root>
  576. <xts:queryNode select="/root/envelope | /root/system | /root/configProps | /root/interfaces | /root/cookies | /root/session"/>
  577. <xsl:apply-templates/>
  578. <out:variable name="consumer" select="$portlet-registration-params[@name = 'consumerAgent']"/>
  579. <out:variable name="is-plumtree" select="$consumer = 'plumtree'"/>
  580. <portlet id="{ ancestor::portlet:portlet[1]/@handle }">
  581. <consumer id="{ '{' }$consumer{ '}' }">
  582. <layout>
  583. <path>
  584. <start/>
  585. <separator>
  586. <out:choose>
  587. <out:when test="$is-plumtree"> : </out:when>
  588. <out:otherwise>
  589. <out:choose>
  590. <out:when test="$portlet-is-ui-rtl">&#8207; &lt; </out:when>
  591. <out:otherwise>&#8206; &gt; </out:otherwise>
  592. </out:choose>
  593. </out:otherwise>
  594. </out:choose>
  595. </separator>
  596. <end/>
  597. </path>
  598. <out:variable name="location">
  599. <out:choose>
  600. <out:when test="$is-plumtree">top-right</out:when>
  601. <out:otherwise>bottom-left</out:otherwise>
  602. </out:choose>
  603. </out:variable>
  604. <buttons location="{'{'}$location{'}'}"/>
  605. <backWhenMaximized>
  606. <out:value-of select="$is-plumtree"/>
  607. </backWhenMaximized>
  608. <linkSeparator>&#160;|&#160;</linkSeparator>
  609. </layout>
  610. <supportTitle>
  611. <out:value-of select="not($consumer='plumtree' or $consumer='sap' or $consumer='websphere')"/>
  612. </supportTitle>
  613. </consumer>
  614. </portlet>
  615. </root>
  616. </xsl:otherwise>
  617. </xsl:choose>
  618. </xsl:otherwise>
  619. </xsl:choose>
  620. </xsl:template>
  621. <xsl:template match="portlet:if-mode" priority="1">
  622. <xsl:choose>
  623. <xsl:when test="@name">
  624. <out:if test="contains('|{ @name }|', concat(concat('|', string($portlet-mode)), '|'))">
  625. <xsl:apply-templates/>
  626. </out:if>
  627. </xsl:when>
  628. <xsl:otherwise>
  629. <xsl:call-template name="portlet-compile-error">
  630. <xsl:with-param name="errno">0006</xsl:with-param>
  631. <xsl:with-param name="errmsg">Missing mandatory attribute: name (xsd:string)</xsl:with-param>
  632. </xsl:call-template>
  633. </xsl:otherwise>
  634. </xsl:choose>
  635. </xsl:template>
  636. <xsl:template match="portlet:if-window-state" priority="1">
  637. <xsl:choose>
  638. <xsl:when test="@name">
  639. <out:if test="contains('|{ @name }|', concat(concat('|', string($portlet-window-state)), '|'))">
  640. <xsl:apply-templates/>
  641. </out:if>
  642. </xsl:when>
  643. <xsl:otherwise>
  644. <xsl:call-template name="portlet-compile-error">
  645. <xsl:with-param name="errno">0007</xsl:with-param>
  646. <xsl:with-param name="errmsg">Missing mandatory attribute: name (xsd:string)</xsl:with-param>
  647. </xsl:call-template>
  648. </xsl:otherwise>
  649. </xsl:choose>
  650. </xsl:template>
  651. <xsl:template match="portlet:cache-control" priority="1">
  652. <wsrp:cacheControl>
  653. <wsrp:expires>
  654. <xsl:choose>
  655. <xsl:when test="@expires">
  656. <out:value-of select="{ @expires }"/>
  657. </xsl:when>
  658. <xsl:otherwise>
  659. <xsl:call-template name="portlet-compile-error">
  660. <xsl:with-param name="errno">0008</xsl:with-param>
  661. <xsl:with-param name="errmsg">Missing mandatory attribute: expires (xsd:int)</xsl:with-param>
  662. </xsl:call-template>
  663. </xsl:otherwise>
  664. </xsl:choose>
  665. </wsrp:expires>
  666. <wsrp:userScope>
  667. <xsl:choose>
  668. <xsl:when test="@userScope">
  669. <out:value-of select="{ @userScope }"/>
  670. </xsl:when>
  671. <xsl:otherwise>wsrp:perUser</xsl:otherwise>
  672. </xsl:choose>
  673. </wsrp:userScope>
  674. <xsl:if test="@validateTag">
  675. <out:if test="string({ @validateTag }) != ''">
  676. <wsrp:validateTag>
  677. <out:value-of select="{ @validateTag }"/>
  678. </wsrp:validateTag>
  679. </out:if>
  680. </xsl:if>
  681. <xsl:apply-templates/>
  682. </wsrp:cacheControl>
  683. </xsl:template>
  684. <xsl:template match="portlet:preferred-title" priority="1">
  685. <xsl:choose>
  686. <xsl:when test="child::node()">
  687. <wsrp:preferredTitle>
  688. <xsl:apply-templates/>
  689. </wsrp:preferredTitle>
  690. </xsl:when>
  691. <xsl:otherwise>
  692. <xsl:call-template name="portlet-compile-error">
  693. <xsl:with-param name="errno">0009</xsl:with-param>
  694. <xsl:with-param name="errmsg">Empty tag is not allowed here '<xsl:value-of select="name(.)"/>'</xsl:with-param>
  695. </xsl:call-template>
  696. </xsl:otherwise>
  697. </xsl:choose>
  698. </xsl:template>
  699. <xsl:template match="portlet:preferred-title-localized-value" priority="1">
  700. <xsl:call-template name="portlet-select-preferred-title">
  701. <xsl:with-param name="select" select="@select"/>
  702. </xsl:call-template>
  703. </xsl:template>
  704. <xsl:template match="portlet:preferred-title-localized" priority="1">
  705. <xsl:choose>
  706. <xsl:when test="@select">
  707. <out:if test="{ @select }">
  708. <wsrp:preferredTitle>
  709. <xsl:call-template name="portlet-select-preferred-title">
  710. <xsl:with-param name="select" select="@select"/>
  711. </xsl:call-template>
  712. </wsrp:preferredTitle>
  713. </out:if>
  714. </xsl:when>
  715. <xsl:otherwise>
  716. <xsl:call-template name="portlet-compile-error">
  717. <xsl:with-param name="errno">0021</xsl:with-param>
  718. <xsl:with-param name="errmsg">Missing 'select' attribute here '<xsl:value-of select="name(.)"/>'</xsl:with-param>
  719. </xsl:call-template>
  720. </xsl:otherwise>
  721. </xsl:choose>
  722. </xsl:template>
  723. <xsl:template match="portlet:title-locale" priority="1">
  724. <titleLocale>
  725. <xsl:choose>
  726. <xsl:when test="@selectState1">
  727. <out:choose>
  728. <out:when test="{ @selectState1 }">
  729. <xsl:call-template name="portlet-select-title-locale">
  730. <xsl:with-param name="select" select="@selectState1"/>
  731. </xsl:call-template>
  732. </out:when>
  733. <xsl:if test="@selectState2">
  734. <out:when test="{ @selectState2 }">
  735. <xsl:call-template name="portlet-select-title-locale">
  736. <xsl:with-param name="select" select="@selectState2"/>
  737. </xsl:call-template>
  738. </out:when>
  739. </xsl:if>
  740. <out:otherwise>
  741. <out:value-of select="$portlet-content-locale"/>
  742. </out:otherwise>
  743. </out:choose>
  744. </xsl:when>
  745. <xsl:otherwise>
  746. <xsl:call-template name="portlet-compile-error">
  747. <xsl:with-param name="errno">0024</xsl:with-param>
  748. <xsl:with-param name="errmsg">Missing 'selectState1' attribute here '<xsl:value-of select="name(.)"/>'</xsl:with-param>
  749. </xsl:call-template>
  750. </xsl:otherwise>
  751. </xsl:choose>
  752. </titleLocale>
  753. </xsl:template>
  754. <xsl:template name="portlet-select-title-locale">
  755. <xsl:param name="select"/>
  756. <out:variable name="currentLocales">
  757. <out:for-each select="{ $select }">
  758. <out:value-of select="substring-after( @name, 'title_' )"/>
  759. <out:if test="not(position() = last())">,</out:if>
  760. </out:for-each>
  761. </out:variable>
  762. <out:value-of select="java:getBestFitLocale(string($portlet-content-locale),string($currentLocales))"/>
  763. </xsl:template>
  764. <xsl:template name="portlet-select-preferred-title">
  765. <xsl:param name="select"/>
  766. <out:variable name="preferred-title-locale">
  767. <xsl:call-template name="portlet-select-title-locale">
  768. <xsl:with-param name="select" select="$select"/>
  769. </xsl:call-template>
  770. </out:variable>
  771. <out:for-each select="{ $select }">
  772. <out:if test="substring-after( @name, 'title_' ) = $preferred-title-locale">
  773. <out:value-of select="string(.)"/>
  774. </out:if>
  775. </out:for-each>
  776. </xsl:template>
  777. <xsl:template match="portlet:get-version" priority="1">
  778. <consumer>
  779. <out:copy-of select="$portlet-markups/wsrp:extensions/versions"/>
  780. </consumer>
  781. <producer>
  782. <xts:function name="getVersion">
  783. <xts:param name="packages">com.cognos.cps,com.cognos.xts,java.lang,javax.servlet,javax.xml.parsers,javax.xml.transform,jd.xml.xslt,org.dom4j,org.xml.sax</xts:param>
  784. </xts:function>
  785. </producer>
  786. </xsl:template>
  787. <xsl:template match="portlet:session-read" priority="1">
  788. <xsl:choose>
  789. <xsl:when test="@channel">
  790. <xts:transform name="XSLT" src="/cps4/producer/wsrp-impl/transforms/session-read.xslt">
  791. <sessiondata>
  792. <out:variable name="portlet-name-prefix" select="concat( $portlet-op/wsrp:registrationContext/wsrp:registrationHandle, ':', { @channel }, '#' )"/>
  793. <xsl:apply-templates/>
  794. </sessiondata>
  795. </xts:transform>
  796. </xsl:when>
  797. <xsl:otherwise>
  798. <xsl:call-template name="portlet-compile-error">
  799. <xsl:with-param name="errno">0018</xsl:with-param>
  800. <xsl:with-param name="errmsg">Missing 'channel' attribute</xsl:with-param>
  801. </xsl:call-template>
  802. </xsl:otherwise>
  803. </xsl:choose>
  804. </xsl:template>
  805. <xsl:template match="portlet:session-data" priority="1">
  806. <xsl:choose>
  807. <xsl:when test="@name != ''">
  808. <xsl:choose>
  809. <xsl:when test="ancestor::portlet:session-read">
  810. <item>
  811. <out:variable name="name">
  812. <out:value-of select="$portlet-name-prefix"/><out:value-of select="{@name}"/>
  813. </out:variable>
  814. <defaultName>
  815. <out:value-of select="$name"/>
  816. </defaultName>
  817. <state>
  818. <xts:transform name="XMLEncode">
  819. <xts:function name="TDSRequest">
  820. <xts:param name="action">get</xts:param>
  821. <xts:param name="session-id"><out:value-of select="$passport"/></xts:param>
  822. <xts:param name="map-id"><xsl:value-of select="'portlets'"/></xts:param>
  823. <xts:param name="name"><out:value-of select="$name"/></xts:param>
  824. </xts:function>
  825. </xts:transform>
  826. </state>
  827. </item>
  828. </xsl:when>
  829. <xsl:otherwise>
  830. <xsl:call-template name="portlet-compile-error">
  831. <xsl:with-param name="errno">0017</xsl:with-param>
  832. <xsl:with-param name="errmsg">Tag misplaced. Expecting an ancestor 'session-read'</xsl:with-param>
  833. </xsl:call-template>
  834. </xsl:otherwise>
  835. </xsl:choose>
  836. </xsl:when>
  837. <xsl:otherwise>
  838. <xsl:call-template name="portlet-compile-error">
  839. <xsl:with-param name="errno">0016</xsl:with-param>
  840. <xsl:with-param name="errmsg">Missing 'name' attribute</xsl:with-param>
  841. </xsl:call-template>
  842. </xsl:otherwise>
  843. </xsl:choose>
  844. </xsl:template>
  845. <xsl:template match="portlet:extensions" priority="1">
  846. <wsrp:extensions>
  847. <xsl:choose>
  848. <xsl:when test="count(*) = 1">
  849. <xsl:apply-templates/>
  850. </xsl:when>
  851. <xsl:otherwise>
  852. <xsl:call-template name="portlet-compile-error">
  853. <xsl:with-param name="errno">0013</xsl:with-param>
  854. <xsl:with-param name="errmsg">Only one single element is allowed in extensions tag</xsl:with-param>
  855. </xsl:call-template>
  856. </xsl:otherwise>
  857. </xsl:choose>
  858. </wsrp:extensions>
  859. </xsl:template>
  860. <xsl:template match="portlet:*" priority="0">
  861. <xsl:call-template name="portlet-compile-error">
  862. <xsl:with-param name="errno">0100</xsl:with-param>
  863. <xsl:with-param name="errmsg">Unsupported logicsheet tag: <xsl:value-of select="local-name(.)"/></xsl:with-param>
  864. </xsl:call-template>
  865. </xsl:template>
  866. <xsl:template name="portlet-compile-error">
  867. <xsl:param name="errno"/>
  868. <xsl:param name="errmsg"/>
  869. <xsl:message>
  870. <xsl:text>CPS-ERR-</xsl:text>
  871. <xsl:value-of select="$errno"/>
  872. <xsl:text>: </xsl:text>
  873. <xsl:value-of select="$errmsg"/>
  874. <xsl:text>.</xsl:text>
  875. </xsl:message>
  876. <xsl:message terminate="yes">
  877. <xsl:text> ...at: </xsl:text>
  878. <xsl:for-each select="ancestor-or-self::node()[name()!='']">
  879. <xsl:text>/</xsl:text>
  880. <xsl:value-of select="name()"/>
  881. </xsl:for-each>
  882. </xsl:message>
  883. </xsl:template>
  884. <xsl:template match="*|@*|text()|processing-instruction()" priority="-1">
  885. <xsl:copy>
  886. <xsl:apply-templates select="*|@*|text()|processing-instruction()"/>
  887. </xsl:copy>
  888. </xsl:template>
  889. </xsl:stylesheet>