disassembleSelectionSpec.xslt 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ASV
  5. (C) Copyright IBM Corp. 2005, 2010
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" exclude-result-prefixes="bus pf xtsext">
  9. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  10. <xsl:template match="/">
  11. <!-- build the value of the measure -->
  12. <xsl:choose>
  13. <xsl:when test="/selection/type">
  14. <param name="m_sub_type">
  15. <xsl:value-of select="/selection/type"/>
  16. </param>
  17. </xsl:when>
  18. <xsl:otherwise>
  19. <param name="m_sub_type">
  20. <xsl:text>nonMetric</xsl:text>
  21. </param>
  22. </xsl:otherwise>
  23. </xsl:choose>
  24. <xsl:if test="/selection/measure_value">
  25. <param name="m_sub_measure_value">
  26. <xsl:value-of select="/selection/measure_value"/>
  27. </param>
  28. </xsl:if>
  29. <!-- build the other variables - for between if they are there -->
  30. <xsl:if test="/selection/measure_value1">
  31. <param name="m_sub_measure_value1">
  32. <xsl:value-of select="/selection/measure_value1"/>
  33. </param>
  34. </xsl:if>
  35. <xsl:if test="/selection/measure_value_inclusive">
  36. <param name="m_sub_measure_value_inclusive">
  37. <xsl:value-of select="/selection/measure_value_inclusive"/>
  38. </param>
  39. </xsl:if>
  40. <xsl:if test="/selection/measure_value_inclusive1">
  41. <param name="m_sub_measure_value_inclusive1">
  42. <xsl:value-of select="/selection/measure_value_inclusive1"/>
  43. </param>
  44. </xsl:if>
  45. <xsl:if test="/selection/case_insensitive">
  46. <param name="m_sub_case_insensitive">
  47. <xsl:value-of select="/selection/case_insensitive"/>
  48. </param>
  49. </xsl:if>
  50. <!-- build the name of the operation -->
  51. <xsl:if test="/selection/operation">
  52. <param name="m_sub_operation">
  53. <xsl:value-of select="/selection/operation"/>
  54. </param>
  55. </xsl:if>
  56. <!-- copy over all the metric values -->
  57. <xsl:for-each select="/selection/*[starts-with(local-name(),'perfPattern')]">
  58. <param name="{concat('m_sub_', local-name())}">
  59. <xsl:value-of select="."/>
  60. </param>
  61. </xsl:for-each>
  62. <!-- select the type of the data -->
  63. <xsl:variable name="dtype">
  64. <xsl:value-of select="/selection/selections/query/selection/measures/measure/@dtype"/>
  65. </xsl:variable>
  66. <xsl:variable name="usage">
  67. <xsl:value-of select="/selection/selections/query/selection/measures/measure/@usage"/>
  68. </xsl:variable>
  69. <param name="m_subData_dtype_domain">
  70. <xsl:choose>
  71. <!-- values taken from the CCLDBType enumeration -->
  72. <xsl:when test="$dtype='1' or $dtype='25' or $dtype='26' or $dtype='27' or $dtype='28' or $dtype='29' or $dtype='30' or $dtype='31' or $dtype='32' or $dtype='34' or $dtype='35' or $dtype='36' or $dtype='43' or $dtype='45' or dtype='55' or $dtype='56'">
  73. <xsl:choose>
  74. <xsl:when test="$usage='2'">
  75. <xsl:text>string</xsl:text>
  76. </xsl:when>
  77. <xsl:otherwise>
  78. <xsl:text>invalid</xsl:text>
  79. </xsl:otherwise>
  80. </xsl:choose>
  81. </xsl:when>
  82. <xsl:otherwise>
  83. <xsl:choose>
  84. <xsl:when test="$usage='2' or $usage='3'">
  85. <xsl:text>numeric</xsl:text>
  86. </xsl:when>
  87. <xsl:otherwise>
  88. <xsl:text>invalid</xsl:text>
  89. </xsl:otherwise>
  90. </xsl:choose>
  91. </xsl:otherwise>
  92. </xsl:choose>
  93. </param>
  94. <!-- build the name of the measure -->
  95. <param name="m_subData_measure_name">
  96. <xsl:value-of select="/selection/selections/query/selection/measures/measure/item/bus:name"/>
  97. </param>
  98. <xsl:for-each select="/selection/selections/query/selection/rows/row">
  99. <xsl:variable name="name" select="concat(string(local-name()), string(position()))"/>
  100. <xsl:apply-templates select="." mode="buildRowColumnSectionParams">
  101. <xsl:with-param name="name">
  102. <xsl:value-of select="$name"/>
  103. </xsl:with-param>
  104. </xsl:apply-templates>
  105. </xsl:for-each>
  106. <!-- build all the select values for all the columns -->
  107. <xsl:for-each select="/selection/selections/query/selection/columns/column">
  108. <xsl:variable name="name" select="concat(string(local-name()), string(position()))"/>
  109. <xsl:apply-templates select="." mode="buildRowColumnSectionParams">
  110. <xsl:with-param name="name">
  111. <xsl:value-of select="$name"/>
  112. </xsl:with-param>
  113. </xsl:apply-templates>
  114. </xsl:for-each>
  115. <!-- build all the select values for the sections -->
  116. <xsl:for-each select="/selection/selections/query/selection/sections/section">
  117. <xsl:variable name="name" select="concat(string(local-name()), string(position()))"/>
  118. <xsl:apply-templates select="." mode="buildRowColumnSectionParams">
  119. <xsl:with-param name="name">
  120. <xsl:value-of select="$name"/>
  121. </xsl:with-param>
  122. </xsl:apply-templates>
  123. </xsl:for-each>
  124. <!-- wrap the selection spec up too -->
  125. <xsl:variable name="markup">
  126. <xsl:call-template name="serialize-xml">
  127. <xsl:with-param name="node-set">
  128. <xsl:copy-of select="/selection"/>
  129. </xsl:with-param>
  130. </xsl:call-template>
  131. </xsl:variable>
  132. <param name="m_subData_report">
  133. <xsl:value-of select="$markup"/>
  134. </param>
  135. </xsl:template>
  136. <!-- template to build parameters for the row/column values -->
  137. <xsl:template match="*" mode="buildRowColumnSectionParams">
  138. <xsl:param name="name"/>
  139. <!-- build the name of the value this entry -->
  140. <param name="m_subData_name_{$name}">
  141. <xsl:value-of select="./item/bus:name"/>
  142. </param>
  143. <!-- build the default value of this entry -->
  144. <param name="m_subData_defaultValue_{$name}">
  145. <xsl:value-of select="./item/bus:value/item/bus:display"/>
  146. </param>
  147. <!-- build the current selection -->
  148. <xsl:if test="(./selectAll and ./selectAll='false') or not(./selectAll)">
  149. <param name="m_sub_{$name}">
  150. <xsl:text>true</xsl:text>
  151. </param>
  152. </xsl:if>
  153. </xsl:template>
  154. <!-- serialization templates -->
  155. <pf:serialize-xml/>
  156. </xsl:stylesheet>