csv.xsl 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. BI and PM: qs
  5. (C) Copyright IBM Corp. 2001, 2017
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
  13. <xsl:output method="text"/>
  14. <xsl:strip-space elements="*"/>
  15. <xsl:variable name="show_row_numbers" select="//ListFrame/@rowNumbers='show'"/>
  16. <xsl:template match="/Document">
  17. <xsl:apply-templates select="Title"/>
  18. <xsl:text>&#xa;&#xa;</xsl:text>
  19. <xsl:apply-templates select="CQLayout"/>
  20. <xsl:text>&#xa;</xsl:text>
  21. <xsl:apply-templates select="DATA-MATRIX/DATA"/>
  22. </xsl:template>
  23. <xsl:template match="Title">
  24. <xsl:value-of select="."/>
  25. </xsl:template>
  26. <xsl:template match="ListFrame/ListColumns">
  27. <xsl:if test="$show_row_numbers">
  28. <xsl:text>Row, </xsl:text>
  29. </xsl:if>
  30. <xsl:apply-templates select="GrpColumn | ListColumn"/>
  31. </xsl:template>
  32. <xsl:template match="GrpColumn | ListColumn">
  33. <xsl:value-of select="@title"/>
  34. <xsl:text>, </xsl:text>
  35. </xsl:template>
  36. <xsl:template match="LR">
  37. <xsl:apply-templates select="LR | ROW"/>
  38. </xsl:template>
  39. <xsl:template match="ROW[@type='total']">
  40. <xsl:if test="$show_row_numbers">
  41. <xsl:text>, </xsl:text>
  42. </xsl:if>
  43. <xsl:apply-templates select="TQ"/>
  44. <xsl:text>&#xa;</xsl:text>
  45. </xsl:template>
  46. <xsl:template match="ROW[@type='next'] | ROW[@type='previous']">
  47. <xsl:if test="$show_row_numbers">
  48. <xsl:text>..., </xsl:text>
  49. </xsl:if>
  50. <xsl:apply-templates select="Q"/>
  51. <xsl:text>&#xa;</xsl:text>
  52. </xsl:template>
  53. <xsl:template match="ROW">
  54. <xsl:if test="$show_row_numbers">
  55. <xsl:value-of select="@num"/>
  56. <xsl:text>, </xsl:text>
  57. </xsl:if>
  58. <xsl:for-each select="ancestor::LR">
  59. <xsl:if test="name()='LR'">
  60. <xsl:value-of select="./Q"/>
  61. <xsl:text>, </xsl:text>
  62. </xsl:if>
  63. </xsl:for-each>
  64. <xsl:apply-templates select="Q"/>
  65. <xsl:text>&#xa;</xsl:text>
  66. </xsl:template>
  67. <xsl:template match="Q | TQ">
  68. <xsl:value-of select="."/>
  69. <xsl:text>, </xsl:text>
  70. </xsl:template>
  71. </xsl:stylesheet>