123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?xml version="1.0"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: fmmd
- (C) Copyright IBM Corp. 2003, 2013
- US Government Users Restricted Rights - Use, duplication or disclosure
- restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--
- ===============================================================================
- Model Upgrade 56 to 57 Notes:
- This is an XSLT transformation from a Bering schema version 56 model to a Bering
- schema version 57 model.
- This Upgrade is required to accomodate the following Model Schema changes.
- * Step 1: The ALL level for hierarchies contained in relational-based dimensions.
- ============================================================================================ -->
- <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">
- <xsl:include href="fmmd_generalTemplates.xsl"/>
- <xsl:strip-space elements="*"/>
- <xsl:output encoding="utf-8" method="xml" indent="no"/>
- <!-- =============================================================================== -->
- <!-- Step 1: Create the ALL level for hierarchies contained in relational-based dimensions
- The ALL level will always be be the first level in the hierarchy. It does
- not support reorder or cut/copy/paste/delete operations. It can be
- renamed - however when renaming, the “rootCaption” property of
- the parent hierarchy should be updated to reflect the change
- The specific XML will look like the following example:
- <hierarchy>
- <name locale="en-us">COUNTRY</name>
- <lastChanged>2005-06-07T15:08:21</lastChanged>
- <level>
- <name locale="en-us">COUNTRY(All)</name>
- <isManual>true</isManual>
- </level>
- <level>
- <name locale="en-us">COUNTRY</name>
- <queryItem>
- …
- </queryItem>
- </level>
- <multiRoot>false</multiRoot>
- <rootMUN>[all]</rootMUN>
- <rootCaption locale="en-us">COUNTRY(All)</rootCaption>
- </hierarchy>
- The name of the “ALL level” is going to be the name of the parent hierarchy with the suffix (all)
- The following properties are going to be created:
- * The level property “isManual” property should be set to “true” for the “All level”.
- The property tells the system that the object (the level) does not correspond to
- the database, and does not participate in database related operations - synchronization,
- tests. The property is used internally to indicate the special object “All level”.
- * The hierarchy property "multiRoot" should be removed from the model (ie. set to false) when the “All level” exists.
- * The hierarchy property "rootCaption" should initially be set (and updated after) to the same name as the “All level”.
- * The hierarchy property "rootMUN" should also be set to the member unique name
- of the artificial root member.
- -->
- <!--
- Template: Create the ALL level for all hierarchy contained in relational dimensions.
- -->
- <xsl:template match="*[local-name()='namespace']//*[local-name()='dimension' and *[local-name()='definition']/*[local-name()='dbQuery' or local-name()='modelQuery']]/*[local-name()='hierarchy']">
- <xsl:element name="{local-name(.)}">
- <xsl:variable name="Level1Anchor" select="generate-id(./*[local-name()='level'][1])"/>
- <xsl:variable name="rootMUNAnchor" select="generate-id(./*[local-name()='level' or local-name()='balanced' or local-name()='ragged'][last()])"/>
- <xsl:for-each select="./*">
- <xsl:variable name="currentHierarchyProperty" select="generate-id(.)"/>
- <xsl:if test="$currentHierarchyProperty = $Level1Anchor">
- <!-- Insert the ALL level -->
- <xsl:element name="level">
- <!-- For each localized hierarchy name found, create a corresponding name for the ALL level by appending the localized string "(All)" to it -->
- <xsl:for-each select="ancestor::*[local-name()='hierarchy'][1]/*[local-name()='name']">
- <xsl:element name="name">
- <xsl:attribute name="locale"><xsl:value-of select="@*[local-name()='locale']"/></xsl:attribute>
- <xsl:value-of select="concat(., $strLevelAll)"/>
- </xsl:element>
- </xsl:for-each>
- <xsl:element name="isManual">true</xsl:element>
- </xsl:element>
- </xsl:if>
- <!-- Copy over the old property except if it's multiRoot -->
- <xsl:if test="local-name(.) != 'multiRoot'">
- <xsl:apply-templates select="."/>
- </xsl:if>
- <!-- Insert into the hierarchy the properties for the ALL level" -->
- <xsl:if test="$currentHierarchyProperty = $rootMUNAnchor">
- <!-- Insert the property for rootMun -->
- <xsl:element name="rootMUN">[all]</xsl:element>
- <!-- Insert the properties for rootCaption -->
- <!-- For each localized hierarchy name found, create a corresponding name for the ALL level by appending the localized string "(All)" to it -->
- <xsl:for-each select="ancestor::*[local-name()='hierarchy'][1]/*[local-name()='name']">
- <xsl:element name="rootCaption">
- <xsl:attribute name="locale"><xsl:value-of select="@*[local-name()='locale']"/></xsl:attribute>
- <xsl:value-of select="concat(., $strLevelAll)"/>
- </xsl:element>
- </xsl:for-each>
- </xsl:if>
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
- <!-- Globlal variables-->
- <xsl:variable name="sEmptyNamespace" select="string(document('')/*/namespace::*[name()=''])"/>
- <xsl:variable name="nNewSchema" select="number(substring-before(substring-after($sEmptyNamespace, 'http://www.developer.cognos.com/schemas/bmt/'), '/'))"/>
- <xsl:variable name="nOldSchema" select="$nNewSchema - 1"/>
- <xsl:variable name="strLevelAll">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$LEVEL_ALL"/>
- <xsl:with-param name="localeVal" select="$defaultLocale"/>
- </xsl:call-template>
- </xsl:variable>
- </xsl:stylesheet>
|