pre-WARP-process.xslt 9.4 KB

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