register.xts 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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: //cps4/8.1_NovRTM/src/cps/templates/cps4/portlets/portal-admin/portlet-impl/import/getMarkup.xts#1 $ -->
  13. <!-- $DateTime: 2005/10/21 13:51:27 $ -->
  14. <!-- $Change: 12585 $ -->
  15. <xts:morphlet version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/">
  16. <xts:block id="init" type="exec" mode="interpret" processor="XSLT">
  17. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt">
  18. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  19. <xsl:template match="/">
  20. <xts:sequence>
  21. <xts:append>
  22. <contentLocale>en</contentLocale>
  23. <xts:function name="getConfiguration">
  24. <xts:param name="contentLocales">en</xts:param>
  25. </xts:function>
  26. <!--
  27. <new_producers>
  28. <producer>
  29. <name>utility</name>
  30. </producer>
  31. </new_producers>
  32. <updated_producers>
  33. <producer>
  34. <name>nav</name>
  35. <currentPortlets>
  36. <handle>navigator</handle>
  37. <handle>search</handle>
  38. <handle>viewer</handle>
  39. </currentPortlets>
  40. </producer>
  41. </updated_producers>
  42. -->
  43. </xts:append>
  44. </xts:sequence>
  45. </xsl:template>
  46. </xsl:stylesheet>
  47. </xts:block>
  48. <xts:block id="producers" condition=".[/root/new_producers or /root/updated_producers]" dependency="init" type="exec" mode="interpret" processor="XSLT">
  49. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt">
  50. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  51. <xsl:variable name="content-locale" select="/root/contentLocale"/>
  52. <!--
  53. inquire request - retrieve list of installed producers
  54. root
  55. inquire
  56. services
  57. service
  58. id
  59. title
  60. namespace
  61. definition
  62. binding
  63. binding @name="WSRPService"
  64. port @name
  65. address @location
  66. resourceList
  67. resources
  68. values
  69. -->
  70. <xsl:template match="/">
  71. <xts:sequence>
  72. <xts:append>
  73. <inquire>
  74. <xts:request protocol="PRODUCERS" faultBlock="handleFault">
  75. <xts:param name="locale">
  76. <xsl:value-of select="$content-locale"/>
  77. </xts:param>
  78. <xsl:for-each select="/root/configuration/property[@name='contentLocales']/locale[id != $content-locale]">
  79. <xsl:sort select="id"/>
  80. <xts:param name="locale">
  81. <xsl:value-of select="id"/>
  82. </xts:param>
  83. </xsl:for-each>
  84. <xsl:for-each select="/root/new_producers/producer | /root/updated_producers/producer">
  85. <xts:param name="producer">
  86. <xsl:value-of select="name"/>
  87. </xts:param>
  88. </xsl:for-each>
  89. </xts:request>
  90. </inquire>
  91. </xts:append>
  92. </xts:sequence>
  93. </xsl:template>
  94. </xsl:stylesheet>
  95. </xts:block>
  96. <xts:block id="binding" condition=".[/root/new_producers or /root/updated_producers]" dependency="producers" mandatory="false" type="exec" mode="interpret" processor="XSLT">
  97. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xtse="http://developer.cognos.com/schemas/xts/error/1/" exclude-result-prefixes="wsrp wsdlsoap wsdl xtse">
  98. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  99. <xsl:template match="/">
  100. <xsl:if test="/root/new_producers/producer or /root/updated_producers/producer">
  101. <xts:sequence>
  102. <xsl:for-each select="/root/new_producers/producer">
  103. <xsl:variable name="services" select="/root/inquire/services/service"/>
  104. <xsl:variable name="name" select="name"/>
  105. <xts:append select="/root/new_producers/producer[name='{$name}']">
  106. <binding>
  107. <xsl:variable name="service" select="$services[id =$name]"/>
  108. <xsl:variable name="binding" select="$service/binding/service[@name = 'WSRPService']"/>
  109. <xsl:call-template name="gen-wsdl">
  110. <xsl:with-param name="markup" select="$binding/port[@name = 'WSRPBaseService']/address/@location"/>
  111. <xsl:with-param name="description" select="$binding/port[@name = 'WSRPServiceDescriptionService']/address/@location"/>
  112. <xsl:with-param name="registration" select="$binding/port[@name = 'WSRPRegistrationService']/address/@location"/>
  113. <xsl:with-param name="management" select="$binding/port[@name = 'WSRPPortletManagementService']/address/@location"/>
  114. <xsl:with-param name="binding" select="$binding"/>
  115. </xsl:call-template>
  116. </binding>
  117. </xts:append>
  118. </xsl:for-each>
  119. <xsl:for-each select="/root/updated_producers/producer">
  120. <xsl:variable name="services" select="/root/inquire/services/service"/>
  121. <xsl:variable name="name" select="name"/>
  122. <xts:append select="/root/updated_producers/producer[name='{$name}']">
  123. <binding>
  124. <xsl:variable name="service" select="$services[id =$name]"/>
  125. <xsl:variable name="binding" select="$service/binding/service[@name = 'WSRPService']"/>
  126. <xsl:call-template name="gen-wsdl">
  127. <xsl:with-param name="markup" select="$binding/port[@name = 'WSRPBaseService']/address/@location"/>
  128. <xsl:with-param name="description" select="$binding/port[@name = 'WSRPServiceDescriptionService']/address/@location"/>
  129. <xsl:with-param name="registration" select="$binding/port[@name = 'WSRPRegistrationService']/address/@location"/>
  130. <xsl:with-param name="management" select="$binding/port[@name = 'WSRPPortletManagementService']/address/@location"/>
  131. <xsl:with-param name="binding" select="$binding"/>
  132. </xsl:call-template>
  133. </binding>
  134. </xts:append>
  135. </xsl:for-each>
  136. </xts:sequence>
  137. </xsl:if>
  138. </xsl:template>
  139. <xsl:template name="gen-wsdl">
  140. <xsl:param name="markup"/>
  141. <xsl:param name="description"/>
  142. <xsl:param name="registration"/>
  143. <xsl:param name="management"/>
  144. <xsl:param name="binding"/>
  145. <wsdl:definitions targetNamespace="urn:oasis:names:tc:wsrp:v1:wsdl"
  146. xmlns:bind="urn:oasis:names:tc:wsrp:v1:bind"
  147. xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  148. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  149. <wsdl:import namespace="urn:oasis:names:tc:wsrp:v1:bind" location="http://www.oasis-open.org/committees/wsrp/specifications/version1/wsrp_v1_bindings.wsdl"/>
  150. <wsdl:service name="WSRPService">
  151. <xsl:apply-templates select="$binding/*[local-name()='segment']" mode="copy"/>
  152. <wsdl:port binding="bind:WSRP_v1_Markup_Binding_SOAP" name="WSRPBaseService">
  153. <wsdlsoap:address location="{ $markup }"/>
  154. <xsl:apply-templates select="$binding/*[local-name()='port' and @name='WSRPBaseService']/*[local-name()='portletAddress']" mode="copy"/>
  155. </wsdl:port>
  156. <wsdl:port binding="bind:WSRP_v1_ServiceDescription_Binding_SOAP" name="WSRPServiceDescriptionService">
  157. <wsdlsoap:address location="{ $description }"/>
  158. <xsl:apply-templates select="$binding/*[local-name()='port' and @name='WSRPServiceDescriptionService']/*[local-name()='portletAddress']" mode="copy"/>
  159. </wsdl:port>
  160. <xsl:if test="$registration != ''">
  161. <wsdl:port binding="bind:WSRP_v1_Registration_Binding_SOAP" name="WSRPRegistrationService">
  162. <wsdlsoap:address location="{ $registration }"/>
  163. <xsl:apply-templates select="$binding/*[local-name()='port' and @name='WSRPRegistrationService']/*[local-name()='portletAddress']" mode="copy"/>
  164. </wsdl:port>
  165. </xsl:if>
  166. <xsl:if test="$management != ''">
  167. <wsdl:port binding="bind:WSRP_v1_PortletManagement_Binding_SOAP" name="WSRPPortletManagementService">
  168. <wsdlsoap:address location="{ $management }"/>
  169. <xsl:apply-templates select="$binding/*[local-name()='port' and @name='WSRPPortletManagementService']/*[local-name()='portletAddress']" mode="copy"/>
  170. </wsdl:port>
  171. </xsl:if>
  172. </wsdl:service>
  173. </wsdl:definitions>
  174. </xsl:template>
  175. <!-- Using xsl:copy-of will sometime cause a namespace leak. To fix this, we use this template to copy the elements -->
  176. <xsl:template match="*" mode="copy">
  177. <xsl:element name="{name()}" namespace="{namespace-uri()}">
  178. <xsl:copy-of select="@*"/>
  179. <xsl:apply-templates mode="copy"/>
  180. </xsl:element>
  181. </xsl:template>
  182. <xsl:template match="text()" mode="copy">
  183. <xsl:value-of select="."/>
  184. </xsl:template>
  185. </xsl:stylesheet>
  186. </xts:block>
  187. <xts:block id="description" condition=".[/root/new_producers or /root/updated_producers]" dependency="binding" mandatory="false" type="exec" mode="interpret" processor="XSLT">
  188. <!--
  189. description
  190. - retrieve serviceDescription using producer binding
  191. -->
  192. <xts:logicsheet path="/cps4/common/logicsheets/soaplogic.xslt"/>
  193. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://developer.cognos.com/schemas/cps/logic/soap" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" exclude-result-prefixes="xtsext wsrp wsdlsoap wsdl soap">
  194. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  195. <xsl:template match="/">
  196. <xsl:if test="/root/new_producers/producer or /root/updated_producers/producer">
  197. <xts:sequence>
  198. <xsl:for-each select="/root/new_producers/producer">
  199. <xsl:variable name="name" select="name"/>
  200. <xsl:variable name="interface-description" select="binding/wsdl:definitions/wsdl:service[@name = 'WSRPService']/wsdl:port[@name = 'WSRPServiceDescriptionService']/wsdlsoap:address/@location"/>
  201. <xts:append select="/root/new_producers/producer[name='{$name}']">
  202. <description>
  203. <soap:request target="{ $interface-description }" soapAction="urn:oasis:names:tc:wsrp:v1:getServiceDescription" faultBlock="handleFault">
  204. <wsrp:getServiceDescription xmlns:m="urn:oasis:names:tc:wsrp:v1:types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  205. <wsrp:registrationContext xsi:nil="true"/>
  206. <xsl:variable name="locale">
  207. <xsl:choose>
  208. <xsl:when test="/root/contentLocale">
  209. <xsl:value-of select="/root/contentLocale"/>
  210. </xsl:when>
  211. <xsl:otherwise>en</xsl:otherwise>
  212. </xsl:choose>
  213. </xsl:variable>
  214. <wsrp:desiredLocales>
  215. <xsl:value-of select="$locale"/>
  216. </wsrp:desiredLocales>
  217. <xsl:for-each select="/root/configuration/property[@name='contentLocales']/locale[id != $locale]">
  218. <xsl:sort select="id"/>
  219. <wsrp:desiredLocales>
  220. <xsl:value-of select="id"/>
  221. </wsrp:desiredLocales>
  222. </xsl:for-each>
  223. </wsrp:getServiceDescription>
  224. </soap:request>
  225. </description>
  226. </xts:append>
  227. </xsl:for-each>
  228. <xsl:for-each select="/root/updated_producers/producer">
  229. <xsl:variable name="name" select="name"/>
  230. <xsl:variable name="binding" select="binding/wsdl:definitions"/>
  231. <xsl:variable name="interface-description" select="binding/wsdl:definitions/wsdl:service[@name = 'WSRPService']/wsdl:port[@name = 'WSRPServiceDescriptionService']/wsdlsoap:address/@location"/>
  232. <xts:append select="/root/updated_producers/producer[name='{$name}']">
  233. <description>
  234. <soap:request target="{ $interface-description }" soapAction="urn:oasis:names:tc:wsrp:v1:getServiceDescription" faultBlock="handleFault">
  235. <wsrp:getServiceDescription xmlns:m="urn:oasis:names:tc:wsrp:v1:types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  236. <wsrp:registrationContext>
  237. <xsl:copy-of select="*[local-name()='registration']/*[local-name() = 'RegistrationContext']/*"/>
  238. </wsrp:registrationContext>
  239. <xsl:variable name="locale">
  240. <xsl:choose>
  241. <xsl:when test="/root/contentLocale">
  242. <xsl:value-of select="/root/contentLocale"/>
  243. </xsl:when>
  244. <xsl:otherwise>en</xsl:otherwise>
  245. </xsl:choose>
  246. </xsl:variable>
  247. <wsrp:desiredLocales>
  248. <xsl:value-of select="$locale"/>
  249. </wsrp:desiredLocales>
  250. <xsl:for-each select="/root/configuration/property[@name='contentLocales']/locale[id != $locale]">
  251. <xsl:sort select="id"/>
  252. <wsrp:desiredLocales>
  253. <xsl:value-of select="id"/>
  254. </wsrp:desiredLocales>
  255. </xsl:for-each>
  256. </wsrp:getServiceDescription>
  257. </soap:request>
  258. </description>
  259. </xts:append>
  260. </xsl:for-each>
  261. </xts:sequence>
  262. </xsl:if>
  263. </xsl:template>
  264. </xsl:stylesheet>
  265. </xts:block>
  266. <xts:block id="register" condition=".[/root/new_producers]" dependency="description" mandatory="false" type="exec" mode="interpret" processor="XSLT">
  267. <xts:logicsheet path="/cps4/common/logicsheets/soaplogic.xslt"/>
  268. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://developer.cognos.com/schemas/cps/logic/soap" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" exclude-result-prefixes="SOAP-ENV wsrp wsdlsoap xsi wsdl soap xtsext">
  269. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  270. <xsl:template match="/">
  271. <xsl:if test="/root/new_producers/producer">
  272. <xts:sequence>
  273. <xsl:for-each select="/root/new_producers/producer">
  274. <xsl:variable name="name" select="name"/>
  275. <xsl:variable name="description" select="description/SOAP-ENV:Envelope/SOAP-ENV:Body/*[1]"/>
  276. <xsl:variable name="interface-registration" select="binding/wsdl:definitions/wsdl:service[@name = 'WSRPService']/wsdl:port[@name = 'WSRPRegistrationService']/wsdlsoap:address/@location"/>
  277. <xsl:variable name="registration-required" select="$description/wsrp:requiresRegistration[. = 'true' or . = '1']"/>
  278. <xsl:variable name="registration-properties" select="$description/wsrp:registrationPropertyDescription/wsrp:propertyDescriptions"/>
  279. <xsl:if test="$registration-required">
  280. <xts:append select="/root/new_producers/producer[name='{$name}']">
  281. <registration>
  282. <soap:request target="{ $interface-registration }" soapAction="urn:oasis:names:tc:wsrp:v1:register" faultBlock="handleFault">
  283. <wsrp:register xmlns:m="urn:oasis:names:tc:wsrp:v1:types">
  284. <wsrp:consumerName>Cognos WSRP Portal</wsrp:consumerName>
  285. <wsrp:consumerAgent>Cognos.Connection.2.0</wsrp:consumerAgent>
  286. <wsrp:methodGetSupported>true</wsrp:methodGetSupported>
  287. <wsrp:consumerModes>wsrp:view</wsrp:consumerModes>
  288. <wsrp:consumerModes>wsrp:edit</wsrp:consumerModes>
  289. <wsrp:consumerModes>wsrp:preview</wsrp:consumerModes>
  290. <wsrp:consumerModes>wsrp:help</wsrp:consumerModes>
  291. <wsrp:consumerWindowStates>wsrp:normal</wsrp:consumerWindowStates>
  292. <wsrp:consumerWindowStates>wsrp:maximized</wsrp:consumerWindowStates>
  293. <wsrp:consumerWindowStates>wsrp:minimized</wsrp:consumerWindowStates>
  294. <xsl:for-each select="$registration-properties">
  295. <wsrp:registrationProperties name="{ @name }" xml:lang="en">
  296. <wsrp:stringValue>
  297. <xsl:value-of select="''"/>
  298. </wsrp:stringValue>
  299. </wsrp:registrationProperties>
  300. </xsl:for-each>
  301. </wsrp:register>
  302. </soap:request>
  303. </registration>
  304. </xts:append>
  305. </xsl:if>
  306. </xsl:for-each>
  307. </xts:sequence>
  308. </xsl:if>
  309. </xsl:template>
  310. </xsl:stylesheet>
  311. </xts:block>
  312. <xts:block id="description2" dependency="register" condition=".[/root/new_producers/producer/registration]" mandatory="false" type="exec" mode="interpret" processor="XSLT">
  313. <!--
  314. description2
  315. - replace service description with new one using registration context
  316. NOTE: This block will execute if a new registration was created without any errors.
  317. -->
  318. <xts:logicsheet path="/cps4/common/logicsheets/soaplogic.xslt"/>
  319. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://developer.cognos.com/schemas/cps/logic/soap" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xtse="http://developer.cognos.com/schemas/xts/error/1/" exclude-result-prefixes="SOAP-ENV wsrp wsdlsoap xsi wsdl soap xtsext">
  320. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  321. <xsl:template match="/">
  322. <xsl:if test="/root/new_producers/producer">
  323. <xts:sequence>
  324. <xsl:for-each select="/root/new_producers/producer">
  325. <xsl:if test="registration and not(registration/xtse:error)">
  326. <xsl:variable name="name" select="name"/>
  327. <xsl:variable name="interface-description" select="binding/wsdl:definitions/wsdl:service[@name = 'WSRPService']/wsdl:port[@name = 'WSRPServiceDescriptionService']/wsdlsoap:address/@location"/>
  328. <xts:replace select="/root/new_producers/producer[name='{$name}']/description">
  329. <description>
  330. <soap:request target="{ $interface-description }" soapAction="urn:oasis:names:tc:wsrp:v1:getServiceDescription" faultBlock="handleFault">
  331. <wsrp:getServiceDescription xmlns:m="urn:oasis:names:tc:wsrp:v1:types">
  332. <wsrp:registrationContext>
  333. <xsl:copy-of select="registration/*[local-name() = 'Envelope']/*[local-name() = 'Body']/*[local-name() = 'registerResponse']/*"/>
  334. </wsrp:registrationContext>
  335. <xsl:variable name="locale">
  336. <xsl:choose>
  337. <xsl:when test="/root/contentLocale">
  338. <xsl:value-of select="/root/contentLocale"/>
  339. </xsl:when>
  340. <xsl:otherwise>en</xsl:otherwise>
  341. </xsl:choose>
  342. </xsl:variable>
  343. <wsrp:desiredLocales>
  344. <xsl:value-of select="$locale"/>
  345. </wsrp:desiredLocales>
  346. <xsl:for-each select="/root/configuration/property[@name='contentLocales']/locale[id != $locale]">
  347. <xsl:sort select="id"/>
  348. <wsrp:desiredLocales>
  349. <xsl:value-of select="id"/>
  350. </wsrp:desiredLocales>
  351. </xsl:for-each>
  352. </wsrp:getServiceDescription>
  353. </soap:request>
  354. </description>
  355. </xts:replace>
  356. </xsl:if>
  357. </xsl:for-each>
  358. </xts:sequence>
  359. </xsl:if>
  360. </xsl:template>
  361. </xsl:stylesheet>
  362. </xts:block>
  363. <xts:block id="create" dependency="description2" mandatory="false" type="exec" mode="interpret" processor="XSLT">
  364. <xts:logicsheet path="/cps4/common/logicsheets/soaplogic.xslt"/>
  365. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types" xmlns:cps="http://developer.cognos.com/schemas/cps/asm/objects/1/" xmlns:ast="http://developer.cognos.com/schemas/cps/asm/storage/1/" xmlns:soap="http://developer.cognos.com/schemas/cps/logic/soap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xtse="http://developer.cognos.com/schemas/xts/error/1/" exclude-result-prefixes="wsdlsoap soap xtsext">
  366. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  367. <xsl:template match="/">
  368. <xsl:if test="/root/new_producers/producer or /root/updated_producers/producer">
  369. <xts:sequence>
  370. <xsl:for-each select="/root/updated_producers/producer">
  371. <xsl:if test="not(binding/xtse:error) and not(description/xtse:error)">
  372. <xsl:variable name="name" select="name"/>
  373. <xsl:variable name="description" select="description/SOAP-ENV:Envelope/SOAP-ENV:Body/*[1]"/>
  374. <xsl:variable name="current-portlets" select="currentPortlets/handle"/>
  375. <xsl:variable name="resource-list" select="$description/wsrp:resourceList/wsrp:resources"/>
  376. <xts:append select="/root/updated_producers/producer[name='{$name}']">
  377. <newPortlets>
  378. <xsl:variable name="portlets" select="$description/wsrp:offeredPortlets[not (wsrp:portletHandle = $current-portlets)]"/>
  379. <xsl:for-each select="$portlets">
  380. <xsl:variable name="duplicates" select="count($description/wsrp:offeredPortlets[wsrp:title/wsrp:value = current()/wsrp:title/wsrp:value]) - count($portlets[wsrp:title/wsrp:value = current()/wsrp:title/wsrp:value]) + position() - 1"/>
  381. <cps:portlet>
  382. <cps:name>
  383. <xsl:if test="wsrp:title/@resourceName">
  384. <xsl:attribute name="resourceName">
  385. <xsl:value-of select="wsrp:title/@resourceName"/>
  386. <xsl:if test="$duplicates > 0">
  387. <xsl:value-of select="concat(' _', $duplicates)"/>
  388. </xsl:if>
  389. </xsl:attribute>
  390. </xsl:if>
  391. <xsl:copy-of select="wsrp:title/@xml:lang"/>
  392. <xsl:value-of select="wsrp:title/wsrp:value"/>
  393. <xsl:if test="$duplicates > 0">
  394. <xsl:value-of select="concat(' (', $duplicates, ')')"/>
  395. </xsl:if>
  396. </cps:name>
  397. <cps:description>
  398. <xsl:copy-of select="wsrp:description/@xml:lang | wsrp:description/@resourceName"/>
  399. <xsl:value-of select="wsrp:description/wsrp:value"/>
  400. </cps:description>
  401. <cps:handle>
  402. <xsl:value-of select="wsrp:portletHandle"/>
  403. </cps:handle>
  404. </cps:portlet>
  405. </xsl:for-each>
  406. <cps:resourceList>
  407. <!-- portlet strings -->
  408. <xsl:for-each select="$portlets">
  409. <xsl:variable name="duplicates" select="count($description/wsrp:offeredPortlets[wsrp:title/wsrp:value = current()/wsrp:title/wsrp:value]) - count($portlets[wsrp:title/wsrp:value = current()/wsrp:title/wsrp:value]) + position() - 1"/>
  410. <xsl:for-each select="wsrp:title | wsrp:description">
  411. <xsl:variable name="is-title" select="local-name() = 'title'"/>
  412. <xsl:if test="@resourceName">
  413. <xsl:variable name="resource-name">
  414. <xsl:value-of select="@resourceName"/>
  415. <xsl:if test="$is-title and $duplicates > 0">
  416. <xsl:value-of select="concat(' _', $duplicates)"/>
  417. </xsl:if>
  418. </xsl:variable>
  419. <cps:resources resourceName="{ $resource-name }">
  420. <xsl:variable name="resource" select="$resource-list[@resourceName = current()/@resourceName]"/>
  421. <xsl:for-each select="$resource/wsrp:values">
  422. <cps:values xml:lang="{ @xml:lang }">
  423. <xsl:value-of select="wsrp:value"/>
  424. <xsl:if test="$is-title and $duplicates > 0">
  425. <xsl:value-of select="concat(' (', $duplicates , ')')"/>
  426. </xsl:if>
  427. </cps:values>
  428. </xsl:for-each>
  429. </cps:resources>
  430. </xsl:if>
  431. </xsl:for-each>
  432. </xsl:for-each>
  433. </cps:resourceList>
  434. </newPortlets>
  435. </xts:append>
  436. </xsl:if>
  437. </xsl:for-each>
  438. <xsl:for-each select="/root/new_producers/producer">
  439. <xsl:if test="not(binding/xtse:error) and not(description/xtse:error) and not(registration/xtse:error)">
  440. <xsl:variable name="name" select="name"/>
  441. <xsl:variable name="binding" select="binding/wsdl:definitions"/>
  442. <xsl:variable name="description" select="description/SOAP-ENV:Envelope/SOAP-ENV:Body/*[1]"/>
  443. <xsl:variable name="resource-list" select="$description/wsrp:resourceList/wsrp:resources"/>
  444. <xsl:variable name="registration-handle" select="registration/SOAP-ENV:Envelope/SOAP-ENV:Body/*[1]/wsrp:registrationHandle"/>
  445. <xsl:variable name="registration-state" select="registration/SOAP-ENV:Envelope/SOAP-ENV:Body/*[1]/wsrp:registrationState"/>
  446. <xsl:variable name="registration-extensions" select="registration/SOAP-ENV:Envelope/SOAP-ENV:Body/*[1]/wsrp:extensions"/>
  447. <xsl:variable name="services" select="/root/inquire/services/service"/>
  448. <xsl:variable name="service" select="$services[id = $name]"/>
  449. <xts:append select="/root/new_producers/producer[name='{$name}']">
  450. <create>
  451. <ast:savePortletProducer xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types" xmlns:cps="http://developer.cognos.com/schemas/cps/asm/objects/1/" xmlns:ast="http://developer.cognos.com/schemas/cps/asm/storage/1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  452. <cps:path>/connection</cps:path>
  453. <cps:portletProducer>
  454. <cps:name>
  455. <xsl:copy-of select="$service/title/@*"/>
  456. <xsl:value-of select="$service/title"/>
  457. </cps:name>
  458. <cps:description>
  459. <xsl:copy-of select="$description/title/@*"/>
  460. <xsl:value-of select="$description/title"/>
  461. </cps:description>
  462. <cps:screenTip>
  463. <xsl:copy-of select="$service/screenTip/@*"/>
  464. <xsl:value-of select="$service/screenTip"/>
  465. </cps:screenTip>
  466. <cps:binding>
  467. <cps:service name="WSRPService">
  468. <xsl:apply-templates select="$binding/wsdl:service[@name = 'WSRPService']/*[name() != 'wsdl:port']" mode="copy"/>
  469. <xsl:copy-of select="$binding/wsdl:service[@name = 'WSRPService']/wsdl:port"/>
  470. </cps:service>
  471. </cps:binding>
  472. <xsl:if test="$registration-handle != ''">
  473. <cps:registration>
  474. <wsrp:RegistrationContext>
  475. <wsrp:registrationHandle>
  476. <xsl:value-of select="$registration-handle"/>
  477. </wsrp:registrationHandle>
  478. <xsl:if test="$registration-state != ''">
  479. <wsrp:registrationState>
  480. <xsl:value-of select="$registration-state"/>
  481. </wsrp:registrationState>
  482. </xsl:if>
  483. <xsl:copy-of select="$registration-extensions"/>
  484. </wsrp:RegistrationContext>
  485. </cps:registration>
  486. </xsl:if>
  487. <cps:serviceDescription xmlns="urn:oasis:names:tc:wsrp:v1:types">
  488. <xsl:copy-of select="$description/*"/>
  489. </cps:serviceDescription>
  490. <!--
  491. construct portlet name and descriptionfrom wsrp resourceList
  492. wsrp:resourceList
  493. wsrp:resources @resourceName
  494. wsrp:values @xml:lang
  495. wsrp:value
  496. cps:resourceList
  497. cps:resources @resourceName
  498. cps:values @xml:lang
  499. -->
  500. <xsl:variable name="portlets" select="$description/wsrp:offeredPortlets"/>
  501. <xsl:for-each select="$portlets">
  502. <xsl:variable name="duplicates" select="count(preceding-sibling::wsrp:offeredPortlets[wsrp:title/wsrp:value = current()/wsrp:title/wsrp:value])"/>
  503. <cps:portlet>
  504. <cps:name>
  505. <xsl:if test="wsrp:title/@resourceName">
  506. <xsl:attribute name="resourceName">
  507. <xsl:value-of select="wsrp:title/@resourceName"/>
  508. <xsl:if test="$duplicates > 0">
  509. <xsl:value-of select="concat(' _', $duplicates)"/>
  510. </xsl:if>
  511. </xsl:attribute>
  512. </xsl:if>
  513. <xsl:copy-of select="wsrp:title/@xml:lang"/>
  514. <xsl:value-of select="wsrp:title/wsrp:value"/>
  515. <xsl:if test="$duplicates > 0">
  516. <xsl:value-of select="concat(' (', $duplicates , ')')"/>
  517. </xsl:if>
  518. </cps:name>
  519. <cps:description>
  520. <xsl:copy-of select="wsrp:description/@xml:lang | wsrp:description/@resourceName"/>
  521. <xsl:value-of select="wsrp:description/wsrp:value"/>
  522. </cps:description>
  523. <cps:handle>
  524. <xsl:value-of select="wsrp:portletHandle"/>
  525. </cps:handle>
  526. </cps:portlet>
  527. </xsl:for-each>
  528. <!-- resourceList -->
  529. <cps:resourceList>
  530. <!-- portletProducer strings -->
  531. <xsl:for-each select="$service/title | $service/description | $service/screenTip">
  532. <xsl:if test="@resourceName">
  533. <cps:resources resourceName="{ @resourceName }">
  534. <xsl:variable name="resource" select="$service/resourceList/resources[@resourceName = current()/@resourceName]"/>
  535. <xsl:for-each select="$resource/values">
  536. <cps:values xml:lang="{ @xml:lang }">
  537. <xsl:value-of select="."/>
  538. </cps:values>
  539. </xsl:for-each>
  540. </cps:resources>
  541. </xsl:if>
  542. </xsl:for-each>
  543. <!-- portlet strings -->
  544. <xsl:for-each select="$portlets">
  545. <xsl:variable name="duplicates" select="count(preceding-sibling::wsrp:offeredPortlets[wsrp:title/wsrp:value = current()/wsrp:title/wsrp:value])"/>
  546. <xsl:for-each select="wsrp:title | wsrp:description">
  547. <xsl:variable name="is-title" select="local-name() = 'title'"/>
  548. <xsl:if test="@resourceName">
  549. <xsl:variable name="resource-name">
  550. <xsl:value-of select="@resourceName"/>
  551. <xsl:if test="$is-title and $duplicates > 0">
  552. <xsl:value-of select="concat(' _', $duplicates)"/>
  553. </xsl:if>
  554. </xsl:variable>
  555. <cps:resources resourceName="{ $resource-name }">
  556. <xsl:variable name="resource" select="$resource-list[@resourceName = current()/@resourceName]"/>
  557. <xsl:for-each select="$resource/wsrp:values">
  558. <cps:values xml:lang="{ @xml:lang }">
  559. <xsl:value-of select="wsrp:value"/>
  560. <xsl:if test="$is-title and $duplicates > 0">
  561. <xsl:value-of select="concat(' (', $duplicates, ')')"/>
  562. </xsl:if>
  563. </cps:values>
  564. </xsl:for-each>
  565. </cps:resources>
  566. </xsl:if>
  567. </xsl:for-each>
  568. </xsl:for-each>
  569. </cps:resourceList>
  570. </cps:portletProducer>
  571. </ast:savePortletProducer>
  572. </create>
  573. </xts:append>
  574. </xsl:if>
  575. </xsl:for-each>
  576. </xts:sequence>
  577. </xsl:if>
  578. </xsl:template>
  579. <!-- Using xsl:copy-of will sometime cause a namespace leak. To fix this, we use this template to copy the elements -->
  580. <xsl:template match="*" mode="copy">
  581. <xsl:element name="{name()}" namespace="{namespace-uri()}">
  582. <xsl:copy-of select="@*"/>
  583. <xsl:apply-templates mode="copy"/>
  584. </xsl:element>
  585. </xsl:template>
  586. <xsl:template match="text()" mode="copy">
  587. <xsl:value-of select="."/>
  588. </xsl:template>
  589. </xsl:stylesheet>
  590. </xts:block>
  591. <!--
  592. <xts:block id="test" dependency="create" mode="output" processor="XSLT" type="exec" mimeType="text/xml" >
  593. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" xmlns:cml="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/cml/1/" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" xmlns:pm="http://developer.cognos.com/schemas/xts/pm" xmlns:mt="http://developer.cognos.com/schemas/xts/logicsheets/presentation/main/mt" xmlns:mf="http://developer.cognos.com/schemas/xts/logicsheets/presentation/main/mf" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/" xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/" xmlns:out="http://www.w3.org/1999/XSL/Transform" xmlns:pg="http://developer.cognos.com/schemas/xts/pg" xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/" xmlns:utml="http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/" xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/" exclude-result-prefixes="xsl cm cml pf mt mf xts xtsext cf cp out bus utml dp lyt pm">
  594. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  595. <xsl:template match="/">
  596. <xsl:copy-of select="/root"/>
  597. </xsl:template>
  598. </xsl:stylesheet>
  599. </xts:block>
  600. -->
  601. <xts:block id="handleFault" type="fault" processor="XSLT">
  602. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xtse="http://developer.cognos.com/schemas/xts/error/1/">
  603. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  604. <xsl:template match="/">
  605. <xtse:error>
  606. <xsl:for-each select="/root/fault/xts:exception[not(starts-with(xts:exceptionCode, 'java'))]">
  607. <xtse:message>
  608. <xsl:value-of select="xts:exceptionMsg"/>
  609. </xtse:message>
  610. </xsl:for-each>
  611. </xtse:error>
  612. </xsl:template>
  613. </xsl:stylesheet>
  614. </xts:block>
  615. </xts:morphlet>