post-process-main.xslt 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2011
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  13. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  14. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  15. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  16. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  17. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  18. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  19. exclude-result-prefixes="xsd xsi bus">
  20. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  21. <!-- global variables -->
  22. <xsl:variable name="xtscm" select="'http://developer.cognos.com/schemas/xts-cm/1/'"/>
  23. <xsl:variable name="xsd-prefix" select="'xsd'"/>
  24. <!-- main entry point -->
  25. <xsl:template match="/">
  26. <xsl:apply-templates select="SOAP-ENV:Body/bus:queryResponse"/>
  27. </xsl:template>
  28. <xsl:template match="bus:queryResponse">
  29. <queryResponse xmlns="http://developer.cognos.com/schemas/xts-cm/1/">
  30. <queryReply>
  31. <xsl:apply-templates select="queryResult/replies/item[1]/queryResult/item | returns/item[1]/queryResult/item"/>
  32. </queryReply>
  33. <queryReply>
  34. <xsl:apply-templates select="queryResult/replies/item[2]/queryResult/item | returns/item[2]/queryResult/item"/>
  35. </queryReply>
  36. <queryReply>
  37. <xsl:apply-templates select="queryResult/replies/item[3]/queryResult/item | returns/item[3]/queryResult/item"/>
  38. </queryReply>
  39. <xsl:apply-templates select="queryResult/cacheValidator"/>
  40. </queryResponse>
  41. </xsl:template>
  42. <xsl:template match="item">
  43. <xsl:variable name="class" select="substring-after(@xsi:type, ':')"/>
  44. <xsl:element name="{$class}" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  45. <cm:objectClass><xsl:value-of select="$class"/></cm:objectClass>
  46. <xsl:apply-templates select="*[not(contains(@xsi:type, 'ArrayProp'))]"/>
  47. <xsl:if test="base">
  48. <cm:base>
  49. <xsl:apply-templates select="base/value/item"/>
  50. </cm:base>
  51. </xsl:if>
  52. <xsl:if test="target">
  53. <cm:target>
  54. <xsl:apply-templates select="target/value/item"/>
  55. </cm:target>
  56. </xsl:if>
  57. <xsl:if test="metadataModelPackage">
  58. <cm:metadataModelPackage>
  59. <xsl:apply-templates select="metadataModelPackage/value/item"/>
  60. </cm:metadataModelPackage>
  61. </xsl:if>
  62. <xsl:if test="portalPages">
  63. <cm:portalPages>
  64. <xsl:apply-templates select="portalPages/value/item"/>
  65. </cm:portalPages>
  66. </xsl:if>
  67. <xsl:apply-templates select="ancestors"/>
  68. <xsl:apply-templates select="permissions"/>
  69. <xsl:apply-templates select="effectiveUserCapabilities"/>
  70. <xsl:apply-templates select="userInterfaces"/>
  71. <xsl:apply-templates select="defaultOutputFormat"/>
  72. <xsl:apply-templates select="options"/>
  73. <xsl:apply-templates select="mostRecentEventList"/>
  74. </xsl:element>
  75. </xsl:template>
  76. <xsl:template match="*[not(contains(@xsi:type, 'ArrayProp'))]" priority="-99">
  77. <!-- simple properties -->
  78. <xsl:element name="{local-name()}" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  79. <xsl:choose>
  80. <xsl:when test="starts-with(local-name(),'execution') and not(value)">
  81. <xsl:attribute name="nil">true</xsl:attribute>
  82. </xsl:when>
  83. <xsl:otherwise>
  84. <xsl:value-of select="value"/>
  85. </xsl:otherwise>
  86. </xsl:choose>
  87. </xsl:element>
  88. <xsl:if test="local-name() = 'storeID'">
  89. <xsl:element name="searchPathID" namespace="http://developer.cognos.com/schemas/xts-cm/1/"><xsl:value-of select="concat('storeID(&quot;', normalize-space(.), '&quot;)')"/></xsl:element>
  90. </xsl:if>
  91. </xsl:template>
  92. <xsl:template match="specification">
  93. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  94. <xsl:attribute name="type"><xsl:value-of select="@xsi:type"/></xsl:attribute>
  95. <xsl:value-of select="value" disable-output-escaping="yes"/>
  96. </xsl:element>
  97. </xsl:template>
  98. <xsl:template match="ancestors">
  99. <cm:ancestors>
  100. <xsl:for-each select="value/item">
  101. <cm:ancestorInfo>
  102. <cm:objectClass><xsl:value-of select="objectClass"/></cm:objectClass>
  103. <cm:searchPath><xsl:value-of select="searchPath"/></cm:searchPath>
  104. <cm:title><xsl:value-of select="title"/></cm:title>
  105. <cm:storeID><xsl:value-of select="storeID"/></cm:storeID>
  106. </cm:ancestorInfo>
  107. </xsl:for-each>
  108. </cm:ancestors>
  109. </xsl:template>
  110. <xsl:template match="permissions">
  111. <cm:permissions>
  112. <xsl:for-each select="value/item">
  113. <xsl:if test="position() > 1"><xsl:text> </xsl:text></xsl:if>
  114. <xsl:value-of select="."/>
  115. </xsl:for-each>
  116. </cm:permissions>
  117. </xsl:template>
  118. <xsl:template match="effectiveUserCapabilities">
  119. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  120. <xsl:for-each select="./value/item">
  121. <xsl:variable name="capability" select="string(.)"/>
  122. <xsl:if test="$capability != ''">
  123. <xsl:element name="{$capability}" namespace="{$xtscm}"/>
  124. </xsl:if>
  125. </xsl:for-each>
  126. </xsl:element>
  127. </xsl:template>
  128. <xsl:template match="options">
  129. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  130. <xsl:for-each select="value/item">
  131. <xsl:variable name="class" select="substring-after(@xsi:type, ':')"/>
  132. <xsl:element name="{$class}" namespace="{$xtscm}">
  133. <cm:name>
  134. <xsl:value-of select="name"/>
  135. </cm:name>
  136. <cm:value>
  137. <xsl:choose>
  138. <xsl:when test="value/item"><xsl:value-of select="value/item[1]"/></xsl:when>
  139. <xsl:otherwise><xsl:value-of select="value"/></xsl:otherwise>
  140. </xsl:choose>
  141. </cm:value>
  142. </xsl:element>
  143. </xsl:for-each>
  144. </xsl:element>
  145. </xsl:template>
  146. <xsl:template match="userInterfaces">
  147. <cm:userInterfaces>
  148. <xsl:for-each select="value/item">
  149. <cm:uiComponentEnum>
  150. <xsl:value-of select="."/>
  151. </cm:uiComponentEnum>
  152. </xsl:for-each>
  153. </cm:userInterfaces>
  154. </xsl:template>
  155. <xsl:template match="defaultOutputFormat">
  156. <cm:defaultOutputFormat>
  157. <xsl:if test="not(value/item)">
  158. <xsl:attribute name="nil">true</xsl:attribute>
  159. </xsl:if>
  160. <xsl:if test="value/item">
  161. <cm:string><xsl:value-of select="value/item"/></cm:string>
  162. </xsl:if>
  163. </cm:defaultOutputFormat>
  164. </xsl:template>
  165. <xsl:template match="*[local-name() = 'cacheValidator']">
  166. <xsl:element name="validator" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  167. <xsl:if test="string(.)!='NOT_SUPPORTED'"><xsl:value-of select="."/></xsl:if>
  168. </xsl:element>
  169. </xsl:template>
  170. <xsl:template match="state">
  171. <xsl:value-of select="./value" disable-output-escaping="yes"/>
  172. </xsl:template>
  173. <xsl:template match="mostRecentEventList">
  174. <cm:mostRecentEventList>
  175. <xsl:if test="not(value/item)">
  176. <xsl:attribute name="nil">true</xsl:attribute>
  177. </xsl:if>
  178. <xsl:if test="value/item">
  179. <xsl:value-of select="value/item/searchPath/value/."/>
  180. </xsl:if>
  181. </cm:mostRecentEventList>
  182. </xsl:template>
  183. </xsl:stylesheet>