cm-save.xsl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. <!--
  9. ===============================================================================================
  10. Logic sheet for dealing with "special" properties stored in CM.
  11. ===============================================================================================
  12. -->
  13. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:cms="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/cms/1/" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" xmlns:out="dummy-uri" exclude-result-prefixes="cms xtsext">
  14. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  15. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  16. <!-- Apply "special" processing when saving certain CM poperties -->
  17. <xsl:template match="cms:prop-save">
  18. <!-- Handle unwritable properties -->
  19. <out:template match="*[local-name() = 'param'][@name = 'm_p_path']"/>
  20. <out:template match="*[local-name() = 'param'][@name = 'm_p_searchPath']"/>
  21. <!-- handle building the run options property -->
  22. <!-- we have to match all the runOptions that we support here since we have to associate a type (int, string, ...) to them to pass along to pre-process -->
  23. <out:template name="build_runOptions">
  24. <out:param name="env"/>
  25. <out:param name="jobStep" select="false()"/>
  26. <out:if test="$env/*[local-name()='param' and starts-with(@name,'m_ro_')]">
  27. <runOptions xmlns="http://developer.cognos.com/schemas/xts-cm/1/">
  28. <!-- all the runOptionBoolean (m_ro_email, m_ro_emailAsAsttachment, m_ro_emailAsURL, m_ro_print, m_ro_saveOutput) -->
  29. <out:for-each select="$env/*[@name = 'm_ro_burst' or @name='m_ro_print' or @name='m_ro_prompt']">
  30. <out:variable name="value" select="."/>
  31. <out:if test="$value != ''">
  32. <out:variable name="runOptionName" select="substring-after(@name, 'm_ro_')"/>
  33. <runOption class="runOptionBoolean">
  34. <name>
  35. <out:value-of select="$runOptionName"/>
  36. </name>
  37. <value type="boolean">
  38. <out:value-of select="."/>
  39. </value>
  40. </runOption>
  41. </out:if>
  42. </out:for-each>
  43. <!-- special cases were we have to save a value of false in CM -->
  44. <out:if test="not($jobStep) and not($env/*[@name='m_ro_burst']) and $env/*[@name='specify_burst']">
  45. <runOption class="runOptionBoolean">
  46. <name>burst</name>
  47. <value type="boolean">false</value>
  48. </runOption>
  49. </out:if>
  50. <!-- special cases were we have to save a value of false in CM -->
  51. <out:if test="not($env/*[@name='m_ro_prompt']) and $env/*[@name='changed_m_ro_prompt']">
  52. <runOption class="runOptionBoolean">
  53. <name>prompt</name>
  54. <value type="boolean">false</value>
  55. </runOption>
  56. </out:if>
  57. <!-- m_ro_outputPageDefinition, m_ro_outputPageOrientation -->
  58. <!-- only save these values if the PDF checkbox is checked and the specify checkbox is checked or not present -->
  59. <out:if test="$env/*[@name='m_ro_outputFormat_PDF'] = 'PDF' and (not($env/*[@name='changed_specify_format']) or $env/*[@name='specify_format']='checked')">
  60. <out:for-each select="$env/*[@name='m_ro_outputPageDefinition' or @name='m_ro_outputPageOrientation']">
  61. <out:if test=". != 'default'">
  62. <out:variable name="runOptionName" select="substring-after(@name, 'm_ro_')"/>
  63. <runOption class="runOptionString">
  64. <name>
  65. <out:value-of select="$runOptionName"/>
  66. </name>
  67. <value type="string">
  68. <out:value-of select="."/>
  69. </value>
  70. </runOption>
  71. </out:if>
  72. </out:for-each>
  73. </out:if>
  74. <!-- m_ro_printerAddress, m_ro_printer -->
  75. <!-- only save these values if the printer checkbox is checked -->
  76. <out:choose>
  77. <out:when test="$env/*[@name='m_ro_print']='true'">
  78. <out:for-each select="$env/*[@name='m_ro_printerAddress' or @name='m_ro_printer']">
  79. <out:variable name="runOptionName" select="substring-after(@name, 'm_ro_')"/>
  80. <!-- we use either 'printer' or 'printerAddress' to specify a printer.-->
  81. <out:if test="$env/*[@name='ro_printer_kw'] = $runOptionName">
  82. <runOption class="runOptionString">
  83. <name>
  84. <out:value-of select="$runOptionName"/>
  85. </name>
  86. <value type="string">
  87. <out:value-of select="."/>
  88. </value>
  89. </runOption>
  90. </out:if>
  91. </out:for-each>
  92. </out:when>
  93. <out:when test="not($jobStep)">
  94. <runOption class="runOptionBoolean">
  95. <name>print</name>
  96. <value type="boolean">false</value>
  97. </runOption>
  98. </out:when>
  99. </out:choose>
  100. <!-- if we're doing a saveAs -->
  101. <out:choose>
  102. <out:when test="$env/*[@name='save_how'] and $env/*[@name='save_how']='new_entry'">
  103. <runOption class="runOptionSaveAs">
  104. <name>saveAs</name>
  105. <property name="objectClass" type="reportSaveAsEnum">
  106. <out:value-of select="$env/*[@name='m_ro_saveAsType']"/>
  107. </property>
  108. <property name="objectName" type="multilingualToken">
  109. <item type="multilingualToken">
  110. <locale type="string">
  111. <out:value-of select="$contentLocale"/>
  112. </locale>
  113. <value type="string">
  114. <out:value-of select="$env/*[@name='m_ro_saveAsName']"/>
  115. </value>
  116. </item>
  117. </property>
  118. <property name="parentSearchPath" type="string">
  119. <out:value-of select="$env/*[@name='m_ro_saveAsPath']"/>
  120. </property>
  121. </runOption>
  122. </out:when>
  123. <out:when test="$env/*[@name='m_ro_saveOutput'] and $env/*[@name='m_ro_saveOutput']!=''">
  124. <runOption class="runOptionBoolean">
  125. <name>
  126. <out:value-of select="'saveOutput'"/>
  127. </name>
  128. <value type="boolean">
  129. <out:value-of select="$env/*[@name='m_ro_saveOutput']"/>
  130. </value>
  131. </runOption>
  132. </out:when>
  133. <out:when test="not($jobStep) and not($env/*[@name='m_ro_saveOutput'])">
  134. <runOption class="runOptionBoolean">
  135. <name>saveOutput</name>
  136. <value type="boolean">false</value>
  137. </runOption>
  138. </out:when>
  139. </out:choose>
  140. <out:if test="$env/*[@name='m_ro_email'] != ''">
  141. <runOption class="runOptionBoolean">
  142. <name>email</name>
  143. <value type="boolean">true</value>
  144. </runOption>
  145. </out:if>
  146. <!-- email related runOptions
  147. < if we're not emailing as an attachement, then set the runOption to false
  148. <out:if test="not($jobStep) and not($env/*[@name='m_ro_emailAsAttachment'])">
  149. <runOption class="runOptionBoolean">
  150. <name>emailAsAttachment</name>
  151. <value type="boolean">false</value>
  152. </runOption>
  153. </out:if>
  154. < if we're not emailing as a URL, then set the runOption to false
  155. <out:if test="not($jobStep) and not($env/*[@name='m_ro_emailAsURL'])">
  156. <runOption class="runOptionBoolean">
  157. <name>emailAsURL</name>
  158. <value type="boolean">false</value>
  159. </runOption>
  160. </out:if>
  161. <- emailSubject and emailBody - runOptionString
  162. <out:for-each select="$env/*[@name='m_ro_emailBody' or @name='m_ro_emailSubject']">
  163. <out:variable name="runOptionName" select="substring-after(@name, 'm_ro_')"/>
  164. <runOption class="runOptionMultilingualString">
  165. <name><out:value-of select="$runOptionName"/></name>
  166. <items type="cm:multilingualString">
  167. <item type="multilingualString">
  168. <locale type="string"><out:value-of select="$contentLocale"/></locale>
  169. <value type="string"><out:value-of select="."/></value>
  170. </item>
  171. </items>
  172. </runOption>
  173. </out:for-each>
  174. <- emailTo, emailToAddress - runOptionStringArray
  175. <out:if test="(not(/root/env/param[@name='m_ro_burst']) or $env/*[@name='visited_job_properties'] or $env/*[@name='run_with_options_job'])and /root/emailToRunOptions">
  176. <out:copy-of select="/root/emailToRunOptions/*"/>
  177. </out:if>
  178. </out:when>
  179. <out:when test="not($jobStep)">
  180. <runOption class="runOptionBoolean">
  181. <name>email</name>
  182. <value type="boolean">false</value>
  183. </runOption>
  184. </out:when>
  185. </out:choose-->
  186. <!-- copy the delivery options created by the email options page
  187. but we re wrap them, so they can pass through pre-process undigested-->
  188. <out:for-each select="$env/options/value/item">
  189. <xtscm:deliveryOption xmlns:xtscm="http://developer.cognos.com/schemas/xts-cm/1/" cmStyle="true">
  190. <out:copy-of select="."/>
  191. </xtscm:deliveryOption>
  192. </out:for-each>
  193. <!-- outputFormat - runOptionStringArray-->
  194. <out:if test="$env/*[starts-with(@name,'m_ro_outputFormat')] and (not($env/*[@name='changed_specify_format']) or $env/*[@name='specify_format']='checked')">
  195. <xsl:call-template name="build_runOptionArray">
  196. <xsl:with-param name="class" select="'runOptionStringArray'"/>
  197. <xsl:with-param name="type" select="'stringArray'"/>
  198. <xsl:with-param name="name" select="'outputFormat'"/>
  199. </xsl:call-template>
  200. </out:if>
  201. <!-- outputLocale - runOptionLanguageArray -->
  202. <out:if test="$env/*[@name='m_ro_outputLocale'] and (not($env/*[@name='changed_specify_language']) or $env/*[@name='specify_language']='checked')">
  203. <xsl:call-template name="build_runOptionArray">
  204. <xsl:with-param name="class" select="'runOptionLanguageArray'"/>
  205. <xsl:with-param name="type" select="'LanguageArray'"/>
  206. <xsl:with-param name="name" select="'outputLocale'"/>
  207. </xsl:call-template>
  208. </out:if>
  209. </runOptions>
  210. </out:if>
  211. </out:template>
  212. </xsl:template>
  213. <xsl:template name="build_runOptionArray">
  214. <xsl:param name="class"/>
  215. <xsl:param name="type"/>
  216. <xsl:param name="name"/>
  217. <runOption xmlns="http://developer.cognos.com/schemas/xts-cm/1/" class="{$class}">
  218. <name>
  219. <xsl:value-of select="$name"/>
  220. </name>
  221. <items>
  222. <out:for-each select="$env/*[starts-with(@name,concat('m_ro_','{$name}'))]">
  223. <out:if test="(@name!='m_ro_outputFormat_HTML' or $env/*[@name='m_ro_outputF_HTML_Type']='true') and (@name!='m_ro_outputFormat_XLS2000' or $env/*[@name='m_ro_outputF_XLS2000_Type']='true') and . != ''">
  224. <item>
  225. <out:value-of select="."/>
  226. </item>
  227. </out:if>
  228. </out:for-each>
  229. </items>
  230. </runOption>
  231. </xsl:template>
  232. <xsl:template match="*">
  233. <xsl:copy>
  234. <xsl:copy-of select="@*"/>
  235. <xsl:apply-templates/>
  236. </xsl:copy>
  237. </xsl:template>
  238. <!-- Apply "special" processing when saving certain CM poperties -->
  239. <xsl:template match="cms:build_keyItems">
  240. <out:template name="build_keyItems">
  241. <out:param name="keyItems"/>
  242. <out:variable name="before">
  243. <out:value-of select="substring-before($keyItems,';')"/>
  244. </out:variable>
  245. <out:variable name="after">
  246. <out:value-of select="substring-after($keyItems,';')"/>
  247. </out:variable>
  248. <out:if test="string-length(normalize-space($before)) > 0">
  249. <cm:item>
  250. <out:value-of select="normalize-space($before)"/>
  251. </cm:item>
  252. </out:if>
  253. <out:if test="string-length(normalize-space($after)) > 0">
  254. <out:call-template name="build_keyItems">
  255. <out:with-param name="keyItems">
  256. <out:value-of select="$after"/>
  257. </out:with-param>
  258. </out:call-template>
  259. </out:if>
  260. </out:template>
  261. </xsl:template>
  262. </xsl:stylesheet>