ldx2frag.xsl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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:fo="http://www.w3.org/1999/XSL/Format" xmlns:rds="http://developer.cognos.com/schemas/rds/contentmodel/1">
  9. <xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
  10. <xsl:param name="genFragment">true</xsl:param>
  11. <xsl:variable name="fragprefix">
  12. <xsl:choose>
  13. <xsl:when test="$genFragment = 'true'">_THIS_</xsl:when>
  14. <xsl:otherwise/>
  15. </xsl:choose>
  16. </xsl:variable>
  17. <xsl:variable name="quot">"</xsl:variable>
  18. <xsl:variable name="apos">'</xsl:variable>
  19. <xsl:variable name="versionbase">
  20. <xsl:value-of select="/*/rds:versionBase"/>
  21. </xsl:variable>
  22. <xsl:template match="/">
  23. <xsl:choose>
  24. <xsl:when test="$genFragment = 'true'">
  25. <fragment xmlns="http://developer.cognos.com/fragments/1/">
  26. <info>
  27. <title>CCS ReportLet</title>
  28. </info>
  29. <markup>
  30. <mimeType>text/html</mimeType>
  31. <markupXml>
  32. <style>
  33. <xsl:apply-templates select="//rds:styleGroup"/>
  34. </style>
  35. <xsl:apply-templates select="//rds:document/rds:page"/>
  36. <xsl:apply-templates select="//rds:reportElement/*"/>
  37. </markupXml>
  38. </markup>
  39. </fragment>
  40. </xsl:when>
  41. <xsl:otherwise>
  42. <html xmlns="http://www.w3.org/1999/xhtml">
  43. <head>
  44. <style type="text/css">
  45. <xsl:apply-templates select="//rds:styleGroup"/>
  46. </style>
  47. <title>CCS test </title>
  48. </head>
  49. <body>
  50. <xsl:apply-templates select="//rds:document/rds:page"/>
  51. <xsl:apply-templates select="//rds:reportElement/*"/>
  52. </body>
  53. </html>
  54. </xsl:otherwise>
  55. </xsl:choose>
  56. </xsl:template>
  57. <xsl:template match="rds:styleGroup">
  58. .<xsl:value-of select="concat($fragprefix,rds:name)"/> {
  59. <xsl:if test="rds:bgColor">background-color: <xsl:apply-templates mode="printColor" select="rds:bgColor"/>;
  60. </xsl:if>
  61. <xsl:if test="rds:fgColor">color: <xsl:apply-templates mode="printColor" select="rds:fgColor"/>;
  62. </xsl:if>
  63. <xsl:if test="rds:font/rds:family">font-family: &quot;<xsl:value-of select="rds:font/rds:family"/>&quot; ;
  64. </xsl:if>
  65. <xsl:if test="rds:font/rds:size">font-size: <xsl:value-of select="concat(rds:font/rds:size/rds:val, rds:font/rds:size/rds:units)"/>;
  66. </xsl:if>
  67. <xsl:if test="rds:boxStyle/rds:padding">padding: <xsl:value-of select="concat(rds:boxStyle/rds:padding/rds:top/rds:val, rds:boxStyle/rds:padding/rds:top/rds:units, ' ',
  68. rds:boxStyle/rds:padding/rds:right/rds:val, rds:boxStyle/rds:padding/rds:right/rds:units, ' ',
  69. rds:boxStyle/rds:padding/rds:bottom/rds:val, rds:boxStyle/rds:padding/rds:bottom/rds:units, ' ',
  70. rds:boxStyle/rds:padding/rds:left/rds:val, rds:boxStyle/rds:padding/rds:left/rds:units )"/>;
  71. </xsl:if>
  72. <xsl:if test="rds:hAlign">text-align: <xsl:value-of select="rds:hAlign"/>;
  73. </xsl:if>
  74. <xsl:if test="rds:vAlign">vertical-align: <xsl:value-of select="rds:vAlign"/>;
  75. </xsl:if>
  76. <xsl:if test="rds:font/rds:fontStyle/rds:bold">font-weight: <xsl:choose>
  77. <xsl:when test="rds:font/rds:fontStyle/rds:bold = 'true'">bold</xsl:when>
  78. <xsl:otherwise>normal</xsl:otherwise>
  79. </xsl:choose>;
  80. </xsl:if>
  81. <xsl:if test="rds:font/rds:fontStyle/rds:underline">text-decoration: <xsl:choose>
  82. <xsl:when test="rds:font/rds:fontStyle/rds:underline = 'true'">underline</xsl:when>
  83. <xsl:otherwise>none</xsl:otherwise>
  84. </xsl:choose>;
  85. </xsl:if>
  86. <xsl:if test="rds:textStyle/rds:wrapping">white-space: <xsl:choose>
  87. <xsl:when test="rds:textStyle/rds:wrapping = 'false'">nowrap</xsl:when>
  88. <xsl:otherwise>normal</xsl:otherwise>
  89. </xsl:choose>;
  90. </xsl:if>}
  91. </xsl:template>
  92. <xsl:template match="rds:grp">
  93. <xsl:if test="rds:header">
  94. <xsl:for-each select="rds:header/rds:row">
  95. <tr>
  96. <xsl:for-each select="rds:cell">
  97. <xsl:apply-templates mode="printCell" select=".">
  98. <xsl:with-param name="borderkludge">lf</xsl:with-param>
  99. </xsl:apply-templates>
  100. </xsl:for-each>
  101. </tr>
  102. </xsl:for-each>
  103. </xsl:if>
  104. <xsl:for-each select="rds:grp">
  105. <xsl:apply-templates select="."/>
  106. </xsl:for-each>
  107. <xsl:for-each select="rds:row">
  108. <tr>
  109. <xsl:for-each select="rds:cell">
  110. <xsl:apply-templates mode="printCell" select=".">
  111. <xsl:with-param name="borderkludge">lc</xsl:with-param>
  112. </xsl:apply-templates>
  113. </xsl:for-each>
  114. </tr>
  115. </xsl:for-each>
  116. <xsl:if test="rds:footer">
  117. <xsl:for-each select="rds:footer/rds:row">
  118. <tr>
  119. <xsl:for-each select="rds:cell">
  120. <xsl:apply-templates mode="printCell" select=".">
  121. <xsl:with-param name="borderkludge">lf</xsl:with-param>
  122. </xsl:apply-templates>
  123. </xsl:for-each>
  124. </tr>
  125. </xsl:for-each>
  126. </xsl:if>
  127. </xsl:template>
  128. <xsl:template match="rds:lst">
  129. <table style="border-collapse: collapse; font-family:Tahoma" cellpadding="0">
  130. <xsl:attribute name="class"><xsl:value-of select="concat($fragprefix,rds:style)"/></xsl:attribute>
  131. <xsl:if test="rds:id">
  132. <xsl:attribute name="id"><xsl:value-of select="rds:id"/></xsl:attribute>
  133. </xsl:if>
  134. <tr>
  135. <xsl:for-each select="rds:colTitle">
  136. <xsl:apply-templates mode="printCell" select=".">
  137. <xsl:with-param name="borderkludge">lt</xsl:with-param>
  138. </xsl:apply-templates>
  139. </xsl:for-each>
  140. </tr>
  141. <xsl:if test="rds:group/rds:header">
  142. <xsl:for-each select="rds:group/rds:header/rds:row">
  143. <tr>
  144. <xsl:for-each select="rds:cell">
  145. <xsl:apply-templates mode="printCell" select=".">
  146. <xsl:with-param name="borderkludge">lf</xsl:with-param>
  147. </xsl:apply-templates>
  148. </xsl:for-each>
  149. </tr>
  150. </xsl:for-each>
  151. </xsl:if>
  152. <xsl:for-each select="rds:group/rds:grp">
  153. <xsl:apply-templates select="."/>
  154. </xsl:for-each>
  155. <xsl:for-each select="rds:group/rds:row">
  156. <tr>
  157. <xsl:for-each select="rds:cell">
  158. <xsl:apply-templates mode="printCell" select=".">
  159. <xsl:with-param name="borderkludge">lc</xsl:with-param>
  160. </xsl:apply-templates>
  161. </xsl:for-each>
  162. </tr>
  163. </xsl:for-each>
  164. <xsl:if test="rds:group/rds:footer">
  165. <xsl:for-each select="rds:group/rds:footer/rds:row">
  166. <tr>
  167. <xsl:for-each select="rds:cell">
  168. <xsl:apply-templates mode="printCell" select=".">
  169. <xsl:with-param name="borderkludge">lf</xsl:with-param>
  170. </xsl:apply-templates>
  171. </xsl:for-each>
  172. </tr>
  173. </xsl:for-each>
  174. </xsl:if>
  175. </table>
  176. </xsl:template>
  177. <xsl:template match="rds:ctab">
  178. <table style="border-collapse: collapse; font-family:Tahoma" cellpadding="0">
  179. <xsl:variable name="kludgeRowIndex">
  180. <xsl:value-of select="rds:row[1]/rds:start"/>
  181. </xsl:variable>
  182. <xsl:attribute name="class"><xsl:value-of select="concat($fragprefix,rds:style)"/></xsl:attribute>
  183. <xsl:if test="rds:id">
  184. <xsl:attribute name="id"><xsl:value-of select="rds:id"/></xsl:attribute>
  185. </xsl:if>
  186. <tr>
  187. <xsl:apply-templates mode="printCell" select="rds:corner">
  188. <xsl:with-param name="borderkludge">xm</xsl:with-param>
  189. </xsl:apply-templates>
  190. <xsl:for-each select="rds:column">
  191. <xsl:apply-templates mode="printCell" select="rds:name">
  192. <xsl:with-param name="borderkludge">ml</xsl:with-param>
  193. </xsl:apply-templates>
  194. </xsl:for-each>
  195. </tr>
  196. <xsl:if test="rds:column[1]/rds:nestedDimension">
  197. <tr>
  198. <xsl:for-each select="rds:column/rds:nestedDimension">
  199. <xsl:apply-templates mode="printCell" select="rds:name">
  200. <xsl:with-param name="borderkludge">ml</xsl:with-param>
  201. </xsl:apply-templates>
  202. </xsl:for-each>
  203. </tr>
  204. </xsl:if>
  205. <xsl:if test="rds:column[1]/rds:nestedDimension[1]/rds:nestedDimension">
  206. <tr>
  207. <xsl:for-each select="rds:column/rds:nestedDimension/rds:nestedDimension">
  208. <xsl:apply-templates mode="printCell" select="rds:name">
  209. <xsl:with-param name="borderkludge">ml</xsl:with-param>
  210. </xsl:apply-templates>
  211. </xsl:for-each>
  212. </tr>
  213. </xsl:if>
  214. <xsl:for-each select="rds:row">
  215. <xsl:if test="count( rds:nestedDimension) = 0">
  216. <tr>
  217. <xsl:apply-templates mode="printCell" select="rds:name">
  218. <xsl:with-param name="borderkludge">ml</xsl:with-param>
  219. </xsl:apply-templates>
  220. <xsl:variable name="rownum">
  221. <xsl:value-of select="rds:start - $kludgeRowIndex+ 1"/>
  222. </xsl:variable>
  223. <xsl:apply-templates select="../rds:table/rds:row[position() = $rownum]"/>
  224. </tr>
  225. </xsl:if>
  226. <xsl:for-each select="rds:nestedDimension">
  227. <tr>
  228. <xsl:if test="position() = 1">
  229. <xsl:apply-templates mode="printCell" select="../rds:name">
  230. <xsl:with-param name="borderkludge">ml</xsl:with-param>
  231. </xsl:apply-templates>
  232. </xsl:if>
  233. <xsl:apply-templates mode="printCell" select="rds:name">
  234. <xsl:with-param name="borderkludge">ml</xsl:with-param>
  235. </xsl:apply-templates>
  236. <xsl:variable name="rownum">
  237. <xsl:value-of select="rds:start - $kludgeRowIndex+ 1"/>
  238. </xsl:variable>
  239. <xsl:apply-templates select="../../rds:table/rds:row[position() = $rownum]"/>
  240. </tr>
  241. </xsl:for-each>
  242. </xsl:for-each>
  243. </table>
  244. </xsl:template>
  245. <xsl:template match="rds:row">
  246. <xsl:for-each select="rds:cell">
  247. <xsl:apply-templates mode="printCell" select=".">
  248. <xsl:with-param name="borderkludge">ml</xsl:with-param>
  249. </xsl:apply-templates>
  250. </xsl:for-each>
  251. </xsl:template>
  252. <xsl:template mode="printCell" match="*">
  253. <xsl:param name="borderkludge">none</xsl:param>
  254. <!-- border kludge until RSVP fix starts tellign us about the borders -->
  255. <td>
  256. <xsl:choose>
  257. <xsl:when test="$borderkludge = 'lt'">
  258. <xsl:attribute name="style">border: 1px solid #608BB4;</xsl:attribute>
  259. </xsl:when>
  260. <xsl:when test="$borderkludge = 'lf'">
  261. <xsl:attribute name="style">border: 1px solid #CCCCCC;</xsl:attribute>
  262. </xsl:when>
  263. <xsl:when test="$borderkludge = 'lc'">
  264. <xsl:attribute name="style">border: 1px solid #CCCCCC;</xsl:attribute>
  265. </xsl:when>
  266. <xsl:when test="$borderkludge = 'xm'">
  267. <xsl:attribute name="style">border: 1px solid #CFCFCF;</xsl:attribute>
  268. </xsl:when>
  269. <xsl:when test="$borderkludge = 'ml'">
  270. <xsl:attribute name="style">border: 1px solid #93B1CD;</xsl:attribute>
  271. </xsl:when>
  272. <xsl:when test="$borderkludge = 'mv'">
  273. <xsl:attribute name="style">border: 1px solid #CCCCCC;</xsl:attribute>
  274. </xsl:when>
  275. </xsl:choose>
  276. <xsl:if test="rds:rspan">
  277. <xsl:attribute name="rowspan"><xsl:value-of select="rds:rspan"/></xsl:attribute>
  278. </xsl:if>
  279. <xsl:if test="rds:cspan">
  280. <xsl:attribute name="colspan"><xsl:value-of select="rds:cspan"/></xsl:attribute>
  281. </xsl:if>
  282. <xsl:attribute name="class"><xsl:value-of select="concat($fragprefix,rds:style)"/></xsl:attribute>
  283. <xsl:apply-templates select="rds:item/*"/>
  284. </td>
  285. </xsl:template>
  286. <xsl:template match="rds:txt">
  287. <span>
  288. <xsl:if test="rds:id">
  289. <xsl:attribute name="id"><xsl:value-of select="rds:id"/></xsl:attribute>
  290. </xsl:if>
  291. <xsl:attribute name="class"><xsl:value-of select="concat($fragprefix,rds:style)"/></xsl:attribute>
  292. <xsl:choose>
  293. <xsl:when test="rds:fmtVal">
  294. <xsl:value-of select="rds:fmtVal"/>
  295. </xsl:when>
  296. <xsl:otherwise>
  297. <xsl:value-of select="rds:val"/>
  298. </xsl:otherwise>
  299. </xsl:choose>
  300. </span>
  301. </xsl:template>
  302. <xsl:template match="rds:img">
  303. <img>
  304. <xsl:if test="rds:id">
  305. <xsl:attribute name="id"><xsl:value-of select="rds:id"/></xsl:attribute>
  306. </xsl:if>
  307. <xsl:attribute name="src"><xsl:value-of select="rds:url"/></xsl:attribute>
  308. </img>
  309. </xsl:template>
  310. <xsl:template match="rds:cht">
  311. <img>
  312. <xsl:if test="rds:id">
  313. <xsl:attribute name="id"><xsl:value-of select="rds:id"/></xsl:attribute>
  314. </xsl:if>
  315. <xsl:variable name="url">
  316. <xsl:value-of select="translate(rds:url,$quot, $apos)"/>
  317. </xsl:variable>
  318. <xsl:choose>
  319. <xsl:when test="string-length($versionbase) &gt; 0">
  320. <xsl:attribute name="src"><xsl:value-of select="concat($versionbase,'/',$url)"/></xsl:attribute>
  321. </xsl:when>
  322. <xsl:otherwise>
  323. <xsl:attribute name="src"><xsl:value-of select="$url"/></xsl:attribute>
  324. </xsl:otherwise>
  325. </xsl:choose>
  326. </img>
  327. </xsl:template>
  328. <xsl:template match="rds:page">
  329. <table>
  330. <xsl:if test="rds:id">
  331. <xsl:attribute name="id"><xsl:value-of select="rds:id"/></xsl:attribute>
  332. </xsl:if>
  333. <tr>
  334. <xsl:apply-templates select="rds:header/rds:item/*"/>
  335. </tr>
  336. <tr>
  337. <xsl:apply-templates select="rds:body/rds:item/*"/>
  338. </tr>
  339. <tr>
  340. <xsl:apply-templates select="rds:footer/rds:item/*"/>
  341. </tr>
  342. </table>
  343. </xsl:template>
  344. <xsl:template mode="printColor" match="*">rgb(<xsl:value-of select="rds:Red"/>,<xsl:value-of select="rds:Green"/>,<xsl:value-of select="rds:Blue"/>)</xsl:template>
  345. </xsl:stylesheet>