charts_data.xsl 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ccs="http://developer.cognos.com/rds/1" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
  9. <xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" version="1.0"/>
  10. <xsl:param name="gateway" select="'http://localhost/cognos/cgi-bin/ppdscgi.exe'"/>
  11. <xsl:param name="crnGateway" select="'http://localhost/crn/cgi-bin/cognos.cgi'"/>
  12. <xsl:param name="transformData" select="'false'"/>
  13. <xsl:template match="/">
  14. <ccs:chartsInfo>
  15. <xsl:apply-templates select="data" mode="meta"/>
  16. <xsl:if test="$transformData = 'true'">
  17. <xsl:apply-templates select="data"/>
  18. </xsl:if>
  19. </ccs:chartsInfo>
  20. </xsl:template>
  21. <!--***********************************************************************************
  22. MetaData Templates
  23. **************************************************************************************-->
  24. <xsl:template match="data" mode="meta">
  25. <!--
  26. For PP, the foll. hard coded ids hold :
  27. id 1 : Top Report
  28. id 2 : Crosstab
  29. id 3 : Status line
  30. id 4: Page
  31. -->
  32. <xsl:if test="tab/crosstab/datarow/col/@src">
  33. <ccs:chartsMeta>
  34. <ccs:pages>
  35. <ccs:id>c4</ccs:id>
  36. <ccs:name/>
  37. <ccs:type>Page</ccs:type>
  38. <ccs:content>
  39. <ccs:page>
  40. <ccs:headerElements/>
  41. <xsl:apply-templates select="tab/crosstab/datarow" mode="meta"/>
  42. <ccs:footerElements>
  43. </ccs:footerElements>
  44. </ccs:page>
  45. </ccs:content>
  46. </ccs:pages>
  47. </ccs:chartsMeta>
  48. </xsl:if>
  49. </xsl:template>
  50. <xsl:template match="tab/crosstab/datarow" mode="meta">
  51. <xsl:if test="col/@src">
  52. <ccs:bodyElements>
  53. <ccs:id>
  54. <xsl:value-of select="concat('c', position())"/>
  55. </ccs:id>
  56. <ccs:name>Chart</ccs:name>
  57. <ccs:type>Chart</ccs:type>
  58. <ccs:content>
  59. <ccs:chart>
  60. <ccs:hSize>0</ccs:hSize>
  61. <ccs:vSize>0</ccs:vSize>
  62. </ccs:chart>
  63. <ccs:style/>
  64. </ccs:content>
  65. </ccs:bodyElements>
  66. <xsl:if test="col/area[@icon or @color]">
  67. <ccs:bodyElements>
  68. <ccs:id>
  69. <xsl:value-of select="concat('cl', position())"/>
  70. </ccs:id>
  71. <ccs:name>Legend</ccs:name>
  72. <ccs:type>Table</ccs:type>
  73. <ccs:content>
  74. <ccs:table>
  75. <ccs:isCrossTab>false</ccs:isCrossTab>
  76. <ccs:moreRows>false</ccs:moreRows>
  77. <ccs:moreCols>false</ccs:moreCols>
  78. <ccs:measure/>
  79. <ccs:measureStyle/>
  80. <ccs:rows/>
  81. <ccs:columns>
  82. <ccs:isSummary>false</ccs:isSummary>
  83. <ccs:startPos>0</ccs:startPos>
  84. <ccs:name> </ccs:name>
  85. <ccs:size>1</ccs:size>
  86. <ccs:style/>
  87. <ccs:containedGroup/>
  88. </ccs:columns>
  89. <ccs:columns>
  90. <ccs:isSummary>false</ccs:isSummary>
  91. <ccs:startPos>1</ccs:startPos>
  92. <ccs:name> </ccs:name>
  93. <ccs:size>1</ccs:size>
  94. <ccs:style/>
  95. <ccs:containedGroup/>
  96. </ccs:columns>
  97. <xsl:if test="col/area[@value]">
  98. <ccs:columns>
  99. <ccs:isSummary>false</ccs:isSummary>
  100. <ccs:startPos>1</ccs:startPos>
  101. <ccs:name> </ccs:name>
  102. <ccs:size>1</ccs:size>
  103. <ccs:style/>
  104. <ccs:containedGroup/>
  105. </ccs:columns>
  106. </xsl:if>
  107. </ccs:table>
  108. </ccs:content>
  109. </ccs:bodyElements>
  110. </xsl:if>
  111. </xsl:if>
  112. </xsl:template>
  113. <!--************************************************************************************************************
  114. Data Templates
  115. ************************************************************************************************************-->
  116. <xsl:template match="data">
  117. <!--
  118. For PP, the foll. hard coded ids hold :
  119. id 1 : Top Report
  120. id 2 : Chart
  121. id 3 : Status line
  122. id 4: Page
  123. id 5: Legend for chart
  124. -->
  125. <xsl:if test="tab/crosstab/datarow/col/@src">
  126. <ccs:chartsData>
  127. <ccs:pages>
  128. <ccs:id>c4</ccs:id>
  129. <ccs:name/>
  130. <ccs:type>Page</ccs:type>
  131. <ccs:content>
  132. <ccs:page>
  133. <ccs:headerElement/>
  134. <!-- check for simplied - i.e. unnested - chart case -->
  135. <xsl:apply-templates select="tab/crosstab/datarow"/>
  136. <ccs:footerElements>
  137. <xsl:choose>
  138. <xsl:when test="normalize-space(tab/status_line/@status)">
  139. <ccs:id>c3</ccs:id>
  140. <ccs:name>statusLine</ccs:name>
  141. <ccs:type>TextFrame</ccs:type>
  142. <ccs:content>
  143. <ccs:textFrame>
  144. <ccs:value>
  145. <xsl:value-of select="tab/status_line/@status"/>
  146. </ccs:value>
  147. <ccs:valueType>text</ccs:valueType>
  148. </ccs:textFrame>
  149. </ccs:content>
  150. </xsl:when>
  151. </xsl:choose>
  152. </ccs:footerElements>
  153. </ccs:page>
  154. </ccs:content>
  155. </ccs:pages>
  156. </ccs:chartsData>
  157. </xsl:if>
  158. </xsl:template>
  159. <xsl:template match="tab/crosstab/datarow">
  160. <xsl:if test="col/@src">
  161. <ccs:bodyElements>
  162. <ccs:id>
  163. <xsl:value-of select="concat('c', position())"/>
  164. </ccs:id>
  165. <ccs:name>Chart</ccs:name>
  166. <ccs:type>Chart</ccs:type>
  167. <ccs:content>
  168. <ccs:chart>
  169. <ccs:imageUrl>
  170. <xsl:value-of select="concat($gateway,'/../../..',col/@src)"/>
  171. </ccs:imageUrl>
  172. </ccs:chart>
  173. </ccs:content>
  174. </ccs:bodyElements>
  175. <xsl:if test="col/area[@icon or @color or @gradicon]">
  176. <ccs:bodyElements>
  177. <ccs:id>
  178. <xsl:value-of select="concat('cl', position())"/>
  179. </ccs:id>
  180. <ccs:name>Legend</ccs:name>
  181. <ccs:type>Table</ccs:type>
  182. <ccs:content>
  183. <ccs:table>
  184. <!-- first generate the title bar -->
  185. <ccs:row>
  186. <ccs:type>Header</ccs:type>
  187. <ccs:cells>
  188. <ccs:parts>
  189. <ccs:id/>
  190. <ccs:type>TextFrame</ccs:type>
  191. <ccs:content>
  192. <ccs:textFrame>
  193. <ccs:value> </ccs:value>
  194. <ccs:valueType>text</ccs:valueType>
  195. <dataFormat>
  196. <xsl:value-of select="General"/>
  197. </dataFormat>
  198. </ccs:textFrame>
  199. </ccs:content>
  200. </ccs:parts>
  201. </ccs:cells>
  202. <ccs:cells>
  203. <ccs:parts>
  204. <ccs:id/>
  205. <ccs:type>TextFrame</ccs:type>
  206. <ccs:content>
  207. <ccs:textFrame>
  208. <ccs:value>
  209. <!-- if its a col-based chart - i.e. pie - get title there, otherwise from datarow -->
  210. <xsl:choose>
  211. <xsl:when test="col/@description = 'Pie' ">
  212. <xsl:value-of select="col/@text"/>
  213. </xsl:when>
  214. <xsl:otherwise>
  215. <xsl:value-of select="./@text"/>
  216. </xsl:otherwise>
  217. </xsl:choose>
  218. </ccs:value>
  219. <ccs:valueType>text</ccs:valueType>
  220. <ccs:dataFormat>
  221. <xsl:value-of select="General"/>
  222. </ccs:dataFormat>
  223. </ccs:textFrame>
  224. </ccs:content>
  225. <ccs:style>legendtitle</ccs:style>
  226. </ccs:parts>
  227. </ccs:cells>
  228. <xsl:if test="col/area[@value]">
  229. <ccs:cells>
  230. <ccs:parts>
  231. <ccs:id/>
  232. <ccs:type>TextFrame</ccs:type>
  233. <ccs:content>
  234. <ccs:textFrame>
  235. <ccs:value>
  236. <xsl:value-of select="../measure/@name"/>
  237. </ccs:value>
  238. <ccs:valueType>text</ccs:valueType>
  239. <ccs:dataFormat>
  240. <xsl:value-of select="General"/>
  241. </ccs:dataFormat>
  242. </ccs:textFrame>
  243. </ccs:content>
  244. <ccs:style>legendtitle</ccs:style>
  245. </ccs:parts>
  246. </ccs:cells>
  247. </xsl:if>
  248. </ccs:row>
  249. <xsl:apply-templates select="col/area"/>
  250. </ccs:table>
  251. </ccs:content>
  252. </ccs:bodyElements>
  253. </xsl:if>
  254. </xsl:if>
  255. </xsl:template>
  256. <!-- get the data rows -->
  257. <xsl:template match="area[@icon or @color or @gradicon]">
  258. <ccs:row>
  259. <ccs:type>Detail</ccs:type>
  260. <ccs:cells>
  261. <ccs:parts>
  262. <ccs:id/>
  263. <ccs:type>Image</ccs:type>
  264. <ccs:content>
  265. <ccs:image>
  266. <ccs:url>
  267. <xsl:choose>
  268. <xsl:when test="@icon">
  269. <xsl:value-of select="concat($gateway,'/../../ppwb/Icon/',@icon,'.gif')"/>
  270. </xsl:when>
  271. <xsl:when test="@gradicon">
  272. <xsl:value-of select="concat($gateway,@gradicon)"/>
  273. </xsl:when>
  274. <xsl:otherwise>
  275. <xsl:value-of select="concat($crnGateway,'/../../ccs/images/bkg',@color,'.GIF')"/>
  276. </xsl:otherwise>
  277. </xsl:choose>
  278. </ccs:url>
  279. </ccs:image>
  280. </ccs:content>
  281. </ccs:parts>
  282. </ccs:cells>
  283. <ccs:cells>
  284. <ccs:parts>
  285. <ccs:id/>
  286. <ccs:type>TextFrame</ccs:type>
  287. <ccs:content>
  288. <ccs:textFrame>
  289. <ccs:value>
  290. <xsl:value-of select="@name"/>
  291. </ccs:value>
  292. <ccs:valueType>text</ccs:valueType>
  293. <ccs:dataFormat>
  294. <xsl:value-of select="General"/>
  295. </ccs:dataFormat>
  296. </ccs:textFrame>
  297. </ccs:content>
  298. <ccs:style>legendcell</ccs:style>
  299. </ccs:parts>
  300. </ccs:cells>
  301. <xsl:if test="@value">
  302. <ccs:cells>
  303. <ccs:parts>
  304. <ccs:id/>
  305. <ccs:type>TextFrame</ccs:type>
  306. <ccs:content>
  307. <ccs:textFrame>
  308. <ccs:value>
  309. <xsl:value-of select="@value"/>
  310. </ccs:value>
  311. <ccs:valueType>text</ccs:valueType>
  312. <ccs:dataFormat>
  313. <xsl:value-of select="General"/>
  314. </ccs:dataFormat>
  315. </ccs:textFrame>
  316. </ccs:content>
  317. <ccs:style>legendcell</ccs:style>
  318. </ccs:parts>
  319. </ccs:cells>
  320. </xsl:if>
  321. </ccs:row>
  322. </xsl:template>
  323. </xsl:stylesheet>