pre-JSM-process.xslt 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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, 2015
  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. <!-- Since runOptions can be saved in CM for a jobDefinition and in JSM for a schedule on a report, we need this transform
  13. to change what we send to JSM into CM syntax. It's a mini CM/pre-process specific to runOptions-->
  14. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  15. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  16. xmlns:xtscm="http://developer.cognos.com/schemas/xts-cm/1/"
  17. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  18. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  20. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  21. xmlns:xsd="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xtscm">
  22. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  23. <!--
  24. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  25. process the xts syntax to the new Content Manager SOAP call
  26. -->
  27. <xsl:template match="*[local-name()='parameters']" priority="2">
  28. <parameters xsi:type="bus:parameterValueArrayProp">
  29. <value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:parameterValue[{count(xtscm:parameterValue)}]">
  30. <xsl:apply-templates/>
  31. </value>
  32. </parameters>
  33. </xsl:template>
  34. <!-- handle all "parameters" templates -->
  35. <xsl:template match="*[local-name()='parameterValue']">
  36. <item xsi:type="bus:parameterValue">
  37. <name xsi:type="xsd:string"><xsl:value-of select="*[local-name()='name']"/></name>
  38. <value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:parmValueItem[{count(*[not(self::*[local-name()='name'])])}]">
  39. <xsl:apply-templates select="*[not(self::*[local-name()='name'])]"/>
  40. </value>
  41. </item>
  42. </xsl:template>
  43. <xsl:template match="*[local-name()='simpleParmValueItem']">
  44. <item xsi:type="bus:simpleParmValueItem">
  45. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='inclusive']"/></inclusive>
  46. <xsl:call-template name="setDisplayAndUse">
  47. <xsl:with-param name="display"><xsl:value-of select="*[local-name()='display']"/></xsl:with-param>
  48. <xsl:with-param name="use"><xsl:value-of select="*[local-name()='use']"/></xsl:with-param>
  49. </xsl:call-template>
  50. </item>
  51. </xsl:template>
  52. <xsl:template match="*[local-name()='boundRangeParmValueItem']">
  53. <item xsi:type="bus:boundRangeParmValueItem">
  54. <xsl:choose>
  55. <xsl:when test="*[local-name()='inclusive']!=''">
  56. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='inclusive']"/></inclusive>
  57. </xsl:when>
  58. <xsl:otherwise>
  59. <inclusive xsi:type="xsd:boolean">true</inclusive>
  60. </xsl:otherwise>
  61. </xsl:choose>
  62. <start xsi:type="bus:simpleParmValueItem">
  63. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='start']/*[local-name()='inclusive']"/></inclusive>
  64. <xsl:call-template name="setDisplayAndUse">
  65. <xsl:with-param name="display"><xsl:value-of select="*[local-name()='start']/*[local-name()='display']"/></xsl:with-param>
  66. <xsl:with-param name="use"><xsl:value-of select="*[local-name()='start']/*[local-name()='use']"/></xsl:with-param>
  67. </xsl:call-template>
  68. </start>
  69. <end xsi:type="bus:simpleParmValueItem">
  70. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='end']/*[local-name()='inclusive']"/></inclusive>
  71. <xsl:call-template name="setDisplayAndUse">
  72. <xsl:with-param name="display"><xsl:value-of select="*[local-name()='end']/*[local-name()='display']"/></xsl:with-param>
  73. <xsl:with-param name="use"><xsl:value-of select="*[local-name()='end']/*[local-name()='use']"/></xsl:with-param>
  74. </xsl:call-template>
  75. </end>
  76. </item>
  77. </xsl:template>
  78. <xsl:template match="*[local-name()='unboundedEndRangeParmValueItem']">
  79. <item xsi:type="bus:unboundedEndRangeParmValueItem">
  80. <xsl:choose>
  81. <xsl:when test="*[local-name()='inclusive']!=''">
  82. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='inclusive']"/></inclusive>
  83. </xsl:when>
  84. <xsl:otherwise>
  85. <inclusive xsi:type="xsd:boolean">true</inclusive>
  86. </xsl:otherwise>
  87. </xsl:choose>
  88. <start xsi:type="bus:simpleParmValueItem">
  89. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='start']/*[local-name()='inclusive']"/></inclusive>
  90. <xsl:call-template name="setDisplayAndUse">
  91. <xsl:with-param name="display"><xsl:value-of select="*[local-name()='start']/*[local-name()='display']"/></xsl:with-param>
  92. <xsl:with-param name="use"><xsl:value-of select="*[local-name()='start']/*[local-name()='use']"/></xsl:with-param>
  93. </xsl:call-template>
  94. </start>
  95. </item>
  96. </xsl:template>
  97. <xsl:template match="*[local-name()='unboundedStartRangeParmValueItem']">
  98. <item xsi:type="bus:unboundedStartRangeParmValueItem">
  99. <xsl:choose>
  100. <xsl:when test="*[local-name()='inclusive']!=''">
  101. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='inclusive']"/></inclusive>
  102. </xsl:when>
  103. <xsl:otherwise>
  104. <inclusive xsi:type="xsd:boolean">true</inclusive>
  105. </xsl:otherwise>
  106. </xsl:choose>
  107. <end xsi:type="bus:simpleParmValueItem">
  108. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='end']/*[local-name()='inclusive']"/></inclusive>
  109. <xsl:call-template name="setDisplayAndUse">
  110. <xsl:with-param name="display"><xsl:value-of select="*[local-name()='end']/*[local-name()='display']"/></xsl:with-param>
  111. <xsl:with-param name="use"><xsl:value-of select="*[local-name()='end']/*[local-name()='use']"/></xsl:with-param>
  112. </xsl:call-template>
  113. </end>
  114. </item>
  115. </xsl:template>
  116. <!-- Match the first hierarchicalParmValueItem -->
  117. <xsl:template match="*[local-name()='hierarchicalParmValueItem' and parent::*[local-name() != 'hierarchicalParmValueItem']]">
  118. <item xsi:type="bus:hierarchicalParmValueItem">
  119. <xsl:choose>
  120. <xsl:when test="*[local-name()='inclusive']!=''">
  121. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='inclusive']"/></inclusive>
  122. </xsl:when>
  123. <xsl:otherwise>
  124. <inclusive xsi:type="xsd:boolean">true</inclusive>
  125. </xsl:otherwise>
  126. </xsl:choose>
  127. <value xsi:type="bus:simpleParmValueItem">
  128. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='value']/*[local-name()='inclusive']"/></inclusive>
  129. <xsl:call-template name="setDisplayAndUse">
  130. <xsl:with-param name="display"><xsl:value-of select="*[local-name()='value']/*[local-name()='display']"/></xsl:with-param>
  131. <xsl:with-param name="use"><xsl:value-of select="*[local-name()='value']/*[local-name()='use']"/></xsl:with-param>
  132. </xsl:call-template>
  133. </value>
  134. <xsl:apply-templates select="*[local-name()='hierarchicalParmValueItem']"/>
  135. </item>
  136. </xsl:template>
  137. <!-- Match all the sub hierarchicalParmValueItem parameters -->
  138. <xsl:template match="*[local-name()='hierarchicalParmValueItem' and parent::*[local-name() = 'hierarchicalParmValueItem']]">
  139. <subNodes xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:hierarchicalParmValueItem[{count(*[local-name()='hierarchicalParmValueItem'])}]">
  140. <item xsi:type="bus:hierarchicalParmValueItem">
  141. <xsl:choose>
  142. <xsl:when test="*[local-name()='inclusive']!=''">
  143. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='inclusive']"/></inclusive>
  144. </xsl:when>
  145. <xsl:otherwise>
  146. <inclusive xsi:type="xsd:boolean">true</inclusive>
  147. </xsl:otherwise>
  148. </xsl:choose>
  149. <value xsi:type="bus:simpleParmValueItem">
  150. <inclusive xsi:type="xsd:boolean"><xsl:value-of select="*[local-name()='value']/*[local-name()='inclusive']"/></inclusive>
  151. <xsl:call-template name="setDisplayAndUse">
  152. <xsl:with-param name="display"><xsl:value-of select="*[local-name()='value']/*[local-name()='display']"/></xsl:with-param>
  153. <xsl:with-param name="use"><xsl:value-of select="*[local-name()='value']/*[local-name()='use']"/></xsl:with-param>
  154. </xsl:call-template>
  155. </value>
  156. <xsl:apply-templates select="*[local-name()='hierarchicalParmValueItem']"/>
  157. </item>
  158. </subNodes>
  159. </xsl:template>
  160. <!--
  161. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  162. generic text() handler
  163. -->
  164. <xsl:template match="text()" priority="0">
  165. <xsl:copy-of select="."/>
  166. </xsl:template>
  167. <!--
  168. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  169. check for empty values and set to "nil"
  170. -->
  171. <xsl:template name="setDisplayAndUse">
  172. <xsl:param name="display"/>
  173. <xsl:param name="use"/>
  174. <xsl:choose>
  175. <xsl:when test="$display!=''">
  176. <display xsi:type="xsd:string"><xsl:value-of select="$display"/></display>
  177. </xsl:when>
  178. <xsl:otherwise>
  179. <display xsi:nil="true"/>
  180. </xsl:otherwise>
  181. </xsl:choose>
  182. <xsl:choose>
  183. <xsl:when test="$use!=''">
  184. <use xsi:type="xsd:string"><xsl:value-of select="$use"/></use>
  185. </xsl:when>
  186. <xsl:otherwise>
  187. <use xsi:nil="true"/>
  188. </xsl:otherwise>
  189. </xsl:choose>
  190. </xsl:template>
  191. </xsl:stylesheet>