selectionContextRenderer.xsl 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. *****************************************************************
  4. ** Licensed Materials - Property of IBM
  5. **
  6. ** IBM Cognos Products: drill
  7. **
  8. ** (C) Copyright IBM Corp. 2001, 2019
  9. **
  10. ** US Government Users Restricted Rights - Use, duplication or
  11. ** disclosure restricted by GSA ADP Schedule Contract with
  12. ** IBM Corp.
  13. *****************************************************************
  14. -->
  15. <!--
  16. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  17. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  18. -->
  19. <xsl:stylesheet version="1.0"
  20. xmlns:s="http://developer.cognos.com/schemas/selection/1/"
  21. xmlns:out="dummy-uri"
  22. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  23. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  24. exclude-result-prefixes="xsl">
  25. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  26. <xsl:output method="xml" indent="no" encoding="utf-8"/>
  27. <xsl:template match="s:selectionContextRenderer">
  28. <!-- This statement provides keyed access to elements in the selection context by xml:id -->
  29. <out:key
  30. name="key_elementByID"
  31. match="*"
  32. use="@xml:id"/>
  33. <!-- This is for all drill scenario except powerplay -->
  34. <out:template name="selectionContextRenderer">
  35. <out:apply-templates select="/root/selectionContextNodeTree/s:selection/s:cells"/>
  36. </out:template>
  37. <!-- This is for powerplay drill scenario -->
  38. <out:template name="selectionContextRenderer_powerplay">
  39. <out:apply-templates select="/root/selectionContextNodeTree/Response/ConverterOutput/olap/s:selection/s:cells"/>
  40. </out:template>
  41. <out:template match="s:cells">
  42. <out:apply-templates select="s:cell"/>
  43. </out:template>
  44. <out:template match="s:cell">
  45. <!-- need to double-indirect from cell to string table for references in a cell's metadata cell entry -->
  46. <!-- eg: to get the name of a cell: -->
  47. <!-- 1) find the cell's metadata entry: (s:cell rMetadataCell="M_#") -->
  48. <!-- 2) find the metadata cell's rName entry: (s:metadataCell rName="N_#"). -->
  49. <!-- (The value will be the final s:s cell's contents) -->
  50. <out:variable name="metadataCell"
  51. select="key( 'key_elementByID', @rMetadataCell )"/>
  52. <out:variable name="metadataCellName"
  53. select="key( 'key_elementByID', $metadataCell/@rName )"/>
  54. <out:variable name="cellValue"
  55. select="key( 'key_elementByID', @rValue )"/>
  56. <out:variable name="metadataCellType"
  57. select="key( 'key_elementByID', $metadataCell/@rType )"/>
  58. <out:variable name="metadataCellExpression"
  59. select="key( 'key_elementByID', $metadataCell/@rExpression )"/>
  60. <!-- WO2788: The display value (memberCaption) is now stored as a dependent cell of the main cell whose rType is '_memberCaption' (in the string table via the metadata cell). -->
  61. <out:variable name="memberCaptionDependentCellValue">
  62. <out:for-each select="./*[local-name() = 'dependentCells']/*[local-name()='cell']">
  63. <!-- get the metadata cell that corresponds to the current dependent cell -->
  64. <out:variable name="dependentCell_metadataCell" select="key( 'key_elementByID', @rMetadataCell )"/>
  65. <!-- if the type value for this associated metadataCell is "_memberCaption", set the value of the variable -->
  66. <out:if test="key( 'key_elementByID', $dependentCell_metadataCell/@rType) = '_memberCaption'">
  67. <out:value-of select="key( 'key_elementByID', @rValue )" />
  68. </out:if>
  69. </out:for-each>
  70. </out:variable>
  71. <out:variable name="displayValue"
  72. select="$memberCaptionDependentCellValue"/>
  73. <tr>
  74. <!-- render Name, displayValue, Use Value -->
  75. <out:call-template name="DoValue">
  76. <out:with-param name="title" select="'Name'"/>
  77. <out:with-param name="value" select="$metadataCellName"/>
  78. <out:with-param name="headerId">itemName</out:with-param>
  79. </out:call-template>
  80. <out:call-template name="DoValue">
  81. <out:with-param name="title" select="'displayValue'"/>
  82. <out:with-param name="value" select="$displayValue"/>
  83. <out:with-param name="headerId">itemDisplayValue</out:with-param>
  84. </out:call-template>
  85. <out:call-template name="DoValue">
  86. <out:with-param name="title" select="'Use Value'"/>
  87. <out:with-param name="value" select="$cellValue"/>
  88. <out:with-param name="headerId">itemUseValue</out:with-param>
  89. </out:call-template>
  90. <!-- TODO:
  91. Types and Expressions are easy extensions,
  92. After that, the next step would be defining/dependent cells to show more structure....
  93. <out:variable name="isDependentCell">
  94. <out:choose>
  95. <out:when test="parent::s:cells">independent</out:when>
  96. <out:otherwise>dependent</out:otherwise>
  97. </out:choose>
  98. </out:variable>
  99. <out:call-template name="DoValue">
  100. <out:with-param name="title" select="'Type'"/>
  101. <out:with-param name="value" select="$metadataCellType"/>
  102. </out:call-template>
  103. <out:call-template name="DoValue">
  104. <out:with-param name="title" select="'Expression'"/>
  105. <out:with-param name="value" select="$metadataCellExpression"/>
  106. </out:call-template>
  107. <out:apply-templates select="s:definingCells"/>
  108. <out:apply-templates select="s:dependentCells/s:cell"/
  109. -->
  110. </tr>
  111. </out:template>
  112. <!-- produce a single value as a formatted table column -->
  113. <out:template name="DoValue">
  114. <out:param name="value"/>
  115. <out:param name="headerId"/>
  116. <td valign="top" nowrap="" height="10" class="tabletext">
  117. <out:attribute name="headers"><out:value-of select="$headerId"/></out:attribute>
  118. <out:value-of select="xtsext:enforceBTD($value, $baseTextDirection, $productLocale, boolean($isBidiEnabled='true'))"/>
  119. </td>
  120. </out:template>
  121. </xsl:template>
  122. <!-- the main engine -->
  123. <xsl:template match="*">
  124. <xsl:copy>
  125. <xsl:copy-of select="@*"/>
  126. <xsl:apply-templates/>
  127. </xsl:copy>
  128. </xsl:template>
  129. </xsl:stylesheet>