selectValue.xslt 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rsext="xalan://com.cognos.reportserver.ext.RSExt">
  9. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  10. <xsl:include href="V5html.xsl"/>
  11. <!-- we're actually generating XML in here now of the following format - we only generate the use attribute on the value element if the use
  12. and the display differ
  13. <values>
  14. <value use="a" display="a1"/>
  15. <value use="b" display="b1"/>
  16. <value use="c" display="c1"/>
  17. </values>
  18. <type>45</type> -->
  19. <xsl:template match="/">
  20. <xsl:choose>
  21. <!-- cannot test to see if there is a //DRI[@type='datavalue']/OTI[@layoutClass='textItem'] cause in the instance where there
  22. isn't a value returned we'll end up converting a null table into a HTML page - which is incorrect. Check for a table header -->
  23. <xsl:when test="//DRI[@type='columnTitle']">
  24. <xsl:call-template name="selectValues"/>
  25. </xsl:when>
  26. <xsl:otherwise>
  27. <xsl:call-template name="prompt"/>
  28. </xsl:otherwise>
  29. </xsl:choose>
  30. </xsl:template>
  31. <xsl:template name="selectValues">
  32. <values>
  33. <xsl:for-each select="//DRI[@type='datavalue']/OTI[@layoutClass='textItem']">
  34. <xsl:if test="not(contains(@style,'visibility:hidden'))">
  35. <xsl:variable name="ctx" select="./@ctx"/>
  36. <!-- get the use and display values -->
  37. <xsl:variable name="useValue" select="//CD[@ctxId = $ctx]/@useValue"/>
  38. <xsl:variable name="displayValue" select="./text()"/>
  39. <value>
  40. <xsl:attribute name="display"><xsl:value-of select="$displayValue"/></xsl:attribute>
  41. <!-- only send the use value if it's different to the display value -->
  42. <xsl:if test="not($displayValue = $useValue)">
  43. <xsl:attribute name="use"><xsl:value-of select="$useValue"/></xsl:attribute>
  44. </xsl:if>
  45. </value>
  46. </xsl:if>
  47. </xsl:for-each>
  48. </values>
  49. <type>
  50. <xsl:value-of select="/Document/META-DATA/DA/@dtype"/>
  51. </type>
  52. </xsl:template>
  53. <xsl:template name="prompt">
  54. <xsl:apply-templates/>
  55. </xsl:template>
  56. </xsl:stylesheet>