xform_53to54.xsl 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 53 to 54 Notes:
  12. This is an XSLT transformation from a Bering schema version 53 model to a Bering
  13. schema version 54 model.
  14. This Upgrade is required to accomodate the following Model Schema changes.
  15. Steps:
  16. ======
  17. 1. Levelcuts will be removed.
  18. This was added to support convergent levels. This feature has been removed for
  19. Bering and it's been decided that we will use a different approach. This is an interim
  20. step simply to keep valid those few models out there that have levelShortcuts
  21. NOTE: The levelShortcut was never implemented by the query engines.
  22. 2. New Roles property will replace existing query item role and roleName properties.
  23. This upgrade is only for internal use. Existing role properties with a value 'caption'
  24. will be converted to the new role property format. The new role value will be set
  25. to '_memberCaption'
  26. All other roles will be deleted. NOTE: The role property is defined in the
  27. BmtModelBehaviour.xsl file as a multi-lingual string.
  28. <xsd:element name="roles" minOccurs="0">
  29. <xsd:complexType>
  30. <xsd:sequence>
  31. <xsd:element name="role" maxOccurs="unbounded">
  32. <xsd:complexType>
  33. <xsd:simpleContent>
  34. <xsd:extension base="xsd:string">
  35. <xsd:attribute name="locale" type="xsd:language" use="required"/>
  36. </xsd:extension>
  37. </xsd:simpleContent>
  38. </xsd:complexType>
  39. </xsd:element>
  40. </xsd:sequence>
  41. </xsd:complexType>
  42. </xsd:element>
  43. 3. Rename dimensions property to hierarchies
  44. Add new property under calculation object called datasources (no upgrade is required).
  45. Also under calculations rename dimensions property to hierarchies.
  46. NOTE: Change requested by OP.
  47. 4. Empty maxVersions elements will be removed.
  48. Packages which are published with versioning turned off previously resulted in an
  49. empty element which would break schema validation.
  50. ============================================================================================ -->
  51. <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/54/0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  52. <xsl:include href="fmmd_generalTemplates.xsl"/>
  53. <xsl:strip-space elements="*"/>
  54. <xsl:output encoding="utf-8" method="xml" indent="no"/>
  55. <!-- ============================================================================================ -->
  56. <!-- Step #1: LevelShortcuts will be removed. -->
  57. <!-- Template: Delete any existing levelShortcut -->
  58. <xsl:template match="*[local-name()='levelShortcut']"/>
  59. <!-- ============================================================================================ -->
  60. <!-- Step #2: New Roles property will replace existing query item role and roleName properties -->
  61. <!-- Template: Delete any existing queryItem role -->
  62. <xsl:template match="*[local-name()='queryItem']/*[local-name()='role']"/>
  63. <!-- Template: Create new 'roles' property -->
  64. <xsl:template match="*[local-name()='queryItem' and *[local-name()='role' and .='caption']]">
  65. <xsl:variable name="roles">
  66. <xsl:element name="roles">
  67. <xsl:element name="role"><xsl:attribute name="locale"><xsl:value-of select="/*[local-name()='project']/*[local-name()='defaultLocale']"/></xsl:attribute>_memberCaption</xsl:element>
  68. </xsl:element>
  69. </xsl:variable>
  70. <!-- A <roles> group must be inserted before the collation properties-->
  71. <xsl:element name="queryItem">
  72. <xsl:call-template name="myCopyAttributes"/>
  73. <xsl:for-each select="node()">
  74. <xsl:choose>
  75. <xsl:when test="*[local-name()='collationSequenceName']">
  76. <xsl:copy-of select="$roles"/>
  77. <xsl:call-template name="myCopy"/>
  78. </xsl:when>
  79. <xsl:when test="*[local-name()='collationSequenceLevel'] and not(../*[local-name()='collationSequenceName'])">
  80. <xsl:copy-of select="$roles"/>
  81. <xsl:call-template name="myCopy"/>
  82. </xsl:when>
  83. <xsl:when test="*[local-name()='originalCollationSequenceName'] and not(../*[local-name()='collationSequenceLevel']) and not(../*[local-name()='collationSequenceName'])">
  84. <xsl:copy-of select="$roles"/>
  85. <xsl:call-template name="myCopy"/>
  86. </xsl:when>
  87. <xsl:when test="*[local-name()='originalEncodingName'] and not(../*[local-name()='originalCollationSequenceName']) and not(../*[local-name()='collationSequenceLevel']) and not(../*[local-name()='collationSequenceName'])">
  88. <xsl:copy-of select="$roles"/>
  89. <xsl:call-template name="myCopy"/>
  90. </xsl:when>
  91. <xsl:when test="position() = last()">
  92. <xsl:apply-templates select="."/>
  93. <xsl:copy-of select="$roles"/>
  94. </xsl:when>
  95. <xsl:otherwise>
  96. <xsl:apply-templates select="."/>
  97. </xsl:otherwise>
  98. </xsl:choose>
  99. </xsl:for-each>
  100. </xsl:element>
  101. </xsl:template>
  102. <!-- ============================================================================================ -->
  103. <!-- Step #3: Rename dimensions property to hierarchies. -->
  104. <!-- Template: Rename the dimension property -->
  105. <xsl:template match="*[local-name()='calculation']/*[local-name()='dimensions']">
  106. <xsl:call-template name="myCopy">
  107. <xsl:with-param name="elemName">hierarchies</xsl:with-param>
  108. </xsl:call-template>
  109. </xsl:template>
  110. <!-- ============================================================================================ -->
  111. <!-- Step #4: Empty maxVersions elements will be removed. -->
  112. <!-- Template: Delete in the packages/package any empty <maxVersions/> elements -->
  113. <xsl:template match="*[local-name()='packages']/*[local-name()='package']/*[local-name()='maxVersions' and . = '']"/>
  114. <!-- ============================================================================================ -->
  115. <!-- Global variables: -->
  116. <!-- ============================================================================================ -->
  117. <xsl:variable name="sEmptyNamespace" select="string(document('')/*/namespace::*[name()=''])"/>
  118. <xsl:variable name="nNewSchema" select="number(substring-before(substring-after($sEmptyNamespace, 'http://www.developer.cognos.com/schemas/bmt/'), '/'))"/>
  119. <xsl:variable name="nOldSchema" select="$nNewSchema - 1"/>
  120. </xsl:stylesheet>