xform_57to58.xsl 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: fmmd
  5. (C) Copyright IBM Corp. 2003, 2013
  6. US Government Users Restricted Rights - Use, duplication or disclosure
  7. restricted by GSA ADP Schedule Contract with IBM Corp.
  8. -->
  9. <!--
  10. ===============================================================================
  11. Model Upgrade 57 to 58 Notes:
  12. This is an XSLT transformation from a Bering schema version 57 model to a Bering
  13. schema version 58 model
  14. This Upgrade is required to accomodate the following Model Schema changes made in Bering:
  15. * Semi-aggregate, regular aggregate and aggregationRule properties values have now
  16. been unified into a common single set of values. For relational and SAP models
  17. all deprecated enums will be mapped to unknown. Lightweight model sources are
  18. unaffected because the model is imported on demand.
  19. The following aggregate values will be deprecated and replaced with 'unknown'
  20. - any
  21. - averageNonZero
  22. - countNonZero
  23. - external
  24. - currentPeriod
  25. - firstPeriod
  26. - lastPeriod
  27. ===============================================================================
  28. -->
  29. <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/58/0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fmfunc="http://www.developer.cognos.com/bmt" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="fmfunc xalan">
  30. <xsl:include href="fmmd_generalTemplates.xsl"/>
  31. <xsl:strip-space elements="*"/>
  32. <xsl:output encoding="utf-8" method="xml" indent="no"/>
  33. <!-- =============================================================================== -->
  34. <!-- Step 1: Semi-aggregate, regular aggregate and aggregationRule properties values
  35. have now been unified.
  36. -->
  37. <!--
  38. Template: Remove the redundant custom property 'SAPAggregate'
  39. -->
  40. <xsl:template match="*[local-name() = 'queryItem' or local-name() = 'measure']/*[local-name() = 'property' and @*[local-name() = 'name' and . = 'SAPAggregate']]"/>
  41. <!--
  42. Template: Map the deprecated aggregate values
  43. -->
  44. <xsl:template match="*[local-name() = 'queryItem' or local-name() = 'measure']/*[local-name() = 'aggregationRule' or local-name() = 'regularAggregate' or local-name() = 'semiAggregate']/text()">
  45. <xsl:choose>
  46. <xsl:when test=". = 'any'">unknown</xsl:when>
  47. <xsl:when test=". = 'averageNonZero'">unknown</xsl:when>
  48. <xsl:when test=". = 'external'">unknown</xsl:when>
  49. <xsl:when test=". = 'currentPeriod'">unknown</xsl:when>
  50. <xsl:when test=". = 'firstPeriod'">unknown</xsl:when>
  51. <xsl:when test=". = 'lastPeriod'">unknown</xsl:when>
  52. <xsl:when test=". = 'countNonZero'">
  53. <!-- countNonZero was wrong for SAPBW Bering models -->
  54. <xsl:choose>
  55. <xsl:when test="ancestor::*[local-name() = 'querySubject' or local-name() = 'dimension'][1][*[local-name() = 'definition']/*[local-name() = 'mdQuery']]">unknown</xsl:when>
  56. <xsl:otherwise>
  57. <xsl:copy/>
  58. </xsl:otherwise>
  59. </xsl:choose>
  60. </xsl:when>
  61. <xsl:otherwise>
  62. <xsl:copy/>
  63. </xsl:otherwise>
  64. </xsl:choose>
  65. </xsl:template>
  66. <!-- WO #1678-->
  67. <!-- NOTE: The property name "SAP BW Variables" is hard coded and not localized-->
  68. <xsl:template match="*[local-name()='dataSource']/*[local-name()='property' and @*[local-name()='name' and .='SAP BW Variables']]/*/*[local-name()='property' and @*[local-name()='name' and .='type']]">
  69. <xsl:variable name="varType" select="."/>
  70. <xsl:choose>
  71. <xsl:when test="$varType = 'characteristic' or $varType = 'hierarchicalNode'">
  72. <xsl:call-template name="myCopy"/>
  73. <xsl:element name="property">
  74. <xsl:attribute name="name">showKeyAndCaption</xsl:attribute>
  75. <xsl:attribute name="type">boolean</xsl:attribute>
  76. <xsl:value-of select="'false'"/>
  77. </xsl:element>
  78. </xsl:when>
  79. <xsl:otherwise>
  80. <xsl:call-template name="myCopy"/>
  81. </xsl:otherwise>
  82. </xsl:choose>
  83. </xsl:template>
  84. <!-- =============================================================================== -->
  85. <!-- Global variables: -->
  86. <!-- =============================================================================== -->
  87. <xsl:variable name="sEmptyNamespace" select="string(document('')/*/namespace::*[name()=''])"/>
  88. <xsl:variable name="nNewSchema" select="number(substring-before(substring-after($sEmptyNamespace, 'http://www.developer.cognos.com/schemas/bmt/'), '/'))"/>
  89. <xsl:variable name="nOldSchema" select="$nNewSchema - 1"/>
  90. </xsl:stylesheet>