ldx2html.xsl 13 KB

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