buildOptionItems.xslt 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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, 2016
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Expects the following
  10. <root>
  11. <env>
  12. ...
  13. </env>
  14. <optionsList>
  15. <runOptions nameType="bus:runOptionEnum">
  16. <option name="burst" optionType="bus:runOptionBoolean" type="xsd:boolean" envName="m_ro_burst" comp="simple"/>
  17. ...
  18. </runOptions>
  19. </optionsList>
  20. <deliveryOptions>
  21. deliveryOptions already formated to be sent to CM
  22. </deliveryOptions>
  23. <mobileOptions>
  24. mobileOptions already formated to be sent to CM
  25. </mobileOptions>
  26. <contentLocale>en-us</contentLocale> **only needed if you want to build the runOptions saveAs**
  27. <optionType>...</optionType> What options should be used in option.xml. If not specified, then all the options will be used
  28. <genDefaults>false</genDefaults> Should defaults from option.xml be used. If not specified, defaults will be generated
  29. <reportOptions>false</reportOptions> Are we building the options array to save on a report?
  30. <jobDefaultSaveOutputOption> The job's saveOutput option
  31. </root>
  32. -->
  33. <xsl:stylesheet version="1.0"
  34. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  35. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  36. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  37. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  38. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  39. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  40. exclude-result-prefixes="bus xsi xsl xts SOAP-ENC">
  41. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  42. <xsl:key name="env-param" match="/root/env/param" use="@name"/>
  43. <xsl:key name="options" match="/root/optionsList/*/option" use="concat(local-name(parent::*), '-', @name)"/>
  44. <xsl:variable name="env" select="/root/env"/>
  45. <xsl:variable name="promptCacheMode" select="string($env/param[@name='m_ro_promptCacheMode'])"/>
  46. <xsl:variable name="reportOptions" select="/root/reportOptions = 'true'"/>
  47. <xsl:template match="/root" priority="3">
  48. <xsl:choose>
  49. <xsl:when test="/root/*[local-name()='optionType'] != ''">
  50. <xsl:for-each select="/root/*[local-name()='optionType']">
  51. <xsl:variable name="optionType" select="."/>
  52. <xsl:apply-templates select="/root/optionsList/*[local-name()=$optionType]/option[not(@complex='T')]" mode="simpleOptions"/>
  53. </xsl:for-each>
  54. </xsl:when>
  55. <xsl:otherwise>
  56. <xsl:apply-templates select="/root/optionsList/*/option[not(@complex='T')]" mode="simpleOptions"/>
  57. </xsl:otherwise>
  58. </xsl:choose>
  59. <xsl:call-template name="buildComplexOptions"/>
  60. <!-- handle deliveryOptions -->
  61. <xsl:if test="key('env-param','m_ro_email') = 'true'">
  62. <xsl:variable name="deliveryOptions" select="/root/*[local-name()='deliveryOptions']/*[local-name()='options']/*[local-name()='value']/*[*[local-name()='name']/@xsi:type='bus:deliveryOptionEnum']"/>
  63. <xsl:choose>
  64. <xsl:when test="key('env-param','m_ro_burst') = 'true' and not(key('env-param','run_options_visited'))">
  65. <!-- remove any recipients that were specified -->
  66. <xsl:copy-of select="$deliveryOptions[local-name()='item' and *[local-name()='name' and (.!='toAddress' and .!='ccAddress' and .!='bccAddress' and .!='to' and .!='cc' and .!='bcc')]]"/>
  67. </xsl:when>
  68. <xsl:otherwise>
  69. <xsl:copy-of select="$deliveryOptions"/>
  70. </xsl:otherwise>
  71. </xsl:choose>
  72. <xsl:choose>
  73. <xsl:when test="/root/*[local-name()='optionType'] = 'powerPlay8Options'">
  74. <xsl:copy-of select="/root/*[local-name()='deliveryOptions']/*[local-name()='options']/*[local-name()='value']/*[*[local-name()='name']/@xsi:type='bus:powerPlay8OptionEnum']"/>
  75. </xsl:when>
  76. <xsl:when test="/root/*[local-name()='optionType'] = 'powerPlay8JobOptions' and /root/*[local-name()='optionType'] = 'runOptions'">
  77. <xsl:copy-of select="/root/*[local-name()='deliveryOptions']/*[local-name()='options']/*[local-name()='value']/*[*[local-name()='name']/@xsi:type!='bus:deliveryOptionEnum']"/>
  78. </xsl:when>
  79. <xsl:otherwise>
  80. <xsl:copy-of select="/root/*[local-name()='deliveryOptions']/*[local-name()='options']/*[local-name()='value']/*[*[local-name()='name']/@xsi:type='bus:runOptionEnum']"/>
  81. </xsl:otherwise>
  82. </xsl:choose>
  83. </xsl:if>
  84. <!-- handle mobileOptions -->
  85. <xsl:if test="key('env-param','m_ro_mobile') = 'true'">
  86. <xsl:copy-of select="/root/*[local-name()='mobileOptions']/*[local-name()='options']/*[local-name()='value']/*"/>
  87. </xsl:if>
  88. </xsl:template>
  89. <!-- special handling for the printers -->
  90. <xsl:template match="*[local-name()='option' and @envName = 'm_ro_printer' or @envName = 'm_ro_printerAddress']" mode="simpleOptions" priority="2">
  91. <xsl:if test="key('env-param','ro_printer_kw') = @name and key('env-param','m_ro_print')='true'">
  92. <item xsi:type="{@optionType}">
  93. <name xsi:type="{../@nameType}"><xsl:value-of select="@name"/></name>
  94. <value xsi:type="{@type}"><xsl:value-of select="key('env-param',@envName)"/></value>
  95. </item>
  96. </xsl:if>
  97. </xsl:template>
  98. <!-- special handling for the selectionBasedFeatures -->
  99. <xsl:template match="*[local-name()='option' and @envName = 'm_ro_selectionBasedFeatures']" mode="simpleOptions" priority="2">
  100. <xsl:if test="key('env-param','m_ro_selectionBasedFeatures') != ''">
  101. <item xsi:type="{@optionType}">
  102. <name xsi:type="{../@nameType}"><xsl:value-of select="@name"/></name>
  103. <value xsi:type="{@type}"><xsl:value-of select="key('env-param',@envName)"/></value>
  104. </item>
  105. </xsl:if>
  106. </xsl:template>
  107. <!-- special handling for the saveOutput runOption -->
  108. <xsl:template match="*[local-name()='option' and @envName = 'm_ro_saveOutput']" mode="simpleOptions" priority="2">
  109. <!-- save the saveOutput runoption under the following conditions
  110. - if we're not building the options array for a report
  111. - if the default options are overriden and we're refreshing the report cache-->
  112. <xsl:if test="not($reportOptions) or (key('env-param','override_default_options')='true' and $promptCacheMode='refresh')">
  113. <item xsi:type="{@optionType}">
  114. <name xsi:type="{../@nameType}"><xsl:value-of select="@name"/></name>
  115. <value xsi:type="{@type}">
  116. <xsl:choose>
  117. <xsl:when test="$promptCacheMode='create' and @ifClearPromptCache!=''"><xsl:value-of select="@ifClearPromptCache"/></xsl:when>
  118. <!-- check override-default-reportoptions is un-checked and that we are visiting schedule properties -->
  119. <xsl:when test="key('env-param','changed_override_default_reportOptions') and not(key('env-param','override_default_reportOptions')) and key('env-param','visited_schedule_properties')='true'">true</xsl:when>
  120. <xsl:when test="key('env-param','override_outputFormat_option')='true'">true</xsl:when>
  121. <!-- force saveOutput to true (or the job's default setting) if the user didn't override the default job options -->
  122. <xsl:when test="key('env-param','changed_override_default_options') and not(key('env-param','override_default_options')) and (key('env-param','run_options_visited')='true' or key('env-param','step_options_visited')='true')">
  123. <xsl:choose>
  124. <xsl:when test="/root/jobDefaultSaveOutputOption"><xsl:value-of select="/root/jobDefaultSaveOutputOption"/></xsl:when>
  125. <xsl:otherwise>true</xsl:otherwise>
  126. </xsl:choose>
  127. </xsl:when>
  128. <xsl:when test="key('env-param','m_ro_saveOutput')='true' and (not(key('env-param','save_how')) or key('env-param','save_how')!='new_entry')">true</xsl:when>
  129. <xsl:otherwise>false</xsl:otherwise>
  130. </xsl:choose>
  131. </value>
  132. </item>
  133. </xsl:if>
  134. </xsl:template>
  135. <!-- special handling for the promptCacheMode runOption for job steps: when set to none, don't save it this allows the default to be picked up from the report -->
  136. <xsl:template match="*[local-name()='option' and @envName = 'm_ro_promptCacheMode' and $promptCacheMode='none' and (key('env-param','run_options_visited')='true' or key('env-param','step_options_visited')='true')]" mode="simpleOptions" priority="2"/>
  137. <!-- special handling for the contentTask (check options) -->
  138. <xsl:template match="*[local-name()='option' and @envName = 'cto_consistency_check']" mode="simpleOptions" priority="2">
  139. <xsl:choose>
  140. <xsl:when test="key('env-param','ctro_runoption')='fix'">
  141. <item xsi:type="{@optionType}">
  142. <name xsi:type="{../@nameType}"><xsl:value-of select="@name"/></name>
  143. <value xsi:type="{@type}"><xsl:value-of select="'false'"/></value>
  144. </item>
  145. </xsl:when>
  146. <xsl:when test="key('env-param','ctro_runoption')='find'">
  147. <item xsi:type="{@optionType}">
  148. <name xsi:type="{../@nameType}"><xsl:value-of select="@name"/></name>
  149. <value xsi:type="{@type}">
  150. <xsl:choose>
  151. <xsl:when test="@name = 'checkInternalInconsistencies' and key('env-param','cto_consistency_check')='internalRef'"><xsl:value-of select="'true'"/></xsl:when>
  152. <xsl:when test="@name = 'checkSecurityReferences' and key('env-param','cto_consistency_check')='internalRef'"><xsl:value-of select="'false'"/></xsl:when>
  153. <xsl:when test="@name = 'checkInternalInconsistencies' and key('env-param','cto_consistency_check')='externalRef'"><xsl:value-of select="'false'"/></xsl:when>
  154. <xsl:when test="@name = 'checkSecurityReferences' and key('env-param','cto_consistency_check')='externalRef'"><xsl:value-of select="'true'"/></xsl:when>
  155. </xsl:choose>
  156. </value>
  157. </item>
  158. </xsl:when>
  159. </xsl:choose>
  160. </xsl:template>
  161. <!-- special handling for the contentTask (repair options) -->
  162. <xsl:template match="*[local-name()='option' and @envName = 'ctro_runoption']" mode="simpleOptions" priority="2">
  163. <xsl:choose>
  164. <xsl:when test="key('env-param','ctro_runoption')='find'">
  165. <item xsi:type="{@optionType}">
  166. <name xsi:type="{../@nameType}"><xsl:value-of select="@name"/></name>
  167. <value xsi:type="{@type}"><xsl:value-of select="'false'"/></value>
  168. </item>
  169. </xsl:when>
  170. <xsl:when test="key('env-param','ctro_runoption')='fix'">
  171. <item xsi:type="{@optionType}">
  172. <name xsi:type="{../@nameType}"><xsl:value-of select="@name"/></name>
  173. <value xsi:type="{@type}">
  174. <xsl:choose>
  175. <xsl:when test="@name = 'repairInternalInconsistencies' and key('env-param','cto_consistency_check')='internalRef'"><xsl:value-of select="'true'"/></xsl:when>
  176. <xsl:when test="@name = 'repairSecurityReferences' and key('env-param','cto_consistency_check')='internalRef'"><xsl:value-of select="'false'"/></xsl:when>
  177. <xsl:when test="@name = 'repairInternalInconsistencies' and key('env-param','cto_consistency_check')='externalRef'"><xsl:value-of select="'false'"/></xsl:when>
  178. <xsl:when test="@name = 'repairSecurityReferences' and key('env-param','cto_consistency_check')='externalRef'"><xsl:value-of select="'true'"/></xsl:when>
  179. </xsl:choose>
  180. </value>
  181. </item>
  182. </xsl:when>
  183. </xsl:choose>
  184. </xsl:template>
  185. <!-- handle all the boolean, int and string options -->
  186. <!-- note: we handle these types: xmlEncodedXML, portalListSeparatorEnum here for now -->
  187. <xsl:template match="*[local-name()='option' and @envName!='m_io_includedObjects']" mode="simpleOptions" priority="1">
  188. <xsl:choose>
  189. <xsl:when test="key('env-param',@envName) != '' or (@type = 'xsd:boolean' and not(key('env-param',@envName)) and key('env-param',concat('changed_', @envName)) = '1')">
  190. <item xsi:type="{@optionType}">
  191. <name xsi:type="{../@nameType}"><xsl:value-of select="@name"/></name>
  192. <value xsi:type="{@type}">
  193. <xsl:choose>
  194. <xsl:when test="$promptCacheMode='create' and @ifClearPromptCache!=''"><xsl:value-of select="@ifClearPromptCache"/></xsl:when>
  195. <xsl:when test="@type = 'xsd:boolean' and not(key('env-param',@envName)) and key('env-param',concat('changed_', @envName)) = '1'">false</xsl:when>
  196. <xsl:otherwise><xsl:value-of select="key('env-param',@envName)"/></xsl:otherwise>
  197. </xsl:choose>
  198. </value>
  199. </item>
  200. </xsl:when>
  201. <!-- build a default option if a default is specified, or force is set to true -->
  202. <xsl:when test="(@default != '' and (not(/root/genDefaults) or /root/genDefaults = 'true')) or @forceDefault='true' or (@envName='m_ro_data' and not($reportOptions))">
  203. <item xsi:type="{@optionType}">
  204. <name xsi:type="{../@nameType}"><xsl:value-of select="@name"/></name>
  205. <value xsi:type="{@type}">
  206. <xsl:choose>
  207. <xsl:when test="$promptCacheMode='create' and @ifClearPromptCache!=''">
  208. <xsl:value-of select="@ifClearPromptCache"/>
  209. </xsl:when>
  210. <xsl:when test="/root/batchOptions = 'true' and @batchDefault">
  211. <xsl:value-of select="@batchDefault"/>
  212. </xsl:when>
  213. <xsl:otherwise>
  214. <xsl:value-of select="@default"/>
  215. </xsl:otherwise>
  216. </xsl:choose>
  217. </value>
  218. </item>
  219. </xsl:when>
  220. </xsl:choose>
  221. </xsl:template>
  222. <!--
  223. Need special handling to build complex options
  224. -->
  225. <xsl:template name="buildComplexOptions">
  226. <!-- outputFormat -->
  227. <xsl:if test="$env/*[starts-with(@name,'m_ro_outputFormat')]">
  228. <xsl:call-template name="buildOptionArray">
  229. <xsl:with-param name="type" select="'runOptions'"/>
  230. <xsl:with-param name="name" select="'outputFormat'"/>
  231. </xsl:call-template>
  232. </xsl:if>
  233. <!-- outputLocale -->
  234. <xsl:if test="key('env-param','m_ro_outputLocale')">
  235. <!-- When generating options for a job, we want to save the outputLocales as both runOptions and powerPlay8JobOptions, so run through this code multiple times -->
  236. <xsl:for-each select="/root/*[local-name()='optionType']">
  237. <xsl:call-template name="buildOptionArray">
  238. <xsl:with-param name="type" select="."/>
  239. <xsl:with-param name="name" select="'outputLocale'"/>
  240. </xsl:call-template>
  241. </xsl:for-each>
  242. </xsl:if>
  243. <!-- saveAs -->
  244. <xsl:if test="key('env-param','save_how')='new_entry' and (key('env-param','m_ro_saveOutput')='true' or not(key('env-param','m_ro_saveOutput')))">
  245. <item xsi:type="bus:runOptionSaveAs">
  246. <name xsi:type="bus:runOptionEnum">saveAs</name>
  247. <objectClass xsi:type="bus:reportSaveAsEnum"><xsl:value-of select="key('env-param','m_ro_saveAsType')"/></objectClass>
  248. <objectName xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:multilingualToken[1]">
  249. <item xsi:type="bus:multilingualToken">
  250. <locale xsi:type="xsd:string"><xsl:value-of select="/root/*[local-name()='contentLocale']"/></locale>
  251. <value xsi:type="xsd:string"><xsl:value-of select="key('env-param','m_ro_saveAsName')"/></value>
  252. </item>
  253. </objectName>
  254. <parentSearchPath xsi:type="xsd:string">
  255. <xsl:choose>
  256. <xsl:when test="key('env-param','m_ro_saveAsPath')!=''">
  257. <xsl:value-of select="key('env-param','m_ro_saveAsPath')"/>
  258. </xsl:when>
  259. <xsl:otherwise>
  260. <xsl:value-of select="key('env-param','m_path')"/>
  261. </xsl:otherwise>
  262. </xsl:choose>
  263. </parentSearchPath>
  264. </item>
  265. </xsl:if>
  266. <xsl:if test="(/root/optionType='contentTaskProperties')">
  267. <xsl:choose>
  268. <!-- report upgrade -->
  269. <xsl:when test="$env/param[@name='contentTaskType']='reportUpgrade'">
  270. <!-- upgradeClassesContext -->
  271. <xsl:call-template name="buildOptionArray">
  272. <xsl:with-param name="type" select="'contentTaskProperties'"/>
  273. <xsl:with-param name="name" select="'upgradeClasses'"/>
  274. </xsl:call-template>
  275. <!-- upgradeClassesContext -->
  276. <xsl:call-template name="buildOptionArray">
  277. <xsl:with-param name="type" select="'contentTaskProperties'"/>
  278. <xsl:with-param name="name" select="'upgradeClassesContext'"/>
  279. </xsl:call-template>
  280. <!-- upgradeClassesReferenceContext -->
  281. <xsl:call-template name="buildOptionArray">
  282. <xsl:with-param name="type" select="'contentTaskProperties'"/>
  283. <xsl:with-param name="name" select="'upgradeClassesReferenceContext'"/>
  284. </xsl:call-template>
  285. </xsl:when>
  286. <!-- content utilization -->
  287. <xsl:when test="$env/param[@name='contentTaskType']='createContentUtilizationInfo'">
  288. <xsl:variable name="optionDef" select="key('options', 'contentTaskOptions-createContentStoreUtilizationInfo')"/>
  289. <xsl:variable name="itemType" select="$optionDef/@optionType"/>
  290. <item xsi:type="bus:contentTaskOptionCSUtilizationConfiguration">
  291. <name xsi:type="bus:contentTaskOptionEnum">createContentStoreUtilizationInfo</name>
  292. <value xsi:type="bus:contentStoreUtilizationConfiguration">
  293. <xsl:variable name="filePerTenant" select="/root/env/param[@name='cto_filePerTenant']"/>
  294. <xsl:if test="$filePerTenant!=''">
  295. <filePerTenant xsi:type="xs:boolean"><xsl:value-of select="$filePerTenant"/></filePerTenant>
  296. </xsl:if>
  297. <tenantFilter xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xs:string[]">
  298. <xsl:for-each select="/root/env/param[@name='selectedTenants']">
  299. <item xsi:type="xs:string"><xsl:value-of select="."/></item>
  300. </xsl:for-each>
  301. <xsl:if test="/root/env/param[@name='selectPublicTenant']='true'">
  302. <item xsi:type="xs:string"/>
  303. </xsl:if>
  304. </tenantFilter>
  305. <xsl:variable name="granularity" select="/root/env/param[@name='cto_granularity']"/>
  306. <xsl:if test="$granularity!=''">
  307. <granularity xsi:type="xs:string"><xsl:value-of select="$granularity"/></granularity>
  308. </xsl:if>
  309. </value>
  310. </item>
  311. </xsl:when>
  312. <!-- consistency check -->
  313. <xsl:otherwise>
  314. <!-- contentTask search path array -->
  315. <xsl:if test="$env/param[@name='cto_consistency_check']='internalRef'">
  316. </xsl:if>
  317. <xsl:if test="$env/param[starts-with(@name,'m_namespace_')]">
  318. <xsl:call-template name="buildOptionArray">
  319. <xsl:with-param name="type" select="'contentTaskProperties'"/>
  320. <xsl:with-param name="name" select="'securityReferencesContext'"/>
  321. </xsl:call-template>
  322. </xsl:if>
  323. </xsl:otherwise>
  324. </xsl:choose>
  325. </xsl:if>
  326. <xsl:if test="(/root/optionType='indexOptions')">
  327. <xsl:call-template name="buildOptionArray">
  328. <xsl:with-param name="type" select="'indexOptions'"/>
  329. <xsl:with-param name="name" select="'includedObjects'"/>
  330. </xsl:call-template>
  331. <xsl:call-template name="buildOptionArray">
  332. <xsl:with-param name="type" select="'indexOptions'"/>
  333. <xsl:with-param name="name" select="'excludedObjects'"/>
  334. </xsl:call-template>
  335. </xsl:if>
  336. <xsl:if test="(/root/optionType='contentTaskOptions')">
  337. <xsl:call-template name="buildOptionArray">
  338. <xsl:with-param name="type" select="'contentTaskOptions'"/>
  339. <xsl:with-param name="name" select="'cleanupContentContext'"/>
  340. </xsl:call-template>
  341. <xsl:call-template name="buildRetentionRuleArray">
  342. <xsl:with-param name="type" select="'contentTaskOptions'"/>
  343. <xsl:with-param name="name" select="'cleanupContentRetentionRules'"/>
  344. </xsl:call-template>
  345. </xsl:if>
  346. <xsl:if test="(/root/optionType='deploymentOptions')">
  347. <xsl:call-template name="buildOptionArray">
  348. <xsl:with-param name="type" select="'deploymentOptions'"/>
  349. <xsl:with-param name="name" select="'upgradeClasses'"/>
  350. <xsl:with-param name="allowEmptyArrays" select="'true'"/>
  351. </xsl:call-template>
  352. </xsl:if>
  353. </xsl:template>
  354. <!-- builds a standard options array -->
  355. <xsl:template name="buildOptionArray">
  356. <xsl:param name="type"/>
  357. <xsl:param name="name"/>
  358. <xsl:param name="allowEmptyArrays" select="'false'"/>
  359. <!-- All the required information about the option can be found in the option list (from options.xml) -->
  360. <xsl:variable name="optionDef" select="key('options', concat($type, '-', $name))"/>
  361. <xsl:variable name="itemType" select="$optionDef/@optionType"/>
  362. <xsl:variable name="nameType">
  363. <xsl:choose>
  364. <xsl:when test="$optionDef/@nameType!=''"><xsl:value-of select="$optionDef/@nameType"/></xsl:when>
  365. <xsl:otherwise><xsl:value-of select="$optionDef/parent::*/@nameType"/></xsl:otherwise>
  366. </xsl:choose>
  367. </xsl:variable>
  368. <xsl:variable name="valueType" select="$optionDef/@type"/>
  369. <xsl:variable name="envName" select="$optionDef/@envName"/>
  370. <xsl:if test="($envName !='') and ($allowEmptyArrays='true' or ($env/*[starts-with(@name, $envName) and string(.) !='']))">
  371. <item xsi:type="{$itemType}">
  372. <name xsi:type="{$nameType}"><xsl:value-of select="$name"/></name>
  373. <value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="{$valueType}[{ count( $env/*[starts-with(@name, $envName) and string(.) != ''] ) }]">
  374. <xsl:for-each select="$env/*[starts-with(@name, $envName) and string(.) !='']">
  375. <item xsi:type="{$valueType}"><xsl:value-of select="."/></item>
  376. </xsl:for-each>
  377. </value>
  378. </item>
  379. </xsl:if>
  380. </xsl:template>
  381. <!-- builds a retention rule array -->
  382. <xsl:template name="buildRetentionRuleArray">
  383. <xsl:param name="type"/>
  384. <xsl:param name="name"/>
  385. <!-- All the required information about the option can be found in the option list (from options.xml) -->
  386. <xsl:variable name="optionDef" select="key('options', concat($type, '-', $name))"/>
  387. <xsl:variable name="itemType" select="$optionDef/@optionType"/>
  388. <xsl:variable name="nameType">
  389. <xsl:choose>
  390. <xsl:when test="$optionDef/@nameType!=''"><xsl:value-of select="$optionDef/@nameType"/></xsl:when>
  391. <xsl:otherwise><xsl:value-of select="$optionDef/parent::*/@nameType"/></xsl:otherwise>
  392. </xsl:choose>
  393. </xsl:variable>
  394. <xsl:variable name="valueType" select="$optionDef/@type"/>
  395. <xsl:variable name="envName" select="$optionDef/@envName"/>
  396. <xsl:if test="($envName !='') and ($env/*[starts-with(@name, $envName) and string(.) !=''])">
  397. <item xsi:type="{$itemType}">
  398. <name xsi:type="{$nameType}"><xsl:value-of select="$name"/></name>
  399. <value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:retentionRule[{count($env/*[starts-with(@name, $envName) and string(.) !=''])}]">
  400. <xsl:for-each select="$env/*[starts-with(@name, $envName) and string(.) !='']">
  401. <xsl:variable name="className" select="substring-after(@name, $envName)"/>
  402. <xsl:variable name="maxObjects" select="string($env/*[@name=concat('cto_maxNumber_',$className)])"/>
  403. <xsl:variable name="durationValue" select="string($env/*[@name=concat('cto_duration_',$className)])"/>
  404. <xsl:variable name="durationUnits" select="string($env/*[@name=concat('cto_durationSelect_',$className)])"/>
  405. <xsl:variable name="maxDuration">
  406. <xsl:choose>
  407. <xsl:when test="$durationUnits='seconds'">
  408. <xsl:value-of select="concat('PT',$durationValue,'S')"/>
  409. </xsl:when>
  410. <xsl:when test="$durationUnits='minutes'">
  411. <xsl:value-of select="concat('PT',$durationValue,'M')"/>
  412. </xsl:when>
  413. <xsl:when test="$durationUnits='hours'">
  414. <xsl:value-of select="concat('PT',$durationValue,'H')"/>
  415. </xsl:when>
  416. <xsl:when test="$durationUnits='days'">
  417. <xsl:value-of select="concat('P',$durationValue,'D')"/>
  418. </xsl:when>
  419. <xsl:when test="$durationUnits='months'">
  420. <xsl:value-of select="concat('P',$durationValue,'M')"/>
  421. </xsl:when>
  422. <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
  423. </xsl:choose>
  424. </xsl:variable>
  425. <item xsi:type="bus:retentionRule">
  426. <objectClass xsi:type="bus:classEnum"><xsl:value-of select="$className"/></objectClass>
  427. <prop xsi:type="bus:propEnum">creationTime</prop>
  428. <xsl:choose>
  429. <xsl:when test="$maxObjects != ''">
  430. <maxObjects xsi:type="xsd:integer"><xsl:value-of select="$maxObjects"/></maxObjects>
  431. </xsl:when>
  432. <xsl:otherwise>
  433. <maxObjects xsi:type="xsd:integer">0</maxObjects>
  434. </xsl:otherwise>
  435. </xsl:choose>
  436. <xsl:choose>
  437. <xsl:when test="$maxDuration != ''">
  438. <maxDuration xsi:type="xsd:string"><xsl:value-of select="$maxDuration"/></maxDuration>
  439. </xsl:when>
  440. <xsl:otherwise>
  441. <maxDuration xsi:type="xsd:string"><xsl:value-of select="''"/></maxDuration>
  442. </xsl:otherwise>
  443. </xsl:choose>
  444. </item>
  445. </xsl:for-each>
  446. </value>
  447. </item>
  448. </xsl:if>
  449. </xsl:template>
  450. </xsl:stylesheet>