RSUpgradeResultSetSqueleton.xsl 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: rspecupgrade
  5. (C) Copyright IBM Corp. 2005, 2010
  6. US Government Users Restricted Rights - Use, duplication or disclosure
  7. restricted by GSA ADP Schedule Contract with IBM Corp.
  8. -->
  9. <!-- COPYRIGHT_DATA { 'YEAR':[2005, 2009], 'RELEASE':['colorado_wave1'], 'VISIBLE':'YES', 'COMPONENT':'rspecupgrade' }-->
  10. <!--All lines above the COPYRIGHT_DATA line will be replaced when copyright notices are generated. -->
  11. <!--
  12. * This stylesheet generates a squeleton of V5 QRD from a V5 Report Specification.
  13. * The QRD squeleton describes the structure of the report, down to the valueSet element.
  14. * This QRD is intended to be used for the implementation of WO1713 and WO1730.
  15. * QFW upgrades the query based on an analysis of the queries and structure of the queryResultDefinitions.
  16. *
  17. * NOTE: WO1713 and WO1730 only apply to crosstabs, so the QRD generation rules here are only implemented for crosstabs.
  18. *
  19. -->
  20. <xsl:stylesheet version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:v5="http://developer.cognos.com/schemas/report/2.0/" xmlns="http://developer.cognos.com/schemas/report/2.0/" exclude-result-prefixes="xsl fo xs">
  21. <xsl:output method="xml" encoding="utf-8"/>
  22. <!-- ================================================================================= -->
  23. <!-- Document Definition -->
  24. <xsl:template match="/">
  25. <xsl:apply-templates select="v5:report"/>
  26. </xsl:template>
  27. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  28. <xsl:template match="v5:report">
  29. <querySet>
  30. <xsl:apply-templates select="v5:modelPath"/>
  31. <xsl:apply-templates select="v5:queries"/>
  32. <queryResultDefinitions>
  33. <xsl:apply-templates select="v5:layouts"/>
  34. </queryResultDefinitions>
  35. </querySet>
  36. </xsl:template>
  37. <!-- ================================================================================= -->
  38. <!-- Build queryResultDefinition from layout -->
  39. <xsl:template match="v5:layout">
  40. <xsl:apply-templates select=".//v5:crosstab"/>
  41. </xsl:template>
  42. <!-- ================================================================================= -->
  43. <!-- Build crosstabResult from crosstab layout -->
  44. <xsl:template match="v5:crosstab">
  45. <queryResultDefinition name="{name()}: {@refQuery}" refQuery="{@refQuery}">
  46. <edges>
  47. <xsl:apply-templates select=".//v5:crosstabColumns"/>
  48. <xsl:apply-templates select=".//v5:crosstabRows"/>
  49. <xsl:apply-templates select=".//v5:defaultMeasure"/>
  50. </edges>
  51. </queryResultDefinition>
  52. </xsl:template>
  53. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  54. <xsl:template match="v5:crosstabColumns">
  55. <xsl:variable name="edgeName"><xsl:value-of select="generate-id(.)"/></xsl:variable>
  56. <edge edgeID="1" name="{$edgeName}">
  57. <edgeGroups>
  58. <xsl:apply-templates select="v5:crosstabNode"/>
  59. </edgeGroups>
  60. </edge>
  61. </xsl:template>
  62. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  63. <xsl:template match="v5:crosstabRows">
  64. <xsl:variable name="edgeName"><xsl:value-of select="generate-id(.)"/></xsl:variable>
  65. <edge edgeID="2" name="{$edgeName}">
  66. <edgeGroups>
  67. <xsl:apply-templates select="v5:crosstabNode"/>
  68. </edgeGroups>
  69. </edge>
  70. </xsl:template>
  71. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  72. <xsl:template match="v5:defaultMeasure">
  73. <xsl:variable name="edgeName"><xsl:value-of select="generate-id(.)"/></xsl:variable>
  74. <xsl:variable name="valueSetName"><xsl:value-of select="@name"/></xsl:variable>
  75. <edge edgeID="3" name="{$edgeName}">
  76. <edgeGroups>
  77. <edgeGroup>
  78. <valueSets>
  79. <valueSet name="{$valueSetName}" refDataItem="{@refDataItem}"/>
  80. </valueSets>
  81. </edgeGroup>
  82. </edgeGroups>
  83. </edge>
  84. </xsl:template>
  85. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  86. <xsl:template match="v5:crosstabNode">
  87. <edgeGroup>
  88. <xsl:apply-templates select="v5:crosstabNodeMembers"/>
  89. <xsl:apply-templates select="v5:crosstabNestedNodes"/>
  90. </edgeGroup>
  91. </xsl:template>
  92. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  93. <xsl:template match="v5:crosstabNestedNodes">
  94. <edgeGroups>
  95. <xsl:apply-templates select="v5:crosstabNode"/>
  96. </edgeGroups>
  97. </xsl:template>
  98. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  99. <xsl:template match="v5:crosstabNodeMembers">
  100. <valueSets>
  101. <xsl:apply-templates select="v5:crosstabNodeMember"/>
  102. </valueSets>
  103. </xsl:template>
  104. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  105. <xsl:template match="v5:crosstabNodeMember">
  106. <xsl:variable name="refItem" select="@refDataItem"/>
  107. <xsl:variable name="valueSetName"><xsl:value-of select="@name"/></xsl:variable>
  108. <valueSet name="{$valueSetName}" refDataItem="{$refItem}"/>
  109. </xsl:template>
  110. <!-- ================================================================================= -->
  111. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  112. <!-- Copy all nodes and attributes by default. -->
  113. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  114. <xsl:template match="@*|node()">
  115. <xsl:copy>
  116. <xsl:apply-templates select="@*|node()"/>
  117. </xsl:copy>
  118. </xsl:template>
  119. </xsl:stylesheet>