xform_56to57.xsl 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 56 to 57 Notes:
  12. This is an XSLT transformation from a Bering schema version 56 model to a Bering
  13. schema version 57 model.
  14. This Upgrade is required to accomodate the following Model Schema changes.
  15. * Step 1: The ALL level for hierarchies contained in relational-based dimensions.
  16. ============================================================================================ -->
  17. <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/57/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" exclude-result-prefixes="fmfunc">
  18. <xsl:include href="fmmd_generalTemplates.xsl"/>
  19. <xsl:strip-space elements="*"/>
  20. <xsl:output encoding="utf-8" method="xml" indent="no"/>
  21. <!-- =============================================================================== -->
  22. <!-- Step 1: Create the ALL level for hierarchies contained in relational-based dimensions
  23. The ALL level will always be be the first level in the hierarchy. It does
  24. not support reorder or cut/copy/paste/delete operations. It can be
  25. renamed - however when renaming, the “rootCaption” property of
  26. the parent hierarchy should be updated to reflect the change
  27. The specific XML will look like the following example:
  28. <hierarchy>
  29. <name locale="en-us">COUNTRY</name>
  30. <lastChanged>2005-06-07T15:08:21</lastChanged>
  31. <level>
  32. <name locale="en-us">COUNTRY(All)</name>
  33. <isManual>true</isManual>
  34. </level>
  35. <level>
  36. <name locale="en-us">COUNTRY</name>
  37. <queryItem>
  38. </queryItem>
  39. </level>
  40. <multiRoot>false</multiRoot>
  41. <rootMUN>[all]</rootMUN>
  42. <rootCaption locale="en-us">COUNTRY(All)</rootCaption>
  43. </hierarchy>
  44. The name of the “ALL level” is going to be the name of the parent hierarchy with the suffix (all)
  45. The following properties are going to be created:
  46. * The level property “isManual” property should be set to “true” for the “All level”.
  47. The property tells the system that the object (the level) does not correspond to
  48. the database, and does not participate in database related operations - synchronization,
  49. tests. The property is used internally to indicate the special object “All level”.
  50. * The hierarchy property "multiRoot" should be removed from the model (ie. set to false) when the “All level” exists.
  51. * The hierarchy property "rootCaption" should initially be set (and updated after) to the same name as the “All level”.
  52. * The hierarchy property "rootMUN" should also be set to the member unique name
  53. of the artificial root member.
  54. -->
  55. <!--
  56. Template: Create the ALL level for all hierarchy contained in relational dimensions.
  57. -->
  58. <xsl:template match="*[local-name()='namespace']//*[local-name()='dimension' and *[local-name()='definition']/*[local-name()='dbQuery' or local-name()='modelQuery']]/*[local-name()='hierarchy']">
  59. <xsl:element name="{local-name(.)}">
  60. <xsl:variable name="Level1Anchor" select="generate-id(./*[local-name()='level'][1])"/>
  61. <xsl:variable name="rootMUNAnchor" select="generate-id(./*[local-name()='level' or local-name()='balanced' or local-name()='ragged'][last()])"/>
  62. <xsl:for-each select="./*">
  63. <xsl:variable name="currentHierarchyProperty" select="generate-id(.)"/>
  64. <xsl:if test="$currentHierarchyProperty = $Level1Anchor">
  65. <!-- Insert the ALL level -->
  66. <xsl:element name="level">
  67. <!-- For each localized hierarchy name found, create a corresponding name for the ALL level by appending the localized string "(All)" to it -->
  68. <xsl:for-each select="ancestor::*[local-name()='hierarchy'][1]/*[local-name()='name']">
  69. <xsl:element name="name">
  70. <xsl:attribute name="locale"><xsl:value-of select="@*[local-name()='locale']"/></xsl:attribute>
  71. <xsl:value-of select="concat(., $strLevelAll)"/>
  72. </xsl:element>
  73. </xsl:for-each>
  74. <xsl:element name="isManual">true</xsl:element>
  75. </xsl:element>
  76. </xsl:if>
  77. <!-- Copy over the old property except if it's multiRoot -->
  78. <xsl:if test="local-name(.) != 'multiRoot'">
  79. <xsl:apply-templates select="."/>
  80. </xsl:if>
  81. <!-- Insert into the hierarchy the properties for the ALL level" -->
  82. <xsl:if test="$currentHierarchyProperty = $rootMUNAnchor">
  83. <!-- Insert the property for rootMun -->
  84. <xsl:element name="rootMUN">[all]</xsl:element>
  85. <!-- Insert the properties for rootCaption -->
  86. <!-- For each localized hierarchy name found, create a corresponding name for the ALL level by appending the localized string "(All)" to it -->
  87. <xsl:for-each select="ancestor::*[local-name()='hierarchy'][1]/*[local-name()='name']">
  88. <xsl:element name="rootCaption">
  89. <xsl:attribute name="locale"><xsl:value-of select="@*[local-name()='locale']"/></xsl:attribute>
  90. <xsl:value-of select="concat(., $strLevelAll)"/>
  91. </xsl:element>
  92. </xsl:for-each>
  93. </xsl:if>
  94. </xsl:for-each>
  95. </xsl:element>
  96. </xsl:template>
  97. <!-- Globlal variables-->
  98. <xsl:variable name="sEmptyNamespace" select="string(document('')/*/namespace::*[name()=''])"/>
  99. <xsl:variable name="nNewSchema" select="number(substring-before(substring-after($sEmptyNamespace, 'http://www.developer.cognos.com/schemas/bmt/'), '/'))"/>
  100. <xsl:variable name="nOldSchema" select="$nNewSchema - 1"/>
  101. <xsl:variable name="strLevelAll">
  102. <xsl:call-template name="getLocalizedString">
  103. <xsl:with-param name="stringID" select="$LEVEL_ALL"/>
  104. <xsl:with-param name="localeVal" select="$defaultLocale"/>
  105. </xsl:call-template>
  106. </xsl:variable>
  107. </xsl:stylesheet>