meta.xsl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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. <xsl:template priority="2" match="*[contains(style/CSS/@value, 'visibility:hidden' )]"/>
  17. <!-- first the metadata templates -->
  18. <xsl:template match="list">
  19. <xsl:param name="locid"/>
  20. <xsl:param name="reloc"/>
  21. <xsl:element name="{$reloc}">
  22. <ccs:id>
  23. <xsl:choose>
  24. <xsl:when test="@name">
  25. <xsl:value-of select="@name"/>
  26. </xsl:when>
  27. <xsl:otherwise>
  28. <xsl:value-of select="$locid"/>
  29. </xsl:otherwise>
  30. </xsl:choose>
  31. </ccs:id>
  32. <ccs:locid>
  33. <xsl:value-of select="$locid"/>
  34. </ccs:locid>
  35. <ccs:style/>
  36. <ccs:name>
  37. <xsl:value-of select="@name"/>
  38. </ccs:name>
  39. <ccs:type>Table</ccs:type>
  40. <ccs:content>
  41. <ccs:table>
  42. <ccs:isCrossTab>false</ccs:isCrossTab>
  43. <ccs:moreRows>0</ccs:moreRows>
  44. <ccs:moreCols>0</ccs:moreCols>
  45. <ccs:rows/>
  46. <xsl:for-each select="listColumns/listColumn">
  47. <ccs:columns>
  48. <ccs:isSummary>false</ccs:isSummary>
  49. <ccs:startPos>
  50. <xsl:value-of select="position() - 1"/>
  51. </ccs:startPos>
  52. <ccs:name>
  53. <xsl:value-of select="listColumnTitle/contents/textItem/dataSource/dataItemLabel/@refDataItem"/>
  54. </ccs:name>
  55. <xsl:apply-templates select="listColumnBody/contents">
  56. <xsl:with-param name="locid">
  57. <xsl:value-of select="concat($locid,':C')"/>
  58. </xsl:with-param>
  59. <xsl:with-param name="reloc">ccs:columnType</xsl:with-param>
  60. </xsl:apply-templates>
  61. <ccs:size>1</ccs:size>
  62. <ccs:style/>
  63. <ccs:containedGroup/>
  64. </ccs:columns>
  65. </xsl:for-each>
  66. </ccs:table>
  67. </ccs:content>
  68. </xsl:element>
  69. </xsl:template>
  70. <xsl:template match="table">
  71. <xsl:param name="locid"/>
  72. <xsl:param name="reloc"/>
  73. <xsl:for-each select="tableRows/tableRow/tableCells/tableCell/contents/*">
  74. <xsl:apply-templates select=".">
  75. <xsl:with-param name="locid">
  76. <xsl:value-of select="concat($locid,'T',position())"/>
  77. </xsl:with-param>
  78. <xsl:with-param name="reloc">
  79. <xsl:value-of select="$reloc"/>
  80. </xsl:with-param>
  81. </xsl:apply-templates>
  82. </xsl:for-each>
  83. </xsl:template>
  84. <xsl:template match="conditionalBlocks">
  85. <xsl:param name="locid"/>
  86. <xsl:param name="reloc"/>
  87. <!-- We don't actually process anything in conditonal blocks just yet, but we must count the block or else IDs will be messed up-->
  88. </xsl:template>
  89. <xsl:template match="hyperlink">
  90. <xsl:param name="locid"/>
  91. <xsl:param name="reloc"/>
  92. <!-- Explicitly ignore hyperlinks in this version. -->
  93. </xsl:template>
  94. <xsl:template match="repeaterTable">
  95. <xsl:param name="locid"/>
  96. <xsl:param name="reloc"/>
  97. <xsl:for-each select="repeaterTableCell/contents/*">
  98. <xsl:apply-templates select=".">
  99. <xsl:with-param name="locid">
  100. <xsl:value-of select="concat($locid,'RT',position())"/>
  101. </xsl:with-param>
  102. <xsl:with-param name="reloc">
  103. <xsl:value-of select="$reloc"/>
  104. </xsl:with-param>
  105. </xsl:apply-templates>
  106. </xsl:for-each>
  107. </xsl:template>
  108. <xsl:template match="crosstab">
  109. <xsl:param name="locid"/>
  110. <xsl:param name="reloc"/>
  111. <xsl:element name="{$reloc}">
  112. <ccs:id>
  113. <xsl:choose>
  114. <xsl:when test="@name">
  115. <xsl:value-of select="@name"/>
  116. </xsl:when>
  117. <xsl:otherwise>
  118. <xsl:value-of select="$locid"/>
  119. </xsl:otherwise>
  120. </xsl:choose>
  121. </ccs:id>
  122. <ccs:locid>
  123. <xsl:value-of select="$locid"/>
  124. </ccs:locid>
  125. <ccs:style/>
  126. <ccs:name>
  127. <xsl:value-of select="@name"/>
  128. </ccs:name>
  129. <ccs:type>Table</ccs:type>
  130. <ccs:content>
  131. <ccs:table>
  132. <ccs:isCrossTab>false</ccs:isCrossTab>
  133. <ccs:moreRows>0</ccs:moreRows>
  134. <ccs:moreCols>0</ccs:moreCols>
  135. <ccs:rows/>
  136. <ccs:columns/>
  137. </ccs:table>
  138. </ccs:content>
  139. </xsl:element>
  140. </xsl:template>
  141. <xsl:template match="block">
  142. <xsl:param name="locid"/>
  143. <xsl:param name="reloc"/>
  144. <xsl:for-each select="contents/*">
  145. <xsl:apply-templates select=".">
  146. <xsl:with-param name="locid">
  147. <xsl:value-of select="concat($locid,'P',position())"/>
  148. </xsl:with-param>
  149. <xsl:with-param name="reloc">
  150. <xsl:value-of select="$reloc"/>
  151. </xsl:with-param>
  152. </xsl:apply-templates>
  153. </xsl:for-each>
  154. </xsl:template>
  155. <xsl:template match="fieldSet">
  156. <xsl:param name="locid"/>
  157. <xsl:param name="reloc"/>
  158. <xsl:for-each select="contents/*">
  159. <xsl:apply-templates select=".">
  160. <xsl:with-param name="locid">
  161. <xsl:value-of select="concat($locid,'P',position())"/>
  162. </xsl:with-param>
  163. <xsl:with-param name="reloc">
  164. <xsl:value-of select="$reloc"/>
  165. </xsl:with-param>
  166. </xsl:apply-templates>
  167. </xsl:for-each>
  168. </xsl:template>
  169. <xsl:template match="page">
  170. <xsl:variable name="locid">
  171. <xsl:choose>
  172. <xsl:when test="@name">
  173. <xsl:value-of select="@name"/>
  174. </xsl:when>
  175. <xsl:otherwise>
  176. <xsl:value-of select="concat('page_',position())"/>
  177. </xsl:otherwise>
  178. </xsl:choose>
  179. </xsl:variable>
  180. <ccs:pages>
  181. <ccs:id>
  182. <xsl:value-of select="$locid"/>
  183. </ccs:id>
  184. <ccs:locid>
  185. <xsl:value-of select="$locid"/>
  186. </ccs:locid>
  187. <ccs:name>
  188. <xsl:if test="@name">
  189. <xsl:value-of select="$locid"/>
  190. </xsl:if>
  191. </ccs:name>
  192. <ccs:type>Page</ccs:type>
  193. <ccs:content>
  194. <ccs:page>
  195. <xsl:apply-templates>
  196. <xsl:with-param name="locid">
  197. <xsl:value-of select="$locid"/>
  198. </xsl:with-param>
  199. </xsl:apply-templates>
  200. </ccs:page>
  201. </ccs:content>
  202. </ccs:pages>
  203. </xsl:template>
  204. <xsl:template match="pageBody">
  205. <xsl:param name="locid"/>
  206. <xsl:apply-templates select="contents">
  207. <xsl:with-param name="locid">
  208. <xsl:value-of select="concat($locid,':B')"/>
  209. </xsl:with-param>
  210. <xsl:with-param name="reloc">ccs:bodyElements</xsl:with-param>
  211. </xsl:apply-templates>
  212. </xsl:template>
  213. <xsl:template match="pageHeader">
  214. <xsl:param name="locid"/>
  215. <xsl:apply-templates select="contents">
  216. <xsl:with-param name="locid">
  217. <xsl:value-of select="concat($locid,':H')"/>
  218. </xsl:with-param>
  219. <xsl:with-param name="reloc">ccs:headerElements</xsl:with-param>
  220. </xsl:apply-templates>
  221. </xsl:template>
  222. <xsl:template match="pageFooter">
  223. <xsl:param name="locid"/>
  224. <xsl:apply-templates select="contents">
  225. <xsl:with-param name="locid">
  226. <xsl:value-of select="concat($locid,':F')"/>
  227. </xsl:with-param>
  228. <xsl:with-param name="reloc">ccs:footerElements</xsl:with-param>
  229. </xsl:apply-templates>
  230. </xsl:template>
  231. <xsl:template match="contents">
  232. <xsl:param name="locid"/>
  233. <xsl:param name="reloc"/>
  234. <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">
  235. <xsl:apply-templates select=".">
  236. <xsl:with-param name="locid">
  237. <xsl:value-of select="concat($locid,position())"/>
  238. </xsl:with-param>
  239. <xsl:with-param name="reloc">
  240. <xsl:value-of select="$reloc"/>
  241. </xsl:with-param>
  242. </xsl:apply-templates>
  243. </xsl:for-each>
  244. </xsl:template>
  245. <xsl:template match="OTR">
  246. <xsl:param name="locid"/>
  247. <xsl:param name="reloc"/>
  248. <xsl:for-each select="*">
  249. <xsl:apply-templates select=".">
  250. <xsl:with-param name="locid">
  251. <xsl:value-of select="$locid"/>
  252. </xsl:with-param>
  253. <xsl:with-param name="reloc">
  254. <xsl:value-of select="$reloc"/>
  255. </xsl:with-param>
  256. </xsl:apply-templates>
  257. </xsl:for-each>
  258. </xsl:template>
  259. <xsl:template match="textItem">
  260. <xsl:param name="locid"/>
  261. <xsl:param name="reloc">noname</xsl:param>
  262. <xsl:element name="{$reloc}">
  263. <ccs:id>
  264. <xsl:choose>
  265. <xsl:when test="@name">
  266. <xsl:value-of select="@name"/>
  267. </xsl:when>
  268. <xsl:otherwise>
  269. <xsl:value-of select="$locid"/>
  270. </xsl:otherwise>
  271. </xsl:choose>
  272. </ccs:id>
  273. <ccs:locid>
  274. <xsl:value-of select="$locid"/>
  275. </ccs:locid>
  276. <ccs:style>
  277. </ccs:style>
  278. <ccs:name>
  279. <xsl:value-of select="@name"/>
  280. </ccs:name>
  281. <ccs:type>TextFrame</ccs:type>
  282. <ccs:content>
  283. <ccs:textFrame>
  284. <ccs:hSize>0</ccs:hSize>
  285. <ccs:vSize>0</ccs:vSize>
  286. </ccs:textFrame>
  287. </ccs:content>
  288. </xsl:element>
  289. </xsl:template>
  290. <xsl:template match="image | CMMMap">
  291. <xsl:param name="locid"/>
  292. <xsl:param name="reloc"/>
  293. <xsl:element name="{$reloc}">
  294. <ccs:id>
  295. <xsl:choose>
  296. <xsl:when test="@name">
  297. <xsl:value-of select="@name"/>
  298. </xsl:when>
  299. <xsl:otherwise>
  300. <xsl:value-of select="$locid"/>
  301. </xsl:otherwise>
  302. </xsl:choose>
  303. </ccs:id>
  304. <ccs:locid>
  305. <xsl:value-of select="$locid"/>
  306. </ccs:locid>
  307. <xsl:if test="@name">
  308. <ccs:name>
  309. <xsl:value-of select="@name"/>
  310. </ccs:name>
  311. </xsl:if>
  312. <ccs:type>Image</ccs:type>
  313. <ccs:content>
  314. <ccs:image>
  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:imageType>gif</ccs:imageType>
  339. </ccs:image>
  340. <ccs:style/>
  341. </ccs:content>
  342. </xsl:element>
  343. </xsl:template>
  344. <xsl:template match="pieChart | radarChart | progressiveChart | combinationChart | paretoChart | scatterChart | bubbleChart | polarChart | threeDCombinationChart | threeDScatterChart | gaugeChart|mapChart | metricsChart">
  345. <xsl:param name="locid"/>
  346. <xsl:param name="reloc"/>
  347. <xsl:element name="{$reloc}">
  348. <ccs:id>
  349. <xsl:choose>
  350. <xsl:when test="@name">
  351. <xsl:value-of select="@name"/>
  352. </xsl:when>
  353. <xsl:otherwise>
  354. <xsl:value-of select="$locid"/>
  355. </xsl:otherwise>
  356. </xsl:choose>
  357. </ccs:id>
  358. <ccs:locid>
  359. <xsl:value-of select="$locid"/>
  360. </ccs:locid>
  361. <ccs:type>Chart</ccs:type>
  362. <xsl:if test="@name">
  363. <ccs:name>
  364. <xsl:value-of select="@name"/>
  365. </ccs:name>
  366. </xsl:if>
  367. <ccs:content>
  368. <ccs:chart>
  369. <ccs:hSize>
  370. <!-- style="width:400px;height:40px" -->
  371. <xsl:variable name="width">
  372. <xsl:value-of select="substring-before(substring-after(style/CSS/@value,'width:'),'px')"/>
  373. </xsl:variable>
  374. <xsl:choose>
  375. <xsl:when test="string-length($width) &gt; 0">
  376. <xsl:value-of select="$width"/>
  377. </xsl:when>
  378. <xsl:otherwise>0</xsl:otherwise>
  379. </xsl:choose>
  380. </ccs:hSize>
  381. <ccs:vSize>
  382. <xsl:variable name="height">
  383. <xsl:value-of select="substring-before(substring-after(style/CSS/@value,'height:'),'px')"/>
  384. </xsl:variable>
  385. <xsl:choose>
  386. <xsl:when test="string-length($height) &gt; 0">
  387. <xsl:value-of select="$height"/>
  388. </xsl:when>
  389. <xsl:otherwise>0</xsl:otherwise>
  390. </xsl:choose>
  391. </ccs:vSize>
  392. </ccs:chart>
  393. <ccs:style/>
  394. </ccs:content>
  395. </xsl:element>
  396. </xsl:template>
  397. </xsl:stylesheet>