ppchartrans.xsl 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: CCS
  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="http://www.ibm.com/xmlns/prod/cognos/layoutData/200904" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rds="http://developer.cognos.com/schemas/rds/types/2">
  9. <xsl:param name="gateway"/>
  10. <xsl:param name="cogGateway" select="'http://localhost/cognos8/cgi-bin/cognos.cgi'"/>
  11. <xsl:param name="transformData" select="'true'"/>
  12. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
  13. <xsl:template match="/">
  14. <xsl:choose>
  15. <xsl:when test="data/tab/crosstab/datarow/col[@src]">
  16. <xsl:choose>
  17. <xsl:when test="$transformData = 'true'">
  18. <page>
  19. <id>c4</id>
  20. <body>
  21. <xsl:apply-templates select="data/tab/crosstab/datarow"/>
  22. </body>
  23. </page>
  24. </xsl:when>
  25. <xsl:otherwise>
  26. <rds:page>
  27. <id>c4</id>
  28. <rds:posId>P2</rds:posId>
  29. <rds:body>
  30. <rds:item>
  31. <rds:posId>P2B1TR1TC1IT1</rds:posId>
  32. <rds:conditional>false</rds:conditional>
  33. <rds:MChart>
  34. <id>
  35. <xsl:value-of select="concat('c',position())"/>
  36. </id>
  37. </rds:MChart>
  38. </rds:item>
  39. <xsl:if test="data/tab/crosstab/datarow/col/area[@icon or @color or @backicon]">
  40. <rds:item>
  41. <rds:posId>P2B1TR1TC2IT1</rds:posId>
  42. <rds:conditional>false</rds:conditional>
  43. <rds:MListFrame>
  44. <id>
  45. <xsl:value-of select="concat('cl',position())"/>
  46. </id>
  47. </rds:MListFrame>
  48. </rds:item>
  49. </xsl:if>
  50. </rds:body>
  51. </rds:page>
  52. </xsl:otherwise>
  53. </xsl:choose>
  54. </xsl:when>
  55. <xsl:otherwise>
  56. <noData/>
  57. </xsl:otherwise>
  58. </xsl:choose>
  59. </xsl:template>
  60. <xsl:template match="datarow">
  61. <xsl:if test="col/@src">
  62. <item>
  63. <cht>
  64. <id>
  65. <xsl:value-of select="concat('c',position())"/>
  66. </id>
  67. <url>
  68. <xsl:value-of select="concat($gateway,col/@src)"/>
  69. </url>
  70. </cht>
  71. </item>
  72. </xsl:if>
  73. <xsl:if test="col/area[@icon or @color or @gradicon or @backicon]">
  74. <!--This generates the legend (if applicable)-->
  75. <item>
  76. <lst>
  77. <id>
  78. <xsl:value-of select="concat('cl', position())"/>
  79. </id>
  80. <colTitle>
  81. <style>td</style>
  82. <!--This is a blank placeholder cell-->
  83. <item>
  84. <txt>
  85. <val/>
  86. <valTyp>text</valTyp>
  87. <exclPatrn>General</exclPatrn>
  88. </txt>
  89. </item>
  90. </colTitle>
  91. <colTitle>
  92. <style>td</style>
  93. <style>legendtitle</style>
  94. <item>
  95. <txt>
  96. <style>td</style>
  97. <style>legendtitle</style>
  98. <val>
  99. <!-- if its a col-based chart - i.e. pie - get title there, otherwise from datarow -->
  100. <xsl:choose>
  101. <xsl:when test="col/@description = 'Pie' ">
  102. <xsl:value-of select="col/@text"/>
  103. </xsl:when>
  104. <xsl:otherwise>
  105. <xsl:value-of select="./@text"/>
  106. </xsl:otherwise>
  107. </xsl:choose>
  108. </val>
  109. <valTyp>text</valTyp>
  110. <exclPatrn>General</exclPatrn>
  111. </txt>
  112. </item>
  113. </colTitle>
  114. <xsl:if test="col/area[@value]">
  115. <colTitle>
  116. <style>td</style>
  117. <style>legendtitle</style>
  118. <item>
  119. <txt>
  120. <style>legendtitle</style>
  121. <val>
  122. <xsl:value-of select="../measure/@name"/>
  123. </val>
  124. <valTyp>text</valTyp>
  125. <exclPatrn>General</exclPatrn>
  126. </txt>
  127. </item>
  128. </colTitle>
  129. </xsl:if>
  130. <group>
  131. <xsl:apply-templates select="col/area"/>
  132. <depth>1</depth>
  133. </group>
  134. </lst>
  135. </item>
  136. </xsl:if>
  137. </xsl:template>
  138. <xsl:template match="area[@icon or @color or @gradicon or @backicon]">
  139. <row>
  140. <cell>
  141. <style>td</style>
  142. <item>
  143. <img>
  144. <xsl:choose>
  145. <xsl:when test="@icon">
  146. <xsl:choose>
  147. <xsl:when test="@color">
  148. <url>
  149. <xsl:value-of select="concat($gateway,'/../../ppwb/Icon/',@icon,'.gif&amp;ccs_color=FF', @color)"/>
  150. </url>
  151. </xsl:when>
  152. <xsl:otherwise>
  153. <url>
  154. <xsl:value-of select="concat($gateway,'/../../ppwb/Icon/',@icon,'.gif')"/>
  155. </url>
  156. </xsl:otherwise>
  157. </xsl:choose>
  158. </xsl:when>
  159. <xsl:when test="@gradicon">
  160. <url>
  161. <xsl:value-of select="concat($gateway,@gradicon)"/>
  162. </url>
  163. </xsl:when>
  164. <xsl:when test="@backicon">
  165. <url>
  166. <xsl:value-of select="concat($gateway,@backicon)"/>
  167. </url>
  168. </xsl:when>
  169. <xsl:otherwise>
  170. <url>
  171. <xsl:value-of select="concat('color://FF', @color)"/>
  172. <!--Return value as an ARGB hex value-->
  173. </url>
  174. </xsl:otherwise>
  175. </xsl:choose>
  176. </img>
  177. </item>
  178. </cell>
  179. <cell>
  180. <style>td</style>
  181. <style>legendcell</style>
  182. <item>
  183. <txt>
  184. <style>legendcell</style>
  185. <val>
  186. <xsl:value-of select="@name"/>
  187. </val>
  188. <valTyp>text</valTyp>
  189. <exclPatrn>General</exclPatrn>
  190. </txt>
  191. </item>
  192. </cell>
  193. <xsl:if test="@value">
  194. <cell>
  195. <style>td</style>
  196. <style>legendcell</style>
  197. <item>
  198. <txt>
  199. <style>legendcell</style>
  200. <val>
  201. <xsl:value-of select="@value"/>
  202. </val>
  203. <valTyp>text</valTyp>
  204. <exclPatrn>General</exclPatrn>
  205. </txt>
  206. </item>
  207. </cell>
  208. </xsl:if>
  209. </row>
  210. </xsl:template>
  211. </xsl:stylesheet>