getChartUrl.xslt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cogadmin
  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. <!--
  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. This is a temp transform until uiExtentions gets moved to tier 3 and we can do all of this a compile time
  14. -->
  15. <xsl:stylesheet version="1.0"
  16. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  17. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  18. exclude-result-prefixes="xsl xtsext">
  19. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  20. <xsl:template match="/root/barChart">
  21. <xsl:variable name="type" select="type"/>
  22. <xsl:variable name="yTitle" select="xtsext:javascriptencode(yTitle)"/>
  23. <xsl:variable name="xTitle" select="xtsext:javascriptencode(xTitle)"/>
  24. <xsl:variable name="titles">
  25. <xsl:value-of select="concat('&quot;titles&quot;:{&quot;xTitle&quot;:&quot;',$xTitle,'&quot;,&quot;yTitle&quot;:&quot;',$yTitle,'&quot;}')"/>
  26. </xsl:variable>
  27. <xsl:variable name="rows">
  28. <xsl:value-of select="'&quot;rows&quot;:['"/>
  29. <xsl:for-each select="row">
  30. <xsl:variable name="label"><xsl:value-of select="xtsext:javascriptencode(string(label))"/></xsl:variable>
  31. <xsl:variable name="value"><xsl:value-of select="value"/></xsl:variable>
  32. <xsl:value-of select="concat('{&quot;label&quot;:&quot;',$label,'&quot;,&quot;value&quot;:&quot;',$value,'&quot;}')"/>
  33. <xsl:if test="position()!=last()"><xsl:value-of select="','"/></xsl:if>
  34. </xsl:for-each>
  35. <xsl:value-of select="']'"/>
  36. </xsl:variable>
  37. <xsl:variable name="data">
  38. <xsl:value-of select="concat('{&quot;type&quot;:&quot;',$type,'&quot;,',$titles,',',$rows,'}')"/>
  39. </xsl:variable>
  40. <!--cusomized variables for different chart viewer-->
  41. <xsl:variable name="source" select="xtsext:urlencode($data)"/>
  42. <!--the final output url-->
  43. <cogadminChartUrl>
  44. <xsl:value-of select="concat('/simplechartviewer?source=',$source)"/>
  45. </cogadminChartUrl>
  46. </xsl:template>
  47. </xsl:stylesheet>