metadataResponse.xts 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: AGS
  5. (C) Copyright IBM Corp. 2005, 2008
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xts:morphlet resolverBase="prompting" xmlns:xts="http://developer.cognos.com/schemas/xts/" messageBase="messages/AGS.xml,messages/portal.xml" requiredCapability="canUseEventStudio">
  9. <!--
  10. ===============================================================================================
  11. appendDocument - add the results of the requests into the right place
  12. ===============================================================================================
  13. -->
  14. <xts:block id="appendDocument" mode="interpret" processor="XSLT" type="exec">
  15. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/">
  16. <xsl:output method="xml" version="1.0" encoding="UTF-8"/>
  17. <xsl:template match="/root">
  18. <xsl:variable name="CRLF">
  19. <xsl:text>&#xA;</xsl:text>
  20. </xsl:variable>
  21. <xts:sequence>
  22. <xts:append>
  23. <metadataTree>
  24. <xsl:choose>
  25. <xsl:when test="contains(./SOAP-ENV:Envelope/SOAP-ENV:Body/*/bus:result/bus:details/item/bus:metadata, '&lt;?xml')">
  26. <xsl:value-of select="xtsext:replace(substring-after(./SOAP-ENV:Envelope/SOAP-ENV:Body/*/bus:result/bus:details/item/bus:metadata, '?&gt;'), string($CRLF), string('&amp;#xA;'), false)" disable-output-escaping="yes"/>
  27. </xsl:when>
  28. <xsl:otherwise>
  29. <xsl:value-of select="xtsext:replace(./SOAP-ENV:Envelope/SOAP-ENV:Body/*/bus:result/bus:details/item/bus:metadata, string($CRLF), string('&amp;#xA;'), false)" disable-output-escaping="yes"/>
  30. </xsl:otherwise>
  31. </xsl:choose>
  32. </metadataTree>
  33. </xts:append>
  34. </xts:sequence>
  35. </xsl:template>
  36. </xsl:stylesheet>
  37. </xts:block>
  38. <!--
  39. ===============================================================================================
  40. format the response - turn the metadata into some other kinda XML.
  41. ===============================================================================================
  42. -->
  43. <xts:block id="format" type="exec" mode="output" processor="XSLT" mimeType="text/xml" condition="/root/metadataTree/ResponseRoot" dependency="appendDocument">
  44. <!-- get the debug logic sheet -->
  45. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  46. <xts:logicsheet path="logicsheets/portal.xsl"/>
  47. <!-- apply the form logic -->
  48. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:dbg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/debug/" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" exclude-result-prefixes="xsl xts dbg xtsext bus pf">
  49. <xsl:output method="xml" version="1.0" encoding="UTF-8"/>
  50. <!-- start the output -->
  51. <xsl:template match="/root">
  52. <xsl:if test="./metadataTree/ResponseRoot">
  53. <xsl:variable name="markup">
  54. <xsl:call-template name="serialize-xml">
  55. <xsl:with-param name="node-set">
  56. <xsl:apply-templates select="./metadataTree/ResponseRoot"/>
  57. </xsl:with-param>
  58. </xsl:call-template>
  59. </xsl:variable>
  60. <!-- output what we've got -->
  61. <asyncReply>
  62. <xsl:value-of select="$markup"/>
  63. </asyncReply>
  64. </xsl:if>
  65. </xsl:template>
  66. <xsl:template match="/root/metadataTree/ResponseRoot">
  67. <metadata>
  68. <a>
  69. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="/root/env/param[@name='context']"/></xsl:with-param></xsl:call-template>
  70. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="/root/metadataTree/ResponseRoot/decimalSeparator/@value"/></xsl:with-param></xsl:call-template>
  71. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="/root/metadataTree/ResponseRoot/listSeparator/@value"/></xsl:with-param></xsl:call-template>
  72. </a>
  73. <a>
  74. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="/root/metadataTree/ResponseRoot/package/@name"/></xsl:with-param></xsl:call-template>
  75. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="/root/metadataTree/ResponseRoot/package/@screenTip"/></xsl:with-param></xsl:call-template>
  76. </a>
  77. <xsl:for-each select="./folder | ./querySubject | ./queryItemFolder | ./dimension | ./hierarchy | ./level | ./measure | ./measureFolder | ./member">
  78. <xsl:variable name="parent">
  79. <xsl:value-of select="@_path"/>
  80. </xsl:variable>
  81. <xsl:call-template name="buildTreeItemResponseString">
  82. <xsl:with-param name="node" select="."/>
  83. <xsl:with-param name="parent" select="$parent"/>
  84. </xsl:call-template>
  85. </xsl:for-each>
  86. </metadata>
  87. </xsl:template>
  88. <xsl:template name="buildTreeItemResponseString">
  89. <xsl:param name="node"/>
  90. <xsl:param name="parent"/>
  91. <!-- we build the member folder only for normal metadata requests -->
  92. <xsl:if test="(local-name($node) = 'level' or local-name($node) = 'hierarchy') and (not(/root/env/param[@name='memberRequest']) or /root/env/param[@name='memberRequest']!='true')">
  93. <!-- build a response string for the member folder -->
  94. <a>
  95. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal">memberFolder</xsl:with-param></xsl:call-template>
  96. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xts:string id="MEMBERS_FOLDER_NAME"/></xsl:with-param></xsl:call-template>
  97. <!-- empty screen tip and we use the name of the node for the screen tip -->
  98. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:text></xsl:text></xsl:with-param></xsl:call-template>
  99. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="@_path"/></xsl:with-param></xsl:call-template>
  100. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="@_ref"/></xsl:with-param></xsl:call-template>
  101. </a>
  102. </xsl:if>
  103. <xsl:choose>
  104. <xsl:when test="./member">
  105. <xsl:for-each select="$node/*[local-name()='member'][position() &lt; /root/env/param[@name='memberDisplayCountLimit']]">
  106. <a>
  107. <xsl:call-template name="buildResponseString">
  108. <xsl:with-param name="parent" select="$parent"/>
  109. </xsl:call-template>
  110. </a>
  111. </xsl:for-each>
  112. <xsl:if test="count(./member) > /root/env/param[@name='memberDisplayCountLimit']">
  113. <!-- there's more members than we can dispaly - so build a new element to define the search -->
  114. <a>
  115. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal">memberSearch</xsl:with-param></xsl:call-template>
  116. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xts:string id="MEMBERS_SEARCH_NAME"/></xsl:with-param></xsl:call-template>
  117. <!-- empty screen tip and we use the name of the node for the screen tip -->
  118. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:text></xsl:text></xsl:with-param></xsl:call-template>
  119. <!-- pass the path of the parent object as an attribute -->
  120. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="@_path"/></xsl:with-param></xsl:call-template>
  121. </a>
  122. </xsl:if>
  123. </xsl:when>
  124. <xsl:otherwise>
  125. <xsl:for-each select="$node/*">
  126. <a>
  127. <xsl:call-template name="buildResponseString">
  128. <xsl:with-param name="parent" select="$parent"/>
  129. </xsl:call-template>
  130. </a>
  131. </xsl:for-each>
  132. </xsl:otherwise>
  133. </xsl:choose>
  134. </xsl:template>
  135. <xsl:template name="buildResponseString">
  136. <xsl:param name="parent"/>
  137. <xsl:choose>
  138. <xsl:when test="@isNamespace='1'">
  139. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal">namespace</xsl:with-param></xsl:call-template>
  140. </xsl:when>
  141. <xsl:when test="@isHierarchical='1'">
  142. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal">rollupMeasure</xsl:with-param></xsl:call-template>
  143. </xsl:when>
  144. <xsl:when test="@type='measure'">
  145. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal">measureDimension</xsl:with-param></xsl:call-template>
  146. </xsl:when>
  147. <xsl:when test="@calcType='nameSet'">
  148. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal">namedSet</xsl:with-param></xsl:call-template>
  149. </xsl:when>
  150. <xsl:when test="@calcType='macros'">
  151. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal">calculationConstant</xsl:with-param></xsl:call-template>
  152. </xsl:when>
  153. <xsl:otherwise>
  154. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="name()"/></xsl:with-param></xsl:call-template>
  155. </xsl:otherwise>
  156. </xsl:choose>
  157. <xsl:choose>
  158. <xsl:when test="name()='member'">
  159. <xsl:call-template name="buildMemberItemResponseString"><xsl:with-param name="node" select="."/></xsl:call-template>
  160. </xsl:when>
  161. <xsl:otherwise>
  162. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="@name"/></xsl:with-param></xsl:call-template>
  163. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="@screenTip"/></xsl:with-param></xsl:call-template>
  164. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="@_path"/></xsl:with-param></xsl:call-template>
  165. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="@_ref"/></xsl:with-param></xsl:call-template>
  166. <xsl:if test="not(name()='folder' or name()='querySubject' or name()='queryItemFolder' or name()='filter' or name()='dimension' or name()='hierarchy')">
  167. <xsl:call-template name="buildQueryItemResponseString">
  168. <xsl:with-param name="node" select="."/>
  169. </xsl:call-template>
  170. </xsl:if>
  171. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$parent"/></xsl:with-param></xsl:call-template>
  172. </xsl:otherwise>
  173. </xsl:choose>
  174. </xsl:template>
  175. <xsl:template name="buildMemberItemResponseString">
  176. <xsl:param name="node"/>
  177. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@_path"/></xsl:with-param></xsl:call-template>
  178. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@_ref"/></xsl:with-param></xsl:call-template>
  179. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@levelLabel"/></xsl:with-param></xsl:call-template>
  180. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@levelNumber"/></xsl:with-param></xsl:call-template>
  181. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@levelUniqueName"/></xsl:with-param></xsl:call-template>
  182. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@memberCaption"/></xsl:with-param></xsl:call-template>
  183. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@memberUniqueName"/></xsl:with-param></xsl:call-template>
  184. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@parentUniqueName"/></xsl:with-param></xsl:call-template>
  185. </xsl:template>
  186. <xsl:template name="buildQueryItemResponseString">
  187. <xsl:param name="node"/>
  188. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@datatype"/></xsl:with-param></xsl:call-template>
  189. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@usage"/></xsl:with-param></xsl:call-template>
  190. <xsl:call-template name="elementEncode">
  191. <xsl:with-param name="strVal">
  192. <xsl:call-template name="aggregateConversion">
  193. <xsl:with-param name="strVal"><xsl:value-of select="$node/@regularAggregate"/></xsl:with-param>
  194. </xsl:call-template>
  195. </xsl:with-param>
  196. </xsl:call-template>
  197. <xsl:call-template name="elementEncode">
  198. <xsl:with-param name="strVal">
  199. <xsl:call-template name="aggregateConversion">
  200. <xsl:with-param name="strVal"><xsl:value-of select="$node/@semiAggregate"/></xsl:with-param>
  201. </xsl:call-template>
  202. </xsl:with-param>
  203. </xsl:call-template>
  204. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@promptType"/></xsl:with-param></xsl:call-template>
  205. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@displayType"/></xsl:with-param></xsl:call-template>
  206. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@sortOnRef"/></xsl:with-param></xsl:call-template>
  207. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@promptCascadeOnRef"/></xsl:with-param></xsl:call-template>
  208. <xsl:call-template name="elementEncode"><xsl:with-param name="strVal"><xsl:value-of select="$node/@promptFilterItemRef"/></xsl:with-param></xsl:call-template>
  209. </xsl:template>
  210. <xsl:template name="elementEncode">
  211. <xsl:param name="strVal"/>
  212. <xsl:element name="b">
  213. <xsl:value-of select="$strVal"/>
  214. </xsl:element>
  215. </xsl:template>
  216. <xsl:template name="aggregateConversion">
  217. <xsl:param name="strVal"/>
  218. <xsl:choose>
  219. <xsl:when test="$strVal = 'sum'">total</xsl:when>
  220. <xsl:when test="$strVal = 'min'">minimum</xsl:when>
  221. <xsl:when test="$strVal = 'max'">maximum</xsl:when>
  222. <xsl:when test="$strVal = 'avg'">average</xsl:when>
  223. <xsl:when test="$strVal = 'count' or $strVal = 'calculated' or $strVal = 'countDistinct' or
  224. $strVal = 'standardDeviation' or $strVal = 'variance' or $strVal = 'median' or
  225. $strVal = 'automatic'"><xsl:value-of select="$strVal"/></xsl:when>
  226. <xsl:otherwise>none</xsl:otherwise>
  227. </xsl:choose>
  228. </xsl:template>
  229. <pf:serialize-xml/>
  230. </xsl:stylesheet>
  231. </xts:block>
  232. </xts:morphlet>