upgradeMeta.xsl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:ccs="http://developer.cognos.com/rds/1">
  9. <xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" version="1.0"/>
  10. <xsl:template match="/">
  11. <ccs:topReport>
  12. <ccs:title/>
  13. <xsl:apply-templates select="report/layouts/layout/reportPages"/>
  14. </ccs:topReport>
  15. </xsl:template>
  16. <!-- first the metadata templates -->
  17. <xsl:template match="list">
  18. <xsl:param name="locid"/>
  19. <xsl:param name="reloc"/>
  20. <xsl:element name="{$reloc}">
  21. <ccs:id>
  22. <xsl:value-of select="$locid"/>
  23. </ccs:id>
  24. <ccs:style/>
  25. <ccs:name>
  26. <xsl:value-of select="@name"/>
  27. </ccs:name>
  28. <ccs:type>Table</ccs:type>
  29. <ccs:content>
  30. <ccs:table>
  31. <ccs:isCrossTab>false</ccs:isCrossTab>
  32. <ccs:moreRows>0</ccs:moreRows>
  33. <ccs:moreCols>0</ccs:moreCols>
  34. <ccs:rows/>
  35. <xsl:for-each select="listColumns/listColumn">
  36. <ccs:columns>
  37. <ccs:isSummary>false</ccs:isSummary>
  38. <ccs:startPos>
  39. <xsl:value-of select="position() - 1"/>
  40. </ccs:startPos>
  41. <ccs:name>
  42. <xsl:value-of select="listColumnTitle/contents/textItem/dataSource/dataItemLabel/@refDataItem"/>
  43. </ccs:name>
  44. <xsl:apply-templates select="listColumnBody/contents">
  45. <xsl:with-param name="locid">
  46. <xsl:value-of select="concat($locid,':C')"/>
  47. </xsl:with-param>
  48. <xsl:with-param name="reloc">ccs:columnType</xsl:with-param>
  49. </xsl:apply-templates>
  50. <ccs:size>1</ccs:size>
  51. <ccs:style/>
  52. <ccs:containedGroup/>
  53. </ccs:columns>
  54. </xsl:for-each>
  55. </ccs:table>
  56. </ccs:content>
  57. </xsl:element>
  58. </xsl:template>
  59. <xsl:template match="table">
  60. <xsl:param name="locid"/>
  61. <xsl:param name="reloc"/>
  62. <xsl:for-each select="tableRows/tableRow/tableCells/tableCell/contents/*">
  63. <xsl:apply-templates select=".">
  64. <xsl:with-param name="locid">
  65. <xsl:value-of select="concat($locid,'T',position())"/>
  66. </xsl:with-param>
  67. <xsl:with-param name="reloc">
  68. <xsl:value-of select="$reloc"/>
  69. </xsl:with-param>
  70. </xsl:apply-templates>
  71. </xsl:for-each>
  72. </xsl:template>
  73. <xsl:template match="conditionalBlocks">
  74. <xsl:param name="locid"/>
  75. <xsl:param name="reloc"/>
  76. <!-- We don't actually process anything in conditonal blocks just yet, but we must count the block or else IDs will be messed up-->
  77. </xsl:template>
  78. <xsl:template match="hyperlink">
  79. <xsl:param name="locid"/>
  80. <xsl:param name="reloc"/>
  81. <!-- Explicitly ignore hyperlinks in this version. -->
  82. </xsl:template>
  83. <xsl:template match="repeaterTable">
  84. <xsl:param name="locid"/>
  85. <xsl:param name="reloc"/>
  86. <xsl:for-each select="repeaterTableCell/contents/*">
  87. <xsl:apply-templates select=".">
  88. <xsl:with-param name="locid">
  89. <xsl:value-of select="concat($locid,'RT',position())"/>
  90. </xsl:with-param>
  91. <xsl:with-param name="reloc">
  92. <xsl:value-of select="$reloc"/>
  93. </xsl:with-param>
  94. </xsl:apply-templates>
  95. </xsl:for-each>
  96. </xsl:template>
  97. <xsl:template match="crosstab">
  98. <xsl:param name="locid"/>
  99. <xsl:param name="reloc"/>
  100. <xsl:element name="{$reloc}">
  101. <ccs:id>
  102. <xsl:value-of select="$locid"/>
  103. </ccs:id>
  104. <ccs:style/>
  105. <ccs:name>
  106. <xsl:value-of select="@name"/>
  107. </ccs:name>
  108. <ccs:type>Table</ccs:type>
  109. <ccs:content>
  110. <ccs:table>
  111. <ccs:isCrossTab>false</ccs:isCrossTab>
  112. <ccs:moreRows>0</ccs:moreRows>
  113. <ccs:moreCols>0</ccs:moreCols>
  114. <ccs:rows/>
  115. <ccs:columns/>
  116. </ccs:table>
  117. </ccs:content>
  118. </xsl:element>
  119. </xsl:template>
  120. <xsl:template match="block">
  121. <xsl:param name="locid"/>
  122. <xsl:param name="reloc"/>
  123. <xsl:for-each select="contents/*">
  124. <xsl:apply-templates select=".">
  125. <xsl:with-param name="locid">
  126. <xsl:value-of select="concat($locid,'P',position())"/>
  127. </xsl:with-param>
  128. <xsl:with-param name="reloc">
  129. <xsl:value-of select="$reloc"/>
  130. </xsl:with-param>
  131. </xsl:apply-templates>
  132. </xsl:for-each>
  133. </xsl:template>
  134. <xsl:template match="fieldSet">
  135. <xsl:param name="locid"/>
  136. <xsl:param name="reloc"/>
  137. <xsl:for-each select="contents/*">
  138. <xsl:apply-templates select=".">
  139. <xsl:with-param name="locid">
  140. <xsl:value-of select="concat($locid,'P',position())"/>
  141. </xsl:with-param>
  142. <xsl:with-param name="reloc">
  143. <xsl:value-of select="$reloc"/>
  144. </xsl:with-param>
  145. </xsl:apply-templates>
  146. </xsl:for-each>
  147. </xsl:template>
  148. <xsl:template match="page">
  149. <xsl:variable name="locid">
  150. <xsl:choose>
  151. <xsl:when test="@name">
  152. <xsl:value-of select="@name"/>
  153. </xsl:when>
  154. <xsl:otherwise>
  155. <xsl:value-of select="concat('page_',position())"/>
  156. </xsl:otherwise>
  157. </xsl:choose>
  158. </xsl:variable>
  159. <ccs:pages>
  160. <ccs:id>
  161. <xsl:value-of select="$locid"/>
  162. </ccs:id>
  163. <ccs:name>
  164. <xsl:if test="@name">
  165. <xsl:value-of select="$locid"/>
  166. </xsl:if>
  167. </ccs:name>
  168. <ccs:type>Page</ccs:type>
  169. <ccs:content>
  170. <ccs:page>
  171. <xsl:apply-templates>
  172. <xsl:with-param name="locid">
  173. <xsl:value-of select="$locid"/>
  174. </xsl:with-param>
  175. </xsl:apply-templates>
  176. </ccs:page>
  177. </ccs:content>
  178. </ccs:pages>
  179. </xsl:template>
  180. <xsl:template match="pageBody">
  181. <xsl:param name="locid"/>
  182. <xsl:apply-templates select="contents">
  183. <xsl:with-param name="locid">
  184. <xsl:value-of select="concat($locid,':B')"/>
  185. </xsl:with-param>
  186. <xsl:with-param name="reloc">ccs:bodyElements</xsl:with-param>
  187. </xsl:apply-templates>
  188. </xsl:template>
  189. <xsl:template match="pageHeader">
  190. <xsl:param name="locid"/>
  191. <xsl:apply-templates select="contents">
  192. <xsl:with-param name="locid">
  193. <xsl:value-of select="concat($locid,':H')"/>
  194. </xsl:with-param>
  195. <xsl:with-param name="reloc">ccs:headerElements</xsl:with-param>
  196. </xsl:apply-templates>
  197. </xsl:template>
  198. <xsl:template match="pageFooter">
  199. <xsl:param name="locid"/>
  200. <xsl:apply-templates select="contents">
  201. <xsl:with-param name="locid">
  202. <xsl:value-of select="concat($locid,':F')"/>
  203. </xsl:with-param>
  204. <xsl:with-param name="reloc">ccs:footerElements</xsl:with-param>
  205. </xsl:apply-templates>
  206. </xsl:template>
  207. <xsl:template match="contents">
  208. <xsl:param name="locid"/>
  209. <xsl:param name="reloc"/>
  210. <xsl:for-each select="table/tableRows/tableRow/tableCells/tableCell/contents/* | list | block | crosstab | textItem | image | CMMMap | pieChart | radarChart | progressiveChart | combinationChart | paretoChart | scatterChart | bubbleChart | polarChart | threeDCombinationChart | threeDScatterChart | gaugeChart|mapChart | metricsChart | fieldSet | repeaterTable | conditionalBlocks | hyperlink">
  211. <xsl:apply-templates select=".">
  212. <xsl:with-param name="locid">
  213. <xsl:value-of select="concat($locid,position())"/>
  214. </xsl:with-param>
  215. <xsl:with-param name="reloc">
  216. <xsl:value-of select="$reloc"/>
  217. </xsl:with-param>
  218. </xsl:apply-templates>
  219. </xsl:for-each>
  220. </xsl:template>
  221. <xsl:template match="OTR">
  222. <xsl:param name="locid"/>
  223. <xsl:param name="reloc"/>
  224. <xsl:for-each select="*">
  225. <xsl:apply-templates select=".">
  226. <xsl:with-param name="locid">
  227. <xsl:value-of select="$locid"/>
  228. </xsl:with-param>
  229. <xsl:with-param name="reloc">
  230. <xsl:value-of select="$reloc"/>
  231. </xsl:with-param>
  232. </xsl:apply-templates>
  233. </xsl:for-each>
  234. </xsl:template>
  235. <xsl:template match="textItem">
  236. <xsl:param name="locid"/>
  237. <xsl:param name="reloc">noname</xsl:param>
  238. <xsl:element name="{$reloc}">
  239. <ccs:id>
  240. <xsl:value-of select="$locid"/>
  241. </ccs:id>
  242. <ccs:style>
  243. </ccs:style>
  244. <ccs:name>
  245. <xsl:value-of select="@name"/>
  246. </ccs:name>
  247. <ccs:type>TextFrame</ccs:type>
  248. <ccs:content>
  249. <ccs:textFrame>
  250. <ccs:hSize>0</ccs:hSize>
  251. <ccs:vSize>0</ccs:vSize>
  252. </ccs:textFrame>
  253. </ccs:content>
  254. </xsl:element>
  255. </xsl:template>
  256. <xsl:template match="image | CMMMap">
  257. <xsl:param name="locid"/>
  258. <xsl:param name="reloc"/>
  259. <xsl:element name="{$reloc}">
  260. <ccs:id>
  261. <xsl:value-of select="$locid"/>
  262. </ccs:id>
  263. <xsl:if test="@name">
  264. <ccs:name>
  265. <xsl:value-of select="@name"/>
  266. </ccs:name>
  267. </xsl:if>
  268. <ccs:type>Image</ccs:type>
  269. <ccs:content>
  270. <ccs:image>
  271. <ccs:hSize>
  272. <!-- style="width:400px;height:40px" -->
  273. <xsl:variable name="width">
  274. <xsl:value-of select="substring-before(substring-after(style/CSS/@value,'width:'),'px')"/>
  275. </xsl:variable>
  276. <xsl:choose>
  277. <xsl:when test="string-length($width) &gt; 0">
  278. <xsl:value-of select="$width"/>
  279. </xsl:when>
  280. <xsl:otherwise>0</xsl:otherwise>
  281. </xsl:choose>
  282. </ccs:hSize>
  283. <ccs:vSize>
  284. <xsl:variable name="height">
  285. <xsl:value-of select="substring-before(substring-after(style/CSS/@value,'height:'),'px')"/>
  286. </xsl:variable>
  287. <xsl:choose>
  288. <xsl:when test="string-length($height) &gt; 0">
  289. <xsl:value-of select="$height"/>
  290. </xsl:when>
  291. <xsl:otherwise>0</xsl:otherwise>
  292. </xsl:choose>
  293. </ccs:vSize>
  294. <ccs:imageType>gif</ccs:imageType>
  295. </ccs:image>
  296. <ccs:style/>
  297. </ccs:content>
  298. </xsl:element>
  299. </xsl:template>
  300. <xsl:template match="pieChart | radarChart | progressiveChart | combinationChart | paretoChart | scatterChart | bubbleChart | polarChart | threeDCombinationChart | threeDScatterChart | gaugeChart|mapChart | metricsChart">
  301. <xsl:param name="locid"/>
  302. <xsl:param name="reloc"/>
  303. <xsl:element name="{$reloc}">
  304. <ccs:id>
  305. <xsl:value-of select="$locid"/>
  306. </ccs:id>
  307. <ccs:type>Chart</ccs:type>
  308. <xsl:if test="@name">
  309. <ccs:name>
  310. <xsl:value-of select="@name"/>
  311. </ccs:name>
  312. </xsl:if>
  313. <ccs:content>
  314. <ccs:chart>
  315. <ccs:hSize>
  316. <!-- style="width:400px;height:40px" -->
  317. <xsl:variable name="width">
  318. <xsl:value-of select="substring-before(substring-after(style/CSS/@value,'width:'),'px')"/>
  319. </xsl:variable>
  320. <xsl:choose>
  321. <xsl:when test="string-length($width) &gt; 0">
  322. <xsl:value-of select="$width"/>
  323. </xsl:when>
  324. <xsl:otherwise>0</xsl:otherwise>
  325. </xsl:choose>
  326. </ccs:hSize>
  327. <ccs:vSize>
  328. <xsl:variable name="height">
  329. <xsl:value-of select="substring-before(substring-after(style/CSS/@value,'height:'),'px')"/>
  330. </xsl:variable>
  331. <xsl:choose>
  332. <xsl:when test="string-length($height) &gt; 0">
  333. <xsl:value-of select="$height"/>
  334. </xsl:when>
  335. <xsl:otherwise>0</xsl:otherwise>
  336. </xsl:choose>
  337. </ccs:vSize>
  338. </ccs:chart>
  339. <ccs:style/>
  340. </ccs:content>
  341. </xsl:element>
  342. </xsl:template>
  343. </xsl:stylesheet>