RSUpgradeChartLabel.xsl 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. *
  13. * Intermediate stage in upgrading from a baltic report specification
  14. * to a bering report specification.
  15. *
  16. * Remove custom charrt labels where they are not needed.
  17. -->
  18. <xsl:stylesheet version="1.0" xmlns="http://developer.cognos.com/schemas/report/2.0/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:baltic="http://developer.cognos.com/schemas/report/1/" xmlns:bering="http://developer.cognos.com/schemas/report/2.0/" xmlns:date="http://exslt.org/dates-and-times" xmlns:exsl="http://exslt.org/common" xmlns:xalan="http://xml.apache.org/xalan" xmlns:java="http://xml.apache.org/xalan/java" extension-element-prefixes="xalan date exsl" exclude-result-prefixes="xalan java baltic date exsl">
  19. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" xalan:indent-amount="2" omit-xml-declaration="yes"/>
  20. <!--
  21. * Remove customm chart labels that are not needed.
  22. * trakker 554269 Chart Custom Label in no longer generated in appropriate way.
  23. * -->
  24. <xsl:template match="node()[@refDataItem]">
  25. <xsl:variable name="v_dataItem" select="@refDataItem"/>
  26. <xsl:copy>
  27. <xsl:apply-templates select="@*"/>
  28. <xsl:apply-templates select="text()"/>
  29. <xsl:for-each select="./node()">
  30. <xsl:choose>
  31. <xsl:when test="local-name() = 'chartLabel'">
  32. <xsl:variable name="v_soleNode">
  33. <xsl:call-template name="soleDescendant">
  34. <xsl:with-param name="ancestor" select="."/>
  35. <xsl:with-param name="descendant" select="./bering:chartContents/bering:chartTextItem/bering:dataSource/bering:dataItemLabel[@refDataItem=$v_dataItem] "/>
  36. </xsl:call-template>
  37. </xsl:variable>
  38. <xsl:choose>
  39. <xsl:when test="$v_soleNode='1'">
  40. <!-- Ignore the default chart label -->
  41. </xsl:when>
  42. <xsl:otherwise>
  43. <xsl:call-template name="copy"/>
  44. </xsl:otherwise>
  45. </xsl:choose>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <xsl:call-template name="copy"/>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. </xsl:for-each>
  52. </xsl:copy>
  53. </xsl:template>
  54. <!-- Copy anything that is unmatched over to output. -->
  55. <xsl:template match="@*|node()|text()|comment()">
  56. <xsl:copy>
  57. <xsl:apply-templates select="@*|node()|text()|comment()"/>
  58. </xsl:copy>
  59. </xsl:template>
  60. <!-- copy over the object and apply the templates to the children. -->
  61. <xsl:template name="copy">
  62. <xsl:copy>
  63. <xsl:apply-templates select="@*"/>
  64. <xsl:apply-templates select="node()|text()|comment()"/>
  65. </xsl:copy>
  66. </xsl:template>
  67. <!-- Check if a node is the only descendant of another node, -->
  68. <xsl:template name="soleDescendant">
  69. <xsl:param name="ancestor"/>
  70. <xsl:param name="descendant"/>
  71. <xsl:choose>
  72. <xsl:when test="count($descendant)!=1">0</xsl:when>
  73. <xsl:when test="$ancestor=$descendant">1</xsl:when>
  74. <xsl:otherwise>
  75. <xsl:variable name="parent" select="$descendant/.."/>
  76. <xsl:choose>
  77. <xsl:when test="count($parent/node())=1">
  78. <xsl:call-template name="soleDescendant">
  79. <xsl:with-param name="ancestor" select="$ancestor"/>
  80. <xsl:with-param name="descendant" select="$parent"/>
  81. </xsl:call-template>
  82. </xsl:when>
  83. <xsl:otherwise>0</xsl:otherwise>
  84. </xsl:choose>
  85. </xsl:otherwise>
  86. </xsl:choose>
  87. </xsl:template>
  88. </xsl:stylesheet>