buslogic.xslt 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cogadmin
  5. (C) Copyright IBM Corp. 2005, 2019
  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:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  15. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  16. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  17. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  18. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  20. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  21. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  22. xmlns:out="dummy-uri"
  23. exclude-result-prefixes="xsl send xts bus">
  24. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  25. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  26. <!--
  27. ===============================================================================================
  28. send:request - Builds an xts:request that contains a valid BIBus request. The caller can
  29. ignore the details of the SOAP:Header, and simply supply the contents of
  30. the bus:request.
  31. ===============================================================================================
  32. -->
  33. <xsl:template match="send:request">
  34. <xts:request>
  35. <xsl:choose>
  36. <xsl:when test="@provider='cm'">
  37. <xsl:attribute name="protocol">BUS</xsl:attribute>
  38. <xsl:attribute name="href">bus://cm</xsl:attribute>
  39. <xsl:attribute name="soapAction">http://www.ibm.com/xmlns/prod/cognos/contentManagerService/201904/</xsl:attribute>
  40. <xsl:attribute name="outputHeader">true</xsl:attribute>
  41. </xsl:when>
  42. <xsl:when test="@provider='xts'">
  43. <xsl:attribute name="protocol">BUS</xsl:attribute>
  44. <xsl:attribute name="href">bus://xts</xsl:attribute>
  45. <xsl:attribute name="soapAction">xts.run</xsl:attribute>
  46. <xsl:attribute name="outputHeader">true</xsl:attribute>
  47. </xsl:when>
  48. <xsl:when test="@provider='eventManagementService'">
  49. <xsl:attribute name="protocol">BUS</xsl:attribute>
  50. <xsl:attribute name="href">bus://dispatcher</xsl:attribute>
  51. <xsl:attribute name="soapAction">
  52. <xsl:text>http://www.ibm.com/xmlns/prod/cognos/eventManagementService/201610/</xsl:text>
  53. <xsl:if test="@affinity">
  54. <xsl:value-of select="concat('.', @affinity)"/>
  55. </xsl:if>
  56. </xsl:attribute>
  57. <xsl:attribute name="outputHeader">true</xsl:attribute>
  58. </xsl:when>
  59. </xsl:choose>
  60. <xsl:copy-of select="@*[name() != 'provider' and name() != 'affinity' and name() != 'directedRequest' and name()!='soapAction']"/>
  61. <!-- copy any xts:output-param elements -->
  62. <xsl:copy-of select="*[local-name()='output-param']"/>
  63. <SOAP-ENV:Envelope>
  64. <SOAP-ENV:Header>
  65. <bus:biBusHeader>
  66. <out:choose>
  67. <out:when test="/root/header/bus:biBusHeader">
  68. <out:choose>
  69. <out:when test="/root/env/param[@name='m_tracking'] and /root/env/param[@name='m_tracking']!='' and ('{@affinity}'='.high' or '{@affinity}'='.absolute')">
  70. <out:value-of select="xtsext:web64decode( xtsext:cafaction( 'sign_unwrap', string( /root/env/param[@name='m_tracking'] )), true() )" disable-output-escaping="yes"/>
  71. </out:when>
  72. <out:otherwise>
  73. <out:copy-of select="/root/header/bus:biBusHeader/bus:tracking"/>
  74. </out:otherwise>
  75. </out:choose>
  76. <!-- set up the rest of the header elements -->
  77. <out:for-each select="/root/header/bus:biBusHeader/*">
  78. <out:choose>
  79. <out:when test="local-name()='tracking'"/>
  80. <out:when test="local-name()='hdrSession'">
  81. <xsl:choose>
  82. <xsl:when test="starts-with(@provider, 'cm')">
  83. <!-- trim the bus header before sending to cm -->
  84. <out:copy>
  85. <out:copy-of select="@*"/>
  86. <bus:formFieldVars xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:formFieldVar[]">
  87. <out:copy-of select="item[starts-with(name, 'CAM')]"/>
  88. </bus:formFieldVars>
  89. <out:copy-of select="*[local-name() != 'formFieldVars']"/>
  90. </out:copy>
  91. </xsl:when>
  92. <xsl:otherwise>
  93. <out:copy>
  94. <out:copy-of select="@*"/>
  95. <out:copy-of select="*"/>
  96. </out:copy>
  97. </xsl:otherwise>
  98. </xsl:choose>
  99. </out:when>
  100. <out:otherwise>
  101. <out:copy>
  102. <out:copy-of select="@*"/>
  103. <!-- copy child elements except the CAMCredentialPath -->
  104. <out:copy-of select="*[local-name() != 'CAMCredentialPath']"/>
  105. </out:copy>
  106. </out:otherwise>
  107. </out:choose>
  108. </out:for-each>
  109. </out:when>
  110. <out:otherwise>
  111. <!-- there's no header - this means we've come in through transerv. Build one from scratch -->
  112. <bus:userPreferenceVars xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:userPreferenceVar[]">
  113. <item>
  114. <name xsi:type="xsd:string">timeZoneID</name>
  115. <value xsi:type="xsd:string">America/New_York</value>
  116. </item>
  117. <item>
  118. <name xsi:type="xsd:string">productLocale</name>
  119. <value xsi:type="xsd:string"><out:value-of select="substring(/root/http/param[@name='HTTP_ACCEPT_LANGUAGE'],1,2)"/></value>
  120. </item>
  121. <item>
  122. <name xsi:type="xsd:string">contentLocale</name>
  123. <value xsi:type="xsd:string"><out:value-of select="substring(/root/http/param[@name='HTTP_ACCEPT_LANGUAGE'],1,2)"/></value>
  124. </item>
  125. <item>
  126. <name xsi:type="xsd:string">format</name>
  127. <value xsi:type="xsd:string">HTML</value>
  128. </item>
  129. </bus:userPreferenceVars>
  130. <bus:CAM xsi:type="bus:CAM">
  131. <CAMPassport xsi:type="bus:CAMPassport">
  132. <id xsi:type="xsd:string">
  133. <out:choose>
  134. <out:when test="/root/cookies/cookie[@name='cam_passport']">
  135. <out:value-of select="/root/cookies/cookie[@name='cam_passport']"/>
  136. </out:when>
  137. <out:otherwise>
  138. <out:value-of select="/root/env/param[@name='cam_passport']"/>
  139. </out:otherwise>
  140. </out:choose>
  141. </id>
  142. </CAMPassport>
  143. </bus:CAM>
  144. </out:otherwise>
  145. </out:choose>
  146. </bus:biBusHeader>
  147. </SOAP-ENV:Header>
  148. <SOAP-ENV:Body>
  149. <xsl:apply-templates/>
  150. </SOAP-ENV:Body>
  151. </SOAP-ENV:Envelope>
  152. </xts:request>
  153. </xsl:template>
  154. <xsl:template match="*[local-name()='output-param']"/>
  155. <xsl:template match="*">
  156. <xsl:copy>
  157. <xsl:copy-of select="@*"/>
  158. <xsl:apply-templates/>
  159. </xsl:copy>
  160. </xsl:template>
  161. </xsl:stylesheet>