pptrans.xsl 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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="transformData" select="'true'"/>
  10. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  11. <xsl:template match="/">
  12. <xsl:choose>
  13. <xsl:when test="$transformData = 'true'">
  14. <page>
  15. <id>4</id>
  16. <xsl:apply-templates select="data"/>
  17. </page>
  18. </xsl:when>
  19. <xsl:otherwise>
  20. <rds:page>
  21. <!--ID is hardcoded to 4 to maintain compatibility with previous releases-->
  22. <id>4</id>
  23. <rds:posId>P1</rds:posId>
  24. <xsl:if test="data/tab/crosstab">
  25. <rds:header>
  26. <rds:item>
  27. <rds:posId>P1H1</rds:posId>
  28. <rds:conditional>false</rds:conditional>
  29. <rds:MTextFrame>
  30. <id>dimLine</id>
  31. </rds:MTextFrame>
  32. </rds:item>
  33. </rds:header>
  34. <rds:body>
  35. <rds:item>
  36. <rds:posId>P1B1</rds:posId>
  37. <rds:conditional>false</rds:conditional>
  38. <rds:MCrossTab>
  39. <id>2</id>
  40. </rds:MCrossTab>
  41. </rds:item>
  42. </rds:body>
  43. <xsl:if test="data/tab/status_line/@status">
  44. <rds:footer>
  45. <rds:item>
  46. <rds:posId>P1F1</rds:posId>
  47. <rds:conditional>false</rds:conditional>
  48. <rds:MTextFrame>
  49. <id>3</id>
  50. </rds:MTextFrame>
  51. </rds:item>
  52. </rds:footer>
  53. </xsl:if>
  54. </xsl:if>
  55. </rds:page>
  56. </xsl:otherwise>
  57. </xsl:choose>
  58. </xsl:template>
  59. <xsl:template match="data">
  60. <header>
  61. <item>
  62. <txt>
  63. <id>dimLine</id>
  64. <style>dimLine</style>
  65. <val>
  66. <xsl:value-of select="tab/dimension_line/@details"/>
  67. </val>
  68. <valTyp>text</valTyp>
  69. <exclPatrn>General</exclPatrn>
  70. </txt>
  71. </item>
  72. </header>
  73. <body>
  74. <item>
  75. <xsl:apply-templates select="tab/crosstab"/>
  76. </item>
  77. </body>
  78. <xsl:if test="tab/status_line/@status">
  79. <footer>
  80. <item>
  81. <txt>
  82. <id>3</id>
  83. <val>
  84. <xsl:value-of select="normalize-space(tab/status_line/@status)"/>
  85. </val>
  86. <valTyp>text</valTyp>
  87. <exclPatrn>General</exclPatrn>
  88. </txt>
  89. </item>
  90. </footer>
  91. </xsl:if>
  92. </xsl:template>
  93. <xsl:template match="crosstab">
  94. <ctab>
  95. <id>2</id>
  96. <corner>
  97. <style>measurecell</style>
  98. <style>td</style>
  99. <xsl:apply-templates select="measure"/>
  100. </corner>
  101. <xsl:apply-templates select="columns"/>
  102. <xsl:apply-templates select="rows"/>
  103. <table>
  104. <xsl:apply-templates select="datarow"/>
  105. </table>
  106. </ctab>
  107. </xsl:template>
  108. <xsl:template match="measure">
  109. <item>
  110. <txt>
  111. <style>measurecell</style>
  112. <val>
  113. <xsl:value-of select="concat(@name,' ',@type)"/>
  114. </val>
  115. <valTyp>text</valTyp>
  116. </txt>
  117. </item>
  118. </xsl:template>
  119. <xsl:template match="datarow">
  120. <row>
  121. <xsl:for-each select="col">
  122. <cell>
  123. <style>td</style>
  124. <style>
  125. <xsl:call-template name="cellStyle"/>
  126. </style>
  127. <item>
  128. <txt>
  129. <style>
  130. <xsl:call-template name="cellStyle"/>
  131. </style>
  132. <xsl:choose>
  133. <xsl:when test="@calculation = 'true'">
  134. <val>
  135. <xsl:value-of select="text()"/>
  136. </val>
  137. </xsl:when>
  138. <xsl:otherwise>
  139. <val>
  140. <xsl:value-of select="@value"/>
  141. </val>
  142. </xsl:otherwise>
  143. </xsl:choose>
  144. <xsl:if test="not(@value) and not(@calculation = 'true')">
  145. <valErrorState>NA</valErrorState>
  146. </xsl:if>
  147. <valTyp>number</valTyp>
  148. <xsl:if test="@formattedValue">
  149. <fmtVal><xsl:value-of select="@formattedValue"/></fmtVal>
  150. </xsl:if>
  151. <exclPatrn>
  152. <xsl:value-of select="@format"/>
  153. </exclPatrn>
  154. </txt>
  155. </item>
  156. </cell>
  157. </xsl:for-each>
  158. </row>
  159. </xsl:template>
  160. <xsl:template match="row">
  161. <xsl:param name="rowcount" select="count(.//row)">
  162. <!--Counting all rows like this is inefficient....-->
  163. </xsl:param>
  164. <name>
  165. <style>td</style>
  166. <xsl:call-template name="labelStyle"/>
  167. <item>
  168. <txt>
  169. <xsl:call-template name="labelStyle"/>
  170. <val>
  171. <xsl:value-of select="@name"/>
  172. </val>
  173. <valTyp>text</valTyp>
  174. </txt>
  175. </item>
  176. </name>
  177. <start>
  178. <xsl:choose>
  179. <xsl:when test="@axis_pos">
  180. <xsl:value-of select="@axis_pos"/>
  181. </xsl:when>
  182. <xsl:otherwise>
  183. <xsl:value-of select="@pos"/>
  184. </xsl:otherwise>
  185. </xsl:choose>
  186. </start>
  187. <size>
  188. <xsl:choose>
  189. <xsl:when test="$rowcount > 0">
  190. <xsl:value-of select="$rowcount"/>
  191. </xsl:when>
  192. <xsl:otherwise>1</xsl:otherwise>
  193. </xsl:choose>
  194. </size>
  195. <xsl:for-each select="row">
  196. <nestedDimension>
  197. <xsl:apply-templates select="."/>
  198. </nestedDimension>
  199. </xsl:for-each>
  200. </xsl:template>
  201. <xsl:template match="column">
  202. <xsl:param name="colcount" select="count(.//column)">
  203. <!--Counting all columns like this is inefficient....-->
  204. </xsl:param>
  205. <name>
  206. <style>td</style>
  207. <xsl:call-template name="labelStyle"/>
  208. <item>
  209. <txt>
  210. <xsl:call-template name="labelStyle"/>
  211. <val>
  212. <xsl:value-of select="@name"/>
  213. </val>
  214. <valTyp>text</valTyp>
  215. </txt>
  216. </item>
  217. </name>
  218. <start>
  219. <xsl:choose>
  220. <xsl:when test="@axis_pos">
  221. <xsl:value-of select="@axis_pos"/>
  222. </xsl:when>
  223. <xsl:otherwise>
  224. <xsl:value-of select="@pos"/>
  225. </xsl:otherwise>
  226. </xsl:choose>
  227. </start>
  228. <size>
  229. <xsl:choose>
  230. <xsl:when test="$colcount > 0">
  231. <xsl:value-of select="$colcount"/>
  232. </xsl:when>
  233. <xsl:otherwise>1</xsl:otherwise>
  234. </xsl:choose>
  235. </size>
  236. <xsl:for-each select="column">
  237. <nestedDimension>
  238. <xsl:apply-templates select="."/>
  239. </nestedDimension>
  240. </xsl:for-each>
  241. </xsl:template>
  242. <xsl:template match="rows">
  243. <xsl:for-each select="row">
  244. <row>
  245. <xsl:apply-templates select="."/>
  246. </row>
  247. </xsl:for-each>
  248. </xsl:template>
  249. <xsl:template match="columns">
  250. <xsl:for-each select="column">
  251. <column>
  252. <xsl:apply-templates select="."/>
  253. </column>
  254. </xsl:for-each>
  255. </xsl:template>
  256. <xsl:template name="labelStyle">
  257. <style>
  258. <xsl:choose>
  259. <xsl:when test="@suppressed">
  260. <xsl:choose>
  261. <xsl:when test="local-name() = 'row'">
  262. <xsl:choose>
  263. <xsl:when test="parent::row">8020rowlabelnested</xsl:when>
  264. <xsl:otherwise>8020rowlabel</xsl:otherwise>
  265. </xsl:choose>
  266. </xsl:when>
  267. <xsl:when test="local-name() = 'column'">
  268. <xsl:choose>
  269. <xsl:when test="parent::column">8020labelcolnested</xsl:when>
  270. <xsl:otherwise>8020collabel</xsl:otherwise>
  271. </xsl:choose>
  272. </xsl:when>
  273. </xsl:choose>
  274. </xsl:when>
  275. <xsl:when test="@calculation">
  276. <xsl:choose>
  277. <xsl:when test="local-name() = 'row'">
  278. <xsl:choose>
  279. <xsl:when test="parent::row">calculationrowlabelnested</xsl:when>
  280. <xsl:otherwise>calculationrowlabel</xsl:otherwise>
  281. </xsl:choose>
  282. </xsl:when>
  283. <xsl:when test="local-name() = 'column'">
  284. <xsl:choose>
  285. <xsl:when test="parent::column">calculationcollabelnested</xsl:when>
  286. <xsl:otherwise>calculationcollabel</xsl:otherwise>
  287. </xsl:choose>
  288. </xsl:when>
  289. </xsl:choose>
  290. </xsl:when>
  291. <xsl:when test="@summary">
  292. <xsl:choose>
  293. <xsl:when test="local-name() = 'row'">
  294. <xsl:choose>
  295. <xsl:when test="@summ_style_one">summaryrowlabel1</xsl:when>
  296. <xsl:otherwise>summaryrowlabel2</xsl:otherwise>
  297. </xsl:choose>
  298. </xsl:when>
  299. <xsl:when test="local-name() = 'column'">
  300. <xsl:choose>
  301. <xsl:when test="@summ_style_one">summarycollabel1</xsl:when>
  302. <xsl:otherwise>summarycollabel2</xsl:otherwise>
  303. </xsl:choose>
  304. </xsl:when>
  305. </xsl:choose>
  306. </xsl:when>
  307. <xsl:otherwise>
  308. <xsl:choose>
  309. <xsl:when test="local-name() = 'row'">
  310. <xsl:choose>
  311. <xsl:when test="parent::row">rowLabelNested</xsl:when>
  312. <xsl:otherwise>rowLabel</xsl:otherwise>
  313. </xsl:choose>
  314. </xsl:when>
  315. <xsl:when test="local-name() = 'column'">
  316. <xsl:choose>
  317. <xsl:when test="parent::column">colLabelNested</xsl:when>
  318. <xsl:otherwise>colLabel</xsl:otherwise>
  319. </xsl:choose>
  320. </xsl:when>
  321. </xsl:choose>
  322. </xsl:otherwise>
  323. </xsl:choose>
  324. </style>
  325. </xsl:template>
  326. <xsl:template name="cellStyle">
  327. <xsl:choose>
  328. <xsl:when test="@lowexception">lowexceptioncell</xsl:when>
  329. <xsl:when test="@highexception">highexceptioncell</xsl:when>
  330. <xsl:when test="@summary">
  331. <xsl:choose>
  332. <xsl:when test="@rank">
  333. <xsl:choose>
  334. <xsl:when test="@summ_style_one">summarycell1rank</xsl:when>
  335. <xsl:otherwise>summarycell2rank</xsl:otherwise>
  336. </xsl:choose>
  337. </xsl:when>
  338. <xsl:when test="@suppressed or @calculation">
  339. <xsl:choose>
  340. <xsl:when test="@summ_style_one">summarycell1italic</xsl:when>
  341. <xsl:otherwise>summarycell2italic</xsl:otherwise>
  342. </xsl:choose>
  343. </xsl:when>
  344. <xsl:otherwise>
  345. <xsl:choose>
  346. <xsl:when test="@summ_style_one">summarycell1</xsl:when>
  347. <xsl:otherwise>summarycell2</xsl:otherwise>
  348. </xsl:choose>
  349. </xsl:otherwise>
  350. </xsl:choose>
  351. </xsl:when>
  352. <xsl:when test="@rank">rankcell</xsl:when>
  353. <xsl:when test="@calculation">calculationcell</xsl:when>
  354. <xsl:when test="@suppressed">8020cell</xsl:when>
  355. <xsl:otherwise>cell</xsl:otherwise>
  356. </xsl:choose>
  357. <xsl:if test="@exception">
  358. <unprocessedException>
  359. <textColor>
  360. <xsl:value-of select="@fontcolor"/>
  361. </textColor>
  362. <bgColor>
  363. <xsl:value-of select="@bgcolor"/>
  364. </bgColor>
  365. <fontSize>
  366. <xsl:value-of select="@fontSize"/>
  367. </fontSize>
  368. <bold>
  369. <xsl:value-of select="@bold"/>
  370. </bold>
  371. <italic>
  372. <xsl:value-of select="@italic"/>
  373. </italic>
  374. <underline>
  375. <xsl:value-of select="@underline"/>
  376. </underline>
  377. <textAlign>
  378. <xsl:value-of select="@textAlign"/>
  379. </textAlign>
  380. </unprocessedException>
  381. </xsl:if>
  382. </xsl:template>
  383. </xsl:stylesheet>