mergeReportOptions.xslt 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. <!--
  13. Transform to merge the report execution option with the options array. This should go away once the report
  14. options are deprecated.
  15. -->
  16. <xsl:stylesheet version="1.0"
  17. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  18. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  19. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  20. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  21. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  22. exclude-result-prefixes="cm xsl bus xsi SOAP-ENC">
  23. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  24. <xsl:template match="/root/*" priority="1">
  25. <options xmlns="" xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:option[]">
  26. <value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:option[]">
  27. <!-- copy all the options that do not require special handling -->
  28. <xsl:copy-of select="*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and not (contains(' selectionBasedFeatures prompt outputFormat outputLocale outputPageOrientation outputPageDefinition allowAnnotations ', concat(' ', *[local-name()='name'], ' ')))]"/>
  29. <!-- special handling for the other options -->
  30. <!-- format -->
  31. <xsl:choose>
  32. <xsl:when test="cm:executionFormat != ''">
  33. <item xsi:type="cm:runOptionStringArray">
  34. <name xsi:type="cm:runOptionEnum">outputFormat</name>
  35. <value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[1]">
  36. <item xsi:type="xsd:string"><xsl:value-of select="cm:executionFormat"/></item>
  37. </value>
  38. </item>
  39. </xsl:when>
  40. <xsl:otherwise>
  41. <xsl:copy-of select="*[local-name() = 'options']/*[local-name() = 'value']/*[local-name() = 'item' and ./*[local-name() = 'name' and . = 'outputFormat']]"/>
  42. </xsl:otherwise>
  43. </xsl:choose>
  44. <!-- language -->
  45. <xsl:choose>
  46. <xsl:when test="cm:executionLocale != ''">
  47. <item xsi:type="cm:runOptionStringArray">
  48. <name xsi:type="cm:runOptionEnum">outputLocale</name>
  49. <value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[1]">
  50. <item xsi:type="xsd:string"><xsl:value-of select="cm:executionLocale"/></item>
  51. </value>
  52. </item>
  53. </xsl:when>
  54. <xsl:otherwise>
  55. <xsl:copy-of select="*[local-name() = 'options']/*[local-name() = 'value']/*[local-name() = 'item' and ./*[local-name() = 'name' and . = 'outputLocale']]"/>
  56. </xsl:otherwise>
  57. </xsl:choose>
  58. <!-- page orientation -->
  59. <xsl:choose>
  60. <xsl:when test="cm:executionPageOrientation != ''">
  61. <item xsi:type="bus:runOptionString">
  62. <name xsi:type="bus:runOptionEnum">outputPageOrientation</name>
  63. <value xsi:type="xsd:string"><xsl:value-of select="cm:executionPageOrientation"/></value>
  64. </item>
  65. </xsl:when>
  66. <xsl:otherwise>
  67. <xsl:copy-of select="*[local-name() = 'options']/*[local-name() = 'value']/*[local-name() = 'item' and ./*[local-name() = 'name' and . = 'outputPageOrientation']]"/>
  68. </xsl:otherwise>
  69. </xsl:choose>
  70. <!-- selectionBasedFeatures -->
  71. <xsl:choose>
  72. <xsl:when test="*[local-name() = 'options']/*[local-name() = 'value']/*[local-name() = 'item' and ./*[local-name() = 'name' and . = 'selectionBasedFeatures']] != ''">
  73. <xsl:copy-of select="*[local-name() = 'options']/*[local-name() = 'value']/*[local-name() = 'item' and ./*[local-name() = 'name' and . = 'selectionBasedFeatures']]"/>
  74. </xsl:when>
  75. <xsl:otherwise>
  76. <item xsi:type="bus:runOptionBoolean">
  77. <name xsi:type="bus:runOptionEnum">selectionBasedFeatures</name>
  78. <value xsi:type="xsd:boolean">true</value>
  79. </item>
  80. </xsl:otherwise>
  81. </xsl:choose>
  82. <!-- allowAnnotations -->
  83. <xsl:choose>
  84. <xsl:when test="*[local-name() = 'options']/*[local-name() = 'value']/*[local-name() = 'item' and ./*[local-name() = 'name' and . = 'allowAnnotations']] != ''">
  85. <xsl:copy-of select="*[local-name() = 'options']/*[local-name() = 'value']/*[local-name() = 'item' and ./*[local-name() = 'name' and . = 'allowAnnotations']]"/>
  86. </xsl:when>
  87. <xsl:otherwise>
  88. <item xsi:type="bus:runOptionBoolean">
  89. <name xsi:type="bus:runOptionEnum">allowAnnotations</name>
  90. <value xsi:type="xsd:boolean">false</value>
  91. </item>
  92. </xsl:otherwise>
  93. </xsl:choose>
  94. <!-- writeCompleteHistory -->
  95. <xsl:choose>
  96. <xsl:when test="*[local-name() = 'options']/*[local-name() = 'value']/*[local-name() = 'item' and ./*[local-name() = 'name' and . = 'writeCompleteHistory']] != ''">
  97. <xsl:copy-of select="*[local-name() = 'options']/*[local-name() = 'value']/*[local-name() = 'item' and ./*[local-name() = 'name' and . = 'writeCompleteHistory']]"/>
  98. </xsl:when>
  99. <xsl:otherwise>
  100. <item xsi:type="bus:monitorOptionBoolean">
  101. <name xsi:type="bus:monitorOptionEnum">writeCompleteHistory</name>
  102. <value xsi:type="xsd:boolean">true</value>
  103. </item>
  104. </xsl:otherwise>
  105. </xsl:choose>
  106. <!-- paper size -->
  107. <xsl:choose>
  108. <xsl:when test="cm:executionPageDefinition/cm:pageDefinition/cm:searchPath != ''">
  109. <item xsi:type="bus:runOptionString">
  110. <name xsi:type="bus:runOptionEnum">outputPageDefinition</name>
  111. <value xsi:type="xsd:string"><xsl:value-of select="cm:executionPageDefinition/cm:pageDefinition/cm:searchPath"/></value>
  112. </item>
  113. </xsl:when>
  114. <xsl:otherwise>
  115. <xsl:copy-of select="*[local-name() = 'options']/*[local-name() = 'value']/*[local-name() = 'item' and ./*[local-name() = 'name' and . = 'outputPageDefinition']]"/>
  116. </xsl:otherwise>
  117. </xsl:choose>
  118. <!-- prompt -->
  119. <xsl:choose>
  120. <xsl:when test="cm:executionPrompt != ''">
  121. <item xsi:type="cm:runOptionBoolean">
  122. <name xsi:type="cm:runOptionEnum">prompt</name>
  123. <value xsi:type="xsd:boolean"><xsl:value-of select="cm:executionPrompt"/></value>
  124. </item>
  125. </xsl:when>
  126. <xsl:otherwise>
  127. <xsl:copy-of select="*[local-name() = 'options']/*[local-name() = 'value']/*[local-name() = 'item' and ./*[local-name() = 'name' and . = 'prompt']]"/>
  128. </xsl:otherwise>
  129. </xsl:choose>
  130. </value>
  131. </options>
  132. </xsl:template>
  133. </xsl:stylesheet>