123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788 |
- <?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 32 to 50 Notes:
- This is an XSLT transformation from a Baltic schema version 32 model to a Bering
- schema version 50 model
- This Upgrade is required to accomodate Model Schema changes made in Bering for
- the following OLAP model objects:
- Dimension, Level, Hierarchy, Measure, and scopeRelationship.
-
- In brief, the following steps describe the transformations being performed.
- Note that most of the steps deal with migrating OLAP information with the
- exception of step 6 which is a small fix for the way the model file was
- originally written out, and doesn't correspond to a change in the
- BmtModelSpecification.xsd
- Steps:
- ======
- 1. Dimension objects
- Dimension objects are Baltic mdQuery Query Subjects having one or more
- levels.
- Measure Dimensions are Query Subjects having a definition 'mdQuery'
- and having all QIs usage set to 'facts' or hidden 'true'.
-
- Query Subjects of type mdQuery are converted to two objects: a Dimension
- object and a modelQuery querySubject with it's queryItems pointing to the
- dimensions' attributes (see Step 7)
- 1.1MR1 Hierarchies and Levels container objects are no longer used, and
- instead their children are simply output directly. Level(s) followed
- by Hierarchy objects must be moved near the end of the dimension, according
- to the schema.
-
- 2. Hierarchy objects
- The content of the Hierarchy element has been reformatted, and is now
- localized.
-
- "defaultHierarchy" is no longer a custom property belonging to the dimension
- and is now a property of the Hierarchy.
-
- 3. Level objects
- The content of Level element has been reformatted, and is now
- localized.
- 1.1MR1 QueryItem(s) pertaining to the particular level are now listed
- inside the level and 1.1MR1 Level attributes no longer exist.
- 4. Dimension Query item objects
- Filter out any query items which are refered to by the
- levels/level/attributes/refobjs and
- levels/level/key/queryItems_collection/refobjs.
-
- 5. Scope Relationship objects
- 1.1MR1 relationships with refobjs pointing to the new Dimensions objects,
- have been changed to "scopeRelationship" objects.
-
- 6. General miscellaneous cleanup.
- 6.1 Fixes for Baltic models which don't follow the BmtModelSpecification.
- BmtModelSpecification.xsd schema.
-
- * Empty security filter definitions must be removed.
-
- * Models using role-based packages, isRoleBased was mistakenly written as
- an element in Framework Manager releases 1.02, 1.1RTM and 1.1HOT. In
- 1.1MR1 it was corrected and switched to an attribute.
-
- NOTE: Previous releases of FM aren't affected since FM searched for the value in
- both locations.
- * upgrade "sql99" attribute to "native". sql99 is no longer supported in Bering.
- 6.2 Remove empty keys from querySubjects
- * Any key which has an empty queryItem collection will be removed because it
- is incomplete and has no meaning.
-
- 7: Convert the mdQuery querySubject to a model querySubject, with all
- queryItems referencing the associated hidden dimension from Step 1
- 8: Legacy dimensional information for Hierarchies and Levels
- Baltic Hierarchies and Levels are always copied as-is. The Baltic
- BmtModelSpecification definitions for these two objects have been carried
- forward for backwards compatibilty reasons, and the content is hidden from
- users. There is no editor in Bering which can update the legacy information.
- When a Baltic model is opened in the Bering studio applications, the model
- is upgraded on the fly. The legacy dimensional information for levels and
- hierarchies is there to preserve Baltic model behaviour in the Bering
- studio applications. When the model is upgraded in Framework Manager, the
- legacy information is flagged during "Verify Model" to be repaired.
- It's considered a best-practice approach to always run "Verify Model" once
- a model has been successfully upgraded in Framework Manager. This is to
- allow the user to make modelling decisions appropriate for their model.
- The legacy information for the individual objects is removed once the
- object has been successfully edited or repaired and the model has been
- saved.
- NOTE: For Baltic mdQuery querySubjects (ie SAPBW), Hierachy and Level
- objects are also upgraded to the equivalent Bering definition. So in
- Bering, the equivalent model querySubject has both the old Baltic and the
- new Bering definition for Hierarchy and Level embedded in it.
- 9: Generate missing localized elements for levels and hierarchies.
- Some localized dimension info properties were not supported in Baltic and
- as a result were not stored in the model.
- Placeholder values are generated using the locale key and the value stored
- in the default locale, for the following hierarchy and level properties:
- name, description and screenTip.
- 10. Hide the Bering dimensions from the published packages
- When upgrading a SAPBW querySubject from Baltic to Bering, a model
- querySubject is created along with a new Bering dimension object, which the
- model querySubject references. The dimension is "hidden" from view, and all
- the user sees is the model querySubject which has all the Baltic properties
- carried forward in Bering.
- This is to preserve any Baltic behaviour the modeler was relying upon, such
- as re-ordering the queryItems which cannot be done with dimensions.
- 11. Translate all locale keys to lowercase
- It seems some models contain a mix of upper and lower case when specifying
- the locale key.
-
- This template converts them all to lowercase going forward, to eliminate any
- possible mismatches due to case. Calls to translate(., $uppercase, $lowercase)
- are now all over this script when referring to a locale-based value
- 12. Governors for Data type Upgrade and Generating default dimensional information
- A) Data type Upgrade
- This upgrade is required to accomodate new data types introduced in Bering
- which affect dbQuery and storedProcedure query subjects.
-
- A number of new data types have been introduced in Bering that were previously
- mapped to other existing data types in Baltic. Framework Manager isn't able
- to differenciate which of the data types in a relational based Batlic model
- are correct or invalid, without connecting to the database to verify them.
- A governor called "enhanced model portability" allows for the creation of model
- query against different databases by ignoring the data types stored in the model.
- This governor is turned on if query subjects requiring this upgrade are found
- to exist in the model. (NOTE: This bypasses the problem but introduces a
- performance penalty. The model should be repaired after the upgrade has been
- completed so that the governor can be turned back off)
- All dbQuery and stored procedure Query Subjects are set to "needs reevaluation"
- during upgrade, and are identified afterwards during the "Upgrade Report" and
- "Verify Model" phase as needing to be repaired.
- Once all affected query subjects have been repaired by the "Verify Model" phase,
- the governor's old value can be restored.
- B) Generate default dimensional information
-
- This upgrade is required to indicate that the query engine should generate
- dynamic dimension info when formulating queries. This is basically the old
- Baltic style query generation.
- Verify Model will flag a warning when generateDynamicDimInfo is set to TRUE.
- 13. Add SAP roles to the levels
- In Bering, roles were added to the schema which impact Baltic SAP levels.
- 14. Convert 3 Part references to 5 part references
- In Bering, roles were added to the schema which impact Baltic SAP levels.
- 15. Set filterItemRef and sortOnRef to the member unique name
- * The key, short name, medium name, and long name properties must
- all set their filterItemRef property to the member unique name of the associated level
- See Trakker 463250, WO 1049
- * a sortOnRef value pointing to the memberUniqueName must be added to all queryItem attributes.
- 16. Add missing Level00 information to unit of measure and currency dimensions.
- In Baltic, support was removed for this information. In Bering, support was
- added back in.
- WARNING! The level00 information is generated based on the level01 information
- in the model. If the SAPBW datasource level00 information has been
- customized, it may not correspond to the generated level00 information.
- 17. SAPBW datasource variables have readonly captions.
- ===============================================================================
- -->
- <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/50/0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="xalan">
- <xsl:include href="fmmd_generalTemplates.xsl"/>
- <xsl:strip-space elements="*"/>
- <xsl:output encoding="utf-8" method="xml" indent="no"/>
- <!-- =============================================================================== -->
- <!-- Step 1: Transform OLAP querySubjects into Dimensions
-
- Convert mdQuery querySubject objects which have either of the following characteristics...
- * at least one level (ie. a regular dimension).
- * all QIs usage set to 'facts' or hidden. (ie. a measure dimension)
- .. to a modelQuery querySubject and a corresponding dimension.
- NOTES:
- * The modelQuery querySubject's queryItems use refObjs expressions to point to the
- corresponding dimension attributes.
- * The dimension object, and the dimension's hierarchy and level objects will be renamed
- with underscores to prevent global naming conflicts.
- * The dimension is to made hidden in the package.
- * The queryItemFolders object is dropped only when creating measure dimensions. In some Baltic models
- there may be folders containing a mix of measures and queryItems objects. Bering now distinguishes
- between a queryItemFolder and a measureFolder and it's impossible to create duplicate folder specifications
- for both types of model objects.
- -->
- <!--
- Template: The querySubject is an mdQuery containing at least one level.
- Create 1) a dimension with 2) a modelQuery querySubject with all queryItems pointing to the dimension.
- -->
- <xsl:template match="*[local-name() = 'querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]][*[local-name() = 'levels' and *[local-name() = 'level']]]">
- <!-- Developer's NOTE: The statement below uses a [1] filter. XSLT always returns the nearest ancestor 1st -->
- <xsl:variable name="querySubject" select="."/>
- <xsl:variable name="namespace_name" select="string($querySubject/ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <!-- Create a modelQuery querySubject -->
- <xsl:apply-templates select="current()" mode="MakeQSwithDimRefs"/>
- <!-- Create a dimension based on the dimension's default hierarchy. In the case where no default hierarchy is specified, the dimension is based on the first alternate hierarchy -->
- <xsl:variable name="IsQSRegularDimension">
- <xsl:call-template name="isRegularDimension">
- <xsl:with-param name="querySubject" select="$querySubject"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:if test="$IsQSRegularDimension = string(true())">
- <xsl:variable name="dimension_name" select="concat($dimensionNamePrefix, $querySubject_name)"/>
- <xsl:element name="dimension">
- <!-- Copy the attributes over to the dimension -->
- <xsl:call-template name="myCopyAttributes"/>
- <!-- Log it -->
- <xsl:call-template name="annotate">
- <!--xsl:with-param name="value" select="concat('Creating dimension from query subject ', $querySubject_name, ' found under namespace:', $namespace_name)"/-->
- <xsl:with-param name="value">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
- <xsl:with-param name="localeVal" select="$defaultLocale"/>
- <xsl:with-param name="string1" select="$OBJECT_TYPE_DIMENSION"/>
- <xsl:with-param name="string2" select="$querySubject_name"/>
- <xsl:with-param name="string3" select="$OBJECT_TYPE_NAMESPACE"/>
- <xsl:with-param name="string4" select="$namespace_name"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- <xsl:for-each select="node()[not(local-name() = 'property' and @*[local-name() = 'name' and .='defaultHierarchy'])][not(local-name() = 'levels' or local-name() = 'hierarchies')]">
- <xsl:choose>
- <xsl:when test="local-name() = 'name'">
- <!-- Change the dimension name so that it's prefixed with an underscore.
- Note: dimension name is localized and all values must be updated -->
- <xsl:element name="name">
- <xsl:call-template name="myCopyAttributes"/>
- <xsl:value-of select="concat($dimensionNamePrefix, node())"/>
- </xsl:element>
- </xsl:when>
- <xsl:when test="local-name() = 'queryItem'">
- <xsl:call-template name="copyDimensionQueryItems"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="." mode="dimQueryItem"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- <!-- Filter out the "hierarchies" container element -->
- <xsl:variable name="dataSourceRef" select="./*[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='sources']/*[local-name()='dataSourceRef']"/>
- <xsl:variable name="dimExternalName" select="$querySubject/*[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension']"/>
- <xsl:variable name="candidates" select="key('candidates_using_dimExternalName_dataSourceRef', concat($dimExternalName,'||', $dataSourceRef))"/>
- <xsl:for-each select="$candidates">
- <xsl:variable name="suggestedName">
- <xsl:value-of select="string(./*[local-name()='name'])"/>
- </xsl:variable>
- <xsl:variable name="candidateSuggestedName" select="$candidates[*[local-name()='name' and . =$suggestedName]]"/>
- <xsl:variable name="candidateName">
- <xsl:choose>
- <xsl:when test="count($candidateSuggestedName) > 1 and
- position() != 1 and
- $candidateSuggestedName[1] != .">
- <xsl:value-of select="concat($suggestedName, '_' , generate-id(.))"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$suggestedName"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <!-- If the 2 nodes are exactly equivalent from a string point of view then do not create another hierarchy-->
- <xsl:if test="$candidateSuggestedName[1] = .">
- <xsl:call-template name="hierarchy">
- <xsl:with-param name="namespace_name" select="$namespace_name"/>
- <xsl:with-param name="dimension_name" select="$dimension_name"/>
- <xsl:with-param name="extName" select="./*[local-name()='hierarchies']/*[local-name()='hierarchy']/*[local-name()='externalName']"/>
- <xsl:with-param name="hierarchy_name" select="$candidateName"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:for-each>
- </xsl:element>
- </xsl:if>
- </xsl:template>
- <!--
- Template: The querySubject is an mdQuery and with all queryItems are either all facts or hidden.
- Create 1) a hidden measure dimension 2) a modelQuery querySubject with all queryItems pointing to the dimension.
- -->
- <xsl:template match="*[local-name() = 'querySubject'][*[local-name() = 'definition']/*[local-name() = 'mdQuery']][.//*[local-name()='queryItem' and not(not(*[local-name()='usage' and .='fact']) and not(*[local-name()='hidden' and .='true']))]]">
- <!-- Developer's NOTE: The statement below uses a [1] filter. XSLT always returns the nearest ancestor 1st -->
- <xsl:variable name="namespace_name" select="string(ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="querySubject_name" select="string(./*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <!-- Create a modelQuery querySubject -->
- <xsl:apply-templates select="current()" mode="MakeQSwithDimRefs"/>
- <!-- Create a hidden measure dimension -->
- <xsl:element name="dimension">
- <!-- Copy the attributes over to the dimension -->
- <xsl:call-template name="myCopyAttributes"/>
- <xsl:call-template name="annotate">
- <!--xsl:with-param name="value" select="concat('Created measure dimension from query subject: ', $querySubject_name, ' found under namespace:' , $namespace_name)"/-->
- <xsl:with-param name="value">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
- <xsl:with-param name="localeVal" select="$defaultLocale"/>
- <xsl:with-param name="string1" select="$OBJECT_TYPE_DIMENSION"/>
- <xsl:with-param name="string2" select="$querySubject_name"/>
- <xsl:with-param name="string3" select="$OBJECT_TYPE_NAMESPACE"/>
- <xsl:with-param name="string4" select="$namespace_name"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- <!-- Change the dimension name so that it's prefixed with an underscore.
- Note: dimension name is localized and all values must be updated -->
- <xsl:for-each select="./*[local-name()='name']">
- <xsl:element name="name">
- <xsl:call-template name="myCopyAttributes"/>
- <xsl:value-of select="concat($dimensionNamePrefix, .)"/>
- </xsl:element>
- </xsl:for-each>
- <!-- Output the non-queryItem elements -->
- <!-- NOTE: The partial filter <local-name()!='name'> prevents the dimension's name from being output a second time. -->
- <xsl:apply-templates select="./*[local-name() != 'name' and local-name() != 'queryItem' and local-name() != 'queryItemFolder']"/>
- <!-- Output the queryItems which are "measure" elements -->
- <!-- NOTE1: queryItems can be nested in a queryItemFolder -->
- <!-- NOTE2: Baltic queryItems & measures can be nested in a queryItemFolder. Since it's impossible to create a Bering measureFolder based on the queryItemFolder without creating a conflict, queryItemFolders for measures are stripped from the model -->
- <xsl:for-each select="key('queryItem_using_qsID', generate-id(.))[*[local-name() = 'usage' and .='fact']]">
- <xsl:call-template name="myCopy">
- <xsl:with-param name="elemName">measure</xsl:with-param>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
- <!-- =============================================================================== -->
- <!-- Step 2: Fix OLAP QS : Fix the hierarchy object -->
- <xsl:template name="hierarchy">
- <xsl:param name="namespace_name"/>
- <xsl:param name="dimension_name"/>
- <xsl:param name="extName"/>
- <xsl:param name="hierarchy_name"/>
-
- <!-- Developer's NOTE: The statements below uses a [1] filter. XSLT always returns the nearest document-ordered ancestor 1st -->
- <xsl:variable name="querySubject" select="."/>
- <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:element name="hierarchy">
- <xsl:call-template name="myCopyAttributes"/>
- <xsl:call-template name="localizeElement">
- <xsl:with-param name="basedOnItem" select="$querySubject"/>
- <xsl:with-param name="elementName" select="'name'"/>
- <xsl:with-param name="defaultValue" select="$hierarchy_name"/>
- </xsl:call-template>
- <xsl:call-template name="localizeElement">
- <xsl:with-param name="basedOnItem" select="$querySubject"/>
- <xsl:with-param name="elementName" select="'description'"/>
- <xsl:with-param name="defaultValue" select="$hierarchy_name"/>
- </xsl:call-template>
- <xsl:variable name="screenTip_Value">
- <xsl:call-template name="substring-findDelimited">
- <xsl:with-param name="strString" select="./*[local-name()='externalName']"/>
- <xsl:with-param name="strLeftDelimiter" select="'['"/>
- <xsl:with-param name="strRightDelimiter" select="']'"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="localizeElement">
- <xsl:with-param name="basedOnItem" select="$querySubject"/>
- <xsl:with-param name="elementName" select="'screenTip'"/>
- <xsl:with-param name="defaultValue" select="$screenTip_Value"/>
- </xsl:call-template>
- <xsl:variable name="bUnitofMeasure_or_Currency" select="$querySubject/*[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension' and (.='[0UNIT]' or .='[0CURRENCY]')]"/>
- <xsl:for-each select="./*[local-name() = 'property']">
- <xsl:choose>
- <xsl:when test="$bUnitofMeasure_or_Currency and @*[local-name() = 'name' and . = 'hierarchyCardinality']">
- <xsl:element name="property">
- <xsl:attribute name="name">hierarchyCardinality</xsl:attribute>
- 50
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="myCopy"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- <xsl:element name="externalName">
- <xsl:value-of select="$extName"/>
- </xsl:element>
- <!-- Developer's NOTE: The statement below uses a [1] filter. XSLT always returns the nearest ancestor 1st -->
- <xsl:call-template name="annotate">
- <!--xsl:with-param name="value" select="concat('Created hierarchy: ', $hierarchy_name, ' located under namespace: ', $namespace_name)"/-->
- <xsl:with-param name="value">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
- <xsl:with-param name="localeVal" select="$defaultLocale"/>
- <xsl:with-param name="string1" select="$OBJECT_TYPE_HIERARCHY"/>
- <xsl:with-param name="string2" select="$hierarchy_name"/>
- <xsl:with-param name="string3" select="$OBJECT_TYPE_NAMESPACE"/>
- <xsl:with-param name="string4" select="$namespace_name"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- <xsl:if test="$bUnitofMeasure_or_Currency">
- <!-- Insert missing level00 model information for "units of measure" and "currency" dimensions -->
- <xsl:variable name="level01_name" select="./*[local-name() = 'levels']/*[local-name() = 'level']/*[local-name() = 'name'][1]"/>
- <xsl:variable name="basedOnQI" select="$querySubject/*[local-name()='queryItem' and *[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale] and . = $level01_name]]"/>
- <xsl:for-each select="$querySubject/*[local-name()='levels']/*[local-name()='level' and *[local-name()='name' and . = $level01_name]]">
- <xsl:call-template name="addLevel00">
- <xsl:with-param name="hierarchy_name" select="$hierarchy_name"/>
- <xsl:with-param name="basedOnQI" select="$basedOnQI"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:if>
- <xsl:for-each select="./*[local-name() = 'levels']/*[local-name() = 'level']/*[local-name() = 'name']">
- <xsl:variable name="level_name" select="string(.)"/>
- <xsl:variable name="basedOnQI" select="$querySubject/*[local-name()='queryItem' and *[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale] and . = $level_name]]"/>
- <xsl:for-each select="$querySubject/*[local-name()='levels']/*[local-name()='level' and *[local-name()='name' and . = $level_name]]">
- <xsl:call-template name="level">
- <xsl:with-param name="namespace_name" select="$namespace_name"/>
- <xsl:with-param name="dimension_name" select="$dimension_name"/>
- <xsl:with-param name="querySubject" select="$querySubject"/>
- <xsl:with-param name="hierarchy_name" select="$hierarchy_name"/>
- <xsl:with-param name="level_name" select="$level_name"/>
- <xsl:with-param name="basedOnQI" select="$basedOnQI"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
- <!-- =============================================================================== -->
- <!-- Step 3: Fix OLAP QS : Fix the level object -->
- <xsl:template name="level">
- <xsl:param name="namespace_name"/>
- <xsl:param name="dimension_name"/>
- <xsl:param name="querySubject"/>
- <xsl:param name="hierarchy_name"/>
- <xsl:param name="level_name"/>
- <xsl:param name="basedOnQI"/>
-
- <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:element name="{local-name()}">
- <xsl:call-template name="annotate">
- <!--xsl:with-param name="value" select="concat('Created level: ', $level_name, ' located under namespace: ', $namespace_name)"/-->
- <xsl:with-param name="value">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
- <xsl:with-param name="localeVal" select="$defaultLocale"/>
- <xsl:with-param name="string1" select="$OBJECT_TYPE_LEVEL"/>
- <xsl:with-param name="string2" select="$level_name"/>
- <xsl:with-param name="string3" select="$OBJECT_TYPE_NAMESPACE"/>
- <xsl:with-param name="string4" select="$namespace_name"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="myCopyAttributes"/>
- <xsl:call-template name="localizeElement">
- <xsl:with-param name="basedOnItem" select="$basedOnQI"/>
- <xsl:with-param name="elementName" select="'name'"/>
- <xsl:with-param name="defaultValue" select="$level_name"/>
- </xsl:call-template>
- <xsl:call-template name="localizeElement">
- <xsl:with-param name="basedOnItem" select="$basedOnQI"/>
- <xsl:with-param name="elementName" select="'description'"/>
- <xsl:with-param name="defaultValue" select="$level_name"/>
- </xsl:call-template>
- <xsl:variable name="screenTip_Value">
- <xsl:call-template name="substring-findDelimited">
- <xsl:with-param name="strString" select="./*[local-name()='externalName']"/>
- <xsl:with-param name="strLeftDelimiter" select="'].['"/>
- <xsl:with-param name="strRightDelimiter" select="']'"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="localizeElement">
- <xsl:with-param name="basedOnItem" select="$basedOnQI"/>
- <xsl:with-param name="elementName" select="'screenTip'"/>
- <xsl:with-param name="defaultValue" select="$screenTip_Value"/>
- </xsl:call-template>
- <xsl:for-each select="./*[local-name() = 'property']">
- <xsl:call-template name="myCopy"/>
- </xsl:for-each>
- <xsl:for-each select="*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']">
- <xsl:variable name="refobj_qsName" select="substring-before(substring-after(., '].[' ), ']')"/>
- <!-- takes between '].[' and ']' -->
- <xsl:variable name="refobj_qiName" select="substring-before(substring-after(., concat('].[', $refobj_qsName, '].[') ), ']')"/>
- <!-- takes between '[namespace].[qs].[' and ']' -->
- <xsl:apply-templates select="key('queryItem_using_qsID_qiName', concat(generate-id($querySubject), '||', $refobj_qiName))" mode="dimQueryItem"/>
- <xsl:variable name="bPromptType_selectDate" select="$basedOnQI/*[local-name()='datatype'] = 'date'"/>
- <xsl:variable name="bDimensionType_Time" select="$querySubject/*[local-name() = 'property' and @*[local-name() = 'name' and .='dimensionType']] = 'time'"/>
- <xsl:choose>
- <xsl:when test="$bDimensionType_Time or $bPromptType_selectDate">
- <xsl:variable name="sortOnRef_value">
- <xsl:if test="$bDimensionType_Time"><xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $refobj_qiName, ']')"/></xsl:if>
- </xsl:variable>
- <xsl:variable name="promptType_value">
- <xsl:if test="$bPromptType_selectDate"><xsl:value-of select="'selectDate'"/></xsl:if>
- </xsl:variable>
- <xsl:variable name="sortOnRef_SapAttributes" select="xalan:nodeset($AllSapAttributes_sortOnRef)"/>
- <xsl:apply-templates select="$sortOnRef_SapAttributes/node()" mode="sapAttributes">
- <xsl:with-param name="sortOnRef" select="$sortOnRef_value"/>
- <xsl:with-param name="promptType" select="$promptType_value"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="$AllSapAttributes"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- <xsl:for-each select="*[local-name()='attributes']/*[local-name()='refobj']">
- <xsl:variable name="refobj_qsName" select="substring-before(substring-after(., '].[' ), ']')"/>
- <!-- takes between '].[' and ']' -->
- <xsl:variable name="refobj_qiName" select="substring-before(substring-after(., concat('].[', $refobj_qsName, '].[') ), ']')"/>
- <!-- takes between '[namespace].[qs].[' and ']' -->
- <xsl:apply-templates select="key('queryItem_using_qsID_qiName', concat(generate-id($querySubject), '||', $refobj_qiName))" mode="dimQueryItem"/>
- </xsl:for-each>
- <xsl:element name="isUnique">
- <xsl:choose>
- <xsl:when test="./*[local-name()='key' and @*[local-name()='isUniqueKey' and . = 'true']]">true</xsl:when>
- <xsl:otherwise>false</xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- <xsl:apply-templates select="./*[local-name()='externalName']"/>
- <xsl:apply-templates select="./*[local-name()='externalOrdinal']"/>
- </xsl:element>
- </xsl:template>
- <xsl:template match="*[local-name()='sortOnRef']" mode="sapAttributes">
- <xsl:param name="sortOnRef"/>
- <xsl:if test="$sortOnRef != ''">
- <xsl:element name="sortOnRef">
- <xsl:value-of select="$sortOnRef"/>
- </xsl:element>
- </xsl:if>
- </xsl:template>
- <xsl:template match="*[local-name()='promptType'][../../*[local-name()='externalName' and . = 'levelNumber']]/text()" mode="sapAttributes">
- <xsl:param name="promptType" select="'selectValue'"/>
- <xsl:choose>
- <xsl:when test="$promptType = 'selectDate'">selectDate</xsl:when>
- <xsl:otherwise>selectValue</xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- Template: Default XML Copy templates with mode set.
- NOTE: Required to recursively pass the mode down. -->
- <xsl:template match="*" mode="sapAttributes">
- <xsl:param name="sortOnRef"/>
- <xsl:param name="promptType"/>
- <xsl:element name="{local-name()}">
- <xsl:apply-templates select="*|@*|text()" mode="sapAttributes">
- <xsl:with-param name="sortOnRef" select="$sortOnRef"/>
- <xsl:with-param name="promptType" select="$promptType"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:template>
- <xsl:template match="@*" mode="sapAttributes">
- <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
- </xsl:template>
- <!-- =============================================================================== -->
- <!-- Step 4: Filter out Baltic query items now contained in the level object
- Filter out any query items which are refered to by the levels/level/attributes/refobjs and
- levels/level/key/queryItems_collection/refobjs.
- NOTE: Dimensional query items are processed recursively due to nested folder
- hierarchies.
- -->
- <xsl:template name="copyDimensionQueryItems">
- <xsl:variable name="querySubject" select="ancestor::*[local-name()='querySubject'][1]"/>
- <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="namespace_name" select="string($querySubject/ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="queryItem_name" select="string(*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="attributes_refobjs" select="../*[local-name()='levels']/*[local-name()='level']/*[local-name()='attributes']/*[local-name()='refobj']"/>
- <xsl:variable name="levelkey_refobjs" select="../*[local-name()='levels']/*[local-name()='level']/*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']"/>
- <xsl:variable name="refobj_value" select="concat('[', $namespace_name, '].[', $querySubject_name, '].[', $queryItem_name, ']')"/>
- <xsl:if test="not($refobj_value = $attributes_refobjs) and not($refobj_value = $levelkey_refobjs)">
- <xsl:element name="{local-name()}">
- <xsl:call-template name="myCopyAttributes"/>
- <xsl:apply-templates select="./*" mode="dimQueryItem"/>
- </xsl:element>
- </xsl:if>
- </xsl:template>
- <!-- Template: Change the dimension element to a mdDimension -->
- <xsl:template match="*[local-name()='mdQuery']/*[local-name()='dimension']" mode="dimQueryItem">
- <xsl:apply-templates select="."/>
- </xsl:template>
- <!-- Template: Change the measure dimension element to a mdDimension -->
- <xsl:template match="*[local-name()='mdQuery']/*[local-name()='dimension']">
- <xsl:call-template name="myCopy">
- <xsl:with-param name="elemName">mdDimension</xsl:with-param>
- </xsl:call-template>
- </xsl:template>
- <!-- Template: Default XML Copy template with mode set.
- NOTE: Required to recursively pass the mode down. -->
- <xsl:template match="*" mode="dimQueryItem">
- <xsl:if test="local-name()!= 'queryItemFolder' and not(ancestor::*[local-name()='querysubject'][1]/*[local-name()='definition']/*[local-name()='mdQuery'])">
- <xsl:element name="{name(.)}">
- <xsl:for-each select="@*">
- <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
- </xsl:for-each>
- <xsl:apply-templates select="node()" mode="dimQueryItem"/>
- </xsl:element>
- </xsl:if>
- </xsl:template>
- <!-- =============================================================================== -->
- <!-- Step 5: Fix OLAP QS : Change relationship objects with refobjs pointing
- to Dimensions to "scopeRelationship" objects
- Note that the dimensions are prefixed with an underscore.
- -->
- <xsl:template match="*[local-name()='relationship']">
- <!-- NOTE: Relationships are copied over AS-IS. Relationships which are upgraded to scopeRelationships
- are kept around for legacy purposes and are likely ignored for the most part. -->
- <xsl:call-template name="myCopy"/>
- <xsl:variable name="leftRefobj" select="string(*[local-name() = 'expression']/*[local-name() = 'refobj'][1])"/>
- <!-- Get name between first '[' and ']' -->
- <xsl:variable name="leftnamespace_name" select="substring-before(substring-after($leftRefobj, '['), ']')"/>
- <!-- Get name between first '].[' and ']' -->
- <xsl:variable name="leftquerysubject_name" select="substring-before(substring-after($leftRefobj, '].['), ']')"/>
- <xsl:variable name="leftquerySubject" select="key('querySubject_using_ns_qs', concat('[', $leftnamespace_name, '].[', $leftquerysubject_name, ']'))"/>
- <xsl:variable name="leftMeasure" select="key('measureQS_using_ns_qs', concat('[', $leftnamespace_name, '].[', $leftquerysubject_name, ']'))"/>
- <xsl:variable name="IsLeftRegularDimension">
- <xsl:call-template name="isRegularDimension">
- <xsl:with-param name="querySubject" select="$leftquerySubject"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="rightRefobj" select="string(*[local-name() = 'expression']/*[local-name() = 'refobj'][2])"/>
- <!-- Get name between first '[' and ']' -->
- <xsl:variable name="rightnamespace_name" select="substring-before(substring-after($rightRefobj, '['), ']')"/>
- <!-- Get name between first '].[' and ']' -->
- <xsl:variable name="rightquerysubject_name" select="substring-before(substring-after($rightRefobj, '].['), ']')"/>
- <xsl:variable name="rightquerySubject" select="key('querySubject_using_ns_qs', concat('[', $rightnamespace_name, '].[', $rightquerysubject_name, ']'))"/>
- <xsl:variable name="rightMeasure" select="key('measureQS_using_ns_qs', concat('[', $rightnamespace_name, '].[', $rightquerysubject_name, ']'))"/>
- <xsl:variable name="IsRightRegularDimension">
- <xsl:call-template name="isRegularDimension">
- <xsl:with-param name="querySubject" select="$rightquerySubject"/>
- </xsl:call-template>
- </xsl:variable>
- <!--NOTE: Only the default hierarchy gets a scope relationship. The other QS are brought over as child hierarchies-->
- <xsl:choose>
- <xsl:when test="$rightMeasure and ($IsLeftRegularDimension=string(true()))">
- <!-- Things are in the proper order -->
- <xsl:element name="scopeRelationship">
- <xsl:element name="name">
- <xsl:value-of select="concat($dimensionNamePrefix, $rightquerysubject_name, ' <--> ', $dimensionNamePrefix, $leftquerysubject_name)"/>
- </xsl:element>
- <xsl:apply-templates select="*[local-name()='property']"/>
- <xsl:element name="left">
- <xsl:element name="refobj">
- <xsl:value-of select="concat('[', $leftnamespace_name, '].[', $dimensionNamePrefix, $leftquerysubject_name, ']')"/>
- </xsl:element>
- <xsl:element name="mincard">one</xsl:element>
- <xsl:element name="maxcard">one</xsl:element>
- </xsl:element>
- <xsl:element name="right">
- <xsl:element name="refobj">
- <xsl:value-of select="concat('[', $rightnamespace_name, '].[', $dimensionNamePrefix, $rightquerysubject_name, ']')"/>
- </xsl:element>
- <xsl:element name="mincard">many</xsl:element>
- <xsl:element name="maxcard">many</xsl:element>
- </xsl:element>
- </xsl:element>
- </xsl:when>
- <xsl:when test="$leftMeasure and ($IsRightRegularDimension=string(true()))">
- <!-- The right side has to be the measure -->
- <xsl:element name="scopeRelationship">
- <xsl:element name="name">
- <xsl:value-of select="concat($dimensionNamePrefix, $leftquerysubject_name, ' <--> ', $dimensionNamePrefix, $rightquerysubject_name)"/>
- </xsl:element>
- <xsl:apply-templates select="*[local-name()='property']"/>
- <xsl:element name="left">
- <xsl:element name="refobj">
- <xsl:value-of select="concat('[', $leftnamespace_name, '].[', $dimensionNamePrefix, $leftquerysubject_name, ']')"/>
- </xsl:element>
- <xsl:element name="mincard">many</xsl:element>
- <xsl:element name="maxcard">many</xsl:element>
- </xsl:element>
- <xsl:element name="right">
- <xsl:element name="refobj">
- <xsl:value-of select="concat('[', $rightnamespace_name, '].[', $dimensionNamePrefix, $rightquerysubject_name, ']')"/>
- </xsl:element>
- <xsl:element name="mincard">one</xsl:element>
- <xsl:element name="maxcard">one</xsl:element>
- </xsl:element>
- </xsl:element>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
- <!-- =============================================================================== -->
- <!-- 6. Fixes for Baltic models which don't follow the BmtModelSpecification. -->
- <!-- Template: Empty security filter definitions must be removed -->
- <xsl:template match="*[local-name()='securityFilters']/*[local-name()='securityFilterDefinition'][not(./*)]"/>
- <!-- Template: Convert isRoleBased from an element to an attribute-->
- <xsl:template match="*[local-name()='securityViews']/*[local-name()='securityView' and *[local-name()='isRoleBased']]">
- <xsl:element name="{local-name()}">
- <xsl:attribute name="isRoleBased"><xsl:value-of select="*[local-name()='isRoleBased']"/></xsl:attribute>
- <xsl:for-each select="@*">
- <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
- </xsl:for-each>
- <xsl:apply-templates select="./*[local-name() != 'isRoleBased']"/>
- </xsl:element>
- </xsl:template>
- <!-- Template: Convert sql99 to native -->
- <xsl:template match="*[local-name() = 'querySubject']/*[local-name() = 'definition']/*[local-name()='mdQuery' or local-name()='dbQuery']/*[local-name() = 'sql' and @*[local-name() = 'type' and . = 'sql99']]">
- <xsl:element name="{local-name()}">
- <xsl:attribute name="type">native</xsl:attribute>
- <xsl:value-of select="."/>
- </xsl:element>
- </xsl:template>
- <!-- Template: Remove empty keys from querySubjects -->
- <xsl:template match="*[local-name() = 'querySubject']/*[local-name() = 'definition']/*[local-name() = 'dbQuery']/*[local-name() = 'key' and not(./*[local-name() = 'queryItems_collection']/*)]"/>
- <!-- =============================================================================== -->
- <!-- Step 7: Convert the mdQuery querySubject to a model querySubject,
- with all queryItems referencing the corresponding hidden dimension which
- is created in Step 1.
- This is a collection of templates with mode set to 'MakeQSwithDimRefs"
- -->
- <!-- Template: Change the definition's mdQuery to a modelQuery -->
- <xsl:template match="*[local-name()='mdQuery']" mode="MakeQSwithDimRefs">
- <xsl:element name="modelQuery">
- <xsl:element name="sql"/>
- <xsl:apply-templates select="./*[local-name()='filters']" mode="MakeQSwithDimRefs"/>
- </xsl:element>
- </xsl:template>
- <!-- Template: Change the dimension element to a mdDimension (in order to
- eliminate confusion between the new Dimension object and the old Baltic
- querySubject/definition/mdQuery/Dimension
- -->
- <xsl:template match="*[local-name()='dimension']" mode="MakeQSwithDimRefs">
- <xsl:call-template name="myCopy">
- <xsl:with-param name="elemName">mdDimension</xsl:with-param>
- </xsl:call-template>
- </xsl:template>
- <!-- Template: Determines if the given querySubject should be used to create
- a regular dimension.
-
- SAPBW dimensions are based on query subjects containing a default hierarchy.
-
- In the case where no default hierarchy is specified, the dimension is based on
- the first alternate hierarchy.
- -->
- <xsl:template name="isRegularDimension">
- <xsl:param name="querySubject" select="."/>
- <xsl:variable name="namespace_name" select="string($querySubject/ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="dimExternalName" select="$querySubject/*[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension']"/>
- <xsl:variable name="IsDefHierQS" select="key('defHierQS_using_ns_qs', concat('[', $namespace_name, '].[', $querySubject_name, ']'))"/>
- <xsl:variable name="defHierQS" select="key('defHierQS_using_ns_dimExternalName', concat('[', $namespace_name, ']', $dimExternalName))"/>
- <xsl:variable name="firstAltHier" select="key('altHierQS_using_ns_dimExternalName', concat('[', $namespace_name, ']', $dimExternalName))[1]"/>
- <xsl:value-of select="$IsDefHierQS or (not($defHierQS) and (generate-id($firstAltHier) = generate-id($querySubject)))"/>
- </xsl:template>
- <!-- Template: Determine the dimension name for a given a Baltic querySubject
-
- When given a Baltic query subject not involving an alternate hierarchy,
- simply use the name of the querySubject.
- When given a Baltic query subject for an alternate hierarchy, either use the name of
- the corresponding default hierarchy querySubject or when no default hierarchy
- is found, use the name of the first alternate hierarchy found.
- NOTE: All generated dimension names are prefixed with an underscore to prevent object
- name collisions with the corresponding model query subject.
- -->
- <xsl:template name="getDimensionName">
- <xsl:param name="querySubject" select="."/>
- <xsl:variable name="dimExternalName" select="$querySubject/*[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension']"/>
- <xsl:if test="$dimExternalName">
- <xsl:choose>
- <xsl:when test="key('altHierQS_using_qsID', generate-id($querySubject))">
- <xsl:variable name="namespace_name" select="string($querySubject/ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="defHierQS" select="key('defHierQS_using_ns_dimExternalName', concat('[', $namespace_name, ']', $dimExternalName))"/>
- <xsl:choose>
- <xsl:when test="$defHierQS">
- <xsl:value-of select="concat($dimensionNamePrefix, $defHierQS/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat($dimensionNamePrefix, key('altHierQS_using_ns_dimExternalName', concat('[', $namespace_name, ']', $dimExternalName))[1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:value-of select="concat($dimensionNamePrefix, $querySubject_name)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- </xsl:template>
- <!-- Template: Change the queryItem to use a refobj to the dimension.
-
- Append an <expression> which uses a refobj to the dimension, after the
- last property or screenTip element, whichever is positionally the last one
- to occur.
- Depending on whether or not the model queryItem is pointing to a measure
- or an attribute determines whether a 3 or 5 part name is required. 5 part
- names require the hierarchy and level names be calculated.
-
- Strip the queryItem's <columnName> since it doesn't apply to
- modelQuery querySubjects
- NOTE: Baltic querySubjects with dimInfo containing measures are split into a modelQuery
- and a hidden measure dimension which the modelQuery points to. However, Baltic hidden
- queryItems (which are keys to the dimension hierarchies) have no representation
- in the Bering measure dimension, so these expressions which are now in the modelQuery
- must be retargeted using relationships in the model existing between the hidden
- queryItem and the key for the dimension's hierarchy.
- -->
- <xsl:template match="*[local-name()='queryItem']" mode="MakeQSwithDimRefs">
- <xsl:variable name="queryItem" select="."/>
- <xsl:variable name="queryItem_name" select="string($queryItem/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="querySubject" select="ancestor::*[local-name()='querySubject'][1]"/>
- <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="namespace_name" select="string($querySubject/ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:element name="queryItem">
- <!--Copy over the queryItem's attributes-->
- <xsl:call-template name="myCopyAttributes"/>
- <!--Copy over the queryItem's children-->
- <xsl:variable name="generateidAnchorForExpression" select="generate-id($queryItem/*[local-name()='name' or local-name()='description' or local-name()='lastChanged' or local-name()='screenTip' or local-name()='property'][last()])"/>
- <xsl:for-each select="node()">
- <xsl:choose>
- <xsl:when test="local-name() = 'columnName'"/>
- <!-- Strip the columnName -->
- <xsl:when test="generate-id(.) = $generateidAnchorForExpression">
- <!-- The anchor position to insert the <expression> has been found -->
- <!-- Copy the anchor element over -->
- <xsl:call-template name="myCopy"/>
- <!-- Create the <expression> to append after the anchor-->
- <xsl:variable name="dimension_name">
- <xsl:call-template name="getDimensionName">
- <xsl:with-param name="querySubject" select="$querySubject"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$AllmdQueryMeasureDimensions[generate-id() = generate-id($querySubject)]">
- <xsl:element name="expression">
- <xsl:variable name="embeddedCalc" select="$querySubject/*[local-name()='definition']/*[local-name()='mdQuery' or local-name()='dbQuery']/*[local-name()='calculations']/*[local-name()='calculationDefinition']/*[local-name()='dataItemName' and .=$queryItem_name]"/>
- <xsl:choose>
- <!-- NOTE: If the query item is an embedded calc then the expression already points where it is supposed to so leave it as is -->
- <xsl:when test="$embeddedCalc">
- <xsl:for-each select="$embeddedCalc/../*[local-name()='expression']/node()">
- <xsl:call-template name="myCopy"/>
- </xsl:for-each>
- </xsl:when>
- <!-- NOTE: If the query item is hidden, then the it's an attribute of one of the dimensions in the model. expression already points where it is supposed to so leave it as is -->
- <xsl:when test="$queryItem/*[local-name() ='hidden' and . = 'true']">
- <xsl:element name="refobj">
- <xsl:call-template name="resolveRelationshipReference">
- <xsl:with-param name="refObj" select="concat('[', $namespace_name, '].[', $querySubject_name, '].[', $queryItem_name, ']')"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <!-- NOTE: queryItem is changed to a refobj expression pointing to the Dimension's measure.
- [Namespace].[querySubject].[queryItem] is mapped to [Namespace].[Dimension].[Attribute] -->
- <xsl:otherwise>
- <xsl:element name="refobj">
- <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $queryItem_name, ']')"/>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <!-- NOTE: queryItem is changed to a refobj expression pointing to the Dimension's attribute.
- [Namespace].[querySubject].[queryItem] is mapped to [Namespace].[Dimension].[Hierarchy].[Level].[Attribute] -->
- <xsl:variable name="attributes_refobjs" select="$querySubject/*[local-name()='levels']/*[local-name()='level']/*[local-name()='attributes']/*[local-name()='refobj']"/>
- <xsl:variable name="levelkey_refobjs" select="$querySubject/*[local-name()='levels']/*[local-name()='level']/*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']"/>
- <xsl:variable name="refobj_value" select="concat('[', $namespace_name, '].[', $querySubject_name, '].[', $queryItem_name, ']')"/>
- <xsl:element name="expression">
- <xsl:variable name="attribute_refobj" select="$attributes_refobjs[. = $refobj_value]"/>
- <xsl:variable name="levelkey_refobj" select="$levelkey_refobjs[. = $refobj_value]"/>
- <xsl:choose>
- <xsl:when test="$attribute_refobj">
- <xsl:variable name="level_name" select="string($attribute_refobj/../../*[local-name()='name'])"/>
- <xsl:variable name="hierarchy_name" select="string($querySubject/*[local-name()='hierarchies']/*[local-name()='hierarchy']/*[local-name()='name'])"/>
- <xsl:element name="refobj">
- <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $queryItem_name, ']')"/>
- </xsl:element>
- <xsl:call-template name="annotate">
- <!--xsl:with-param name="value" select="concat('Created attribute from query Item called: ', $queryItem_name, ' found under level: ', $level_name)"/-->
- <xsl:with-param name="value">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
- <xsl:with-param name="localeVal" select="$defaultLocale"/>
- <xsl:with-param name="string1" select="$OBJECT_TYPE_ATTRIBUTE"/>
- <xsl:with-param name="string2" select="$queryItem_name"/>
- <xsl:with-param name="string3" select="$OBJECT_TYPE_LEVEL"/>
- <xsl:with-param name="string4" select="$level_name"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$levelkey_refobj">
- <xsl:variable name="level_name" select="string($levelkey_refobj/../../../*[local-name()='name'])"/>
- <xsl:variable name="hierarchy_name" select="string($querySubject/*[local-name()='hierarchies']/*[local-name()='hierarchy']/*[local-name()='name'])"/>
- <xsl:element name="refobj">
- <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $queryItem_name, ']')"/>
- </xsl:element>
- <xsl:call-template name="annotate">
- <!--xsl:with-param name="value" select="concat('Created level key from attribute called: ', $queryItem_name, ' found under level: ', $level_name)"/-->
- <xsl:with-param name="value">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
- <xsl:with-param name="localeVal" select="$defaultLocale"/>
- <xsl:with-param name="string1" select="$OBJECT_TYPE_KEY"/>
- <xsl:with-param name="string2" select="$queryItem_name"/>
- <xsl:with-param name="string3" select="$OBJECT_TYPE_LEVEL"/>
- <xsl:with-param name="string4" select="$level_name"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message terminate="yes">
- <xsl:value-of select="concat('refobj', $nOldSchema, ' model.')"/>
- </xsl:message>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <!--Copy over the queryItem's child -->
- <xsl:apply-templates select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
- <!-- Template: Rename the levels element to <_levels> and hierarchies to
- <_hierarchies>.
- NOTE: Since the mode was specified for processing mdQuery query subjects,
- the templates in step 7 are not being triggered automatically since they are not
- mode specific.
- This template simply removes the mode specification for hierarchies and levels so
- that normal template processing occurs.
- -->
- <xsl:template match="*[local-name()='levels' or local-name()='hierarchies']" mode="MakeQSwithDimRefs">
- <xsl:apply-templates select="."/>
- </xsl:template>
- <!-- Template: Default XML Copy template with mode set.
- NOTE: Required to recursively pass the mode down. -->
- <xsl:template match="*" mode="MakeQSwithDimRefs">
- <xsl:element name="{local-name()}">
- <xsl:for-each select="@*">
- <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
- </xsl:for-each>
- <xsl:apply-templates select="node()" mode="MakeQSwithDimRefs"/>
- </xsl:element>
- </xsl:template>
- <!-- =============================================================================== -->
- <!-- Step 8: Copy all hierarchies and levels elements in-tact, but rename their
- children to <_level> and <_hierarchy>
- Hierarchies and Levels are left as-is for backwards compatibilty reasons.
- The BmtModelSpecification as it was defined back in Baltic has been carried
- forward.
- Their children are now prefixed with an underscore.
- This is to be able to differentiate inside dimensions objects between the backwards
- compatible stuctures and the upgraded ones. Dimensions have both <level>
- and <_level> and <hierarchy> and <_hierarchy> elements.
- -->
- <xsl:template match="*[local-name()='querySubject']/*[local-name()='levels' or local-name()='hierarchies']">
- <xsl:element name="{local-name()}">
- <xsl:for-each select="./*">
- <xsl:call-template name="myCopy">
- <xsl:with-param name="elemName" select="concat($levelNamePrefix, local-name())"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
- <!-- =============================================================================== -->
- <!-- Step 9: Generate dummy localized elements for dimensions that are missing corresponding Baltic properties.
- NOTE: Baltic didn't store localized properties for level and hierarchy name, description and screenTip elements.
- The dummy placeholder consists of a prefix containing the locale key and simply uses the existing value in the
- <defaultLocale> ie. Design locale, duplicating the behaviour in Framework Manager when a new locale is added to
- the model.
- Example: Assuming the default locale is "en"...
- <level>
- <name locale="en">Value</name>
- <name locale="fr">(fr) Value</name>
- </level>
- -->
- <xsl:template name="localizeElement">
- <xsl:param name="basedOnItem"/>
- <xsl:param name="elementName" select="local-name()"/>
- <xsl:param name="defaultValue" select="."/>
- <xsl:element name="{$elementName}">
- <xsl:attribute name="locale"><xsl:value-of select="$defaultLocale"/></xsl:attribute>
- <xsl:value-of select="$defaultValue"/>
- </xsl:element>
- <xsl:for-each select="$AllProjectLocales/*[local-name()='locale' and . != $defaultLocale]">
- <xsl:variable name="localItr" select="."/>
- <xsl:element name="{$elementName}">
- <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
- <xsl:choose>
- <xsl:when test="$basedOnItem">
- <xsl:value-of select="$basedOnItem/*[local-name()=$elementName and @*[local-name()='locale' and . = $localItr]]"/>
- </xsl:when>
- <xsl:when test="$defaultValue = ''">
- <xsl:value-of select="''"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat('(', . , ') ' , $defaultValue)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:for-each>
- </xsl:template>
- <!-- =============================================================================== -->
- <!-- Step 10: Alter security views to hide the Bering dimensions from the published package
- When upgrading a SAPBW querySubject from Baltic to Bering, a model querySubject is created along with a new
- Bering dimension object, which the model querySubject references. The dimension is "hidden" from view, and all
- the user sees is the model querySubject.
- This is to preserve any Baltic behaviour the modeler was relying upon, such as re-ordering the queryItems which
- cannot be done with dimensions.
- -->
- <xsl:template match="*[local-name()='securityView']/*[local-name()='definition']">
- <xsl:element name="definition">
- <xsl:for-each select="./*[local-name()='set']">
- <xsl:element name="set">
- <xsl:attribute name="includeRule"><xsl:value-of select="./@*[local-name()='includeRule']"/></xsl:attribute>
- <xsl:for-each select="./*[local-name()='refobj']">
- <xsl:variable name="id">
- <xsl:value-of select="./*[local-name()='refobj']"/>
- </xsl:variable>
- <xsl:variable name="qsName" select="substring-before(substring-after($id, '].[' ), ']')"/>
- <xsl:variable name="regDim" select="$AllmdQueryQS/*[local-name()='name' and .=$qsName]"/>
- <xsl:variable name="measureDim" select="$AllmdQueryMeasureDimensions/*[local-name()='name' and .=$qsName]"/>
- <xsl:if test="not($regDim) and not($measureDim)">
- <xsl:call-template name="myCopy"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:element>
- </xsl:for-each>
- <xsl:if test="$AllmdQueryQS or $AllmdQueryMeasureDimensions">
- <xsl:element name="set">
- <xsl:attribute name="includeRule">hide</xsl:attribute>
- <!-- For every Baltic mdQuery querySubject dimension, hide the corresponding Bering generated dimension -->
- <xsl:for-each select="$AllDefaultHierarchyQS | $AllmdQueryMeasureDimensions">
- <xsl:element name="refobj">
- <xsl:value-of select="concat('[' ,ancestor::*[local-name()='namespace'][1]/*[local-name()='name'],']', '.' , '[' , $dimensionNamePrefix, ./*[local-name()='name'], ']')"/>
- </xsl:element>
- </xsl:for-each>
- </xsl:element>
- </xsl:if>
- </xsl:element>
- </xsl:template>
- <!-- =============================================================================== -->
- <!-- Step 11: Translate all locale keys to lowercase
- -->
- <xsl:template match="@*[local-name() = 'locale']/text()">
- <xsl:value-of select="translate(., $uppercase, $lowercase)"/>
- </xsl:template>
- <xsl:template match="/*[local-name() = 'project']/*[local-name() = 'locales']/*[local-name() = 'locale']/text()">
- <xsl:value-of select="translate(., $uppercase, $lowercase)"/>
- </xsl:template>
- <xsl:template match="/*[local-name() = 'project']/*[local-name() = 'defaultLocale']/text()">
- <xsl:value-of select="translate(., $uppercase, $lowercase)"/>
- </xsl:template>
- <!-- ============================================================================== -->
- <!-- Step 12: Set the governors and flag all querySubjects requiring data type upgrading to "needs reevaluation".
-
- * Remove the old governors for "Enhanced Model Portability" (to prevent duplicate occurances)
- * Insert the new governor value for Enhanced Model Portability.
- * Insert the new governor value to Generate default dimensional information
- * Insert the new governor value for "useSQLWithClause"
- * Set all querySubjects of type dbQuery and stored procedure to "needs reevaluation", and annotate them accordingly
- to trigger the Model Report dialog and the "verify model"
- -->
- <!-- Template: Strip out the old governors being replaced, so there's not duplicates. Later on, put them back if we don't need to insert new values -->
- <xsl:template match="/*[local-name()='project']/*[local-name()='parameterMaps']/*[local-name()='parameterMap' and *[local-name() = 'name' and . = '_governor']]/*[local-name()='parameterMapEntry' and *[local-name()='key' and (. = 'useMetadataCallback' or . = 'useSQLWithClause')]]">
- </xsl:template>
- <!-- Template: Insert the new governor values -->
- <xsl:template match="/*[local-name()='project']/*[local-name()='parameterMaps']/*[local-name()='parameterMap' and *[local-name() = 'name' and . = '_governor']]/*[local-name() = 'name' or local-name() = 'property' or local-name() = 'defaultValue' or local-name()='parameterMapEntry'][last()]">
- <xsl:variable name="AllGovernors" select="/*[local-name()='project']/*[local-name()='parameterMaps']/*[local-name()='parameterMap' and *[local-name() = 'name' and . = '_governor']]"/>
- <xsl:variable name="governor_useMetadataCallback" select="$AllGovernors/*[local-name()='parameterMapEntry' and *[local-name()='key' and . = 'useMetadataCallback']]"/>
- <!-- Copy the anchor element -->
- <xsl:if test="not(*[local-name()='key' and (. = 'useMetadataCallback' or . = 'useSQLWithClause')])">
- <xsl:call-template name="myCopy"/>
- </xsl:if>
- <!-- Insert the governors -->
- <!-- Insert the governor "useMetadataCallback" for enhanced model portability if the model contains querySubjects requiring it
- NOTE: This entry is annotated at the project level so it appears at the top of the report. -->
- <xsl:choose>
- <xsl:when test="$AllUpgradeDatatypeQuerySubjects">
- <xsl:element name="parameterMapEntry">
- <xsl:element name="key">useMetadataCallback</xsl:element>
- <xsl:element name="value">false</xsl:element>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <!-- If the governor previously existed in the model, put the old value back.
- NOTE: The governor is stripped out of the model by the previous template, to prevent a duplicate from being inserted. -->
- <xsl:for-each select="$governor_useMetadataCallback">
- <xsl:call-template name="myCopy"/>
- </xsl:for-each>
- </xsl:otherwise>
- </xsl:choose>
- <!-- Insert the governor "useSQLWithClause" -->
- <xsl:variable name="governor_useSQLWithClause" select="$AllGovernors/*[local-name()='parameterMapEntry' and *[local-name()='key' and . = 'useSQLWithClause']]"/>
- <xsl:choose>
- <!-- If the governor previously existed in the model, put the old value back.
- NOTE: The governor is stripped out of the model by the previous template, to prevent a duplicate from being inserted. -->
- <xsl:when test="$governor_useSQLWithClause">
- <xsl:for-each select="$governor_useSQLWithClause">
- <xsl:call-template name="myCopy"/>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="parameterMapEntry">
- <xsl:element name="key">useSQLWithClause</xsl:element>
- <xsl:element name="value">false</xsl:element>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- <!-- Insert the governor "dynamicDimensionInfo" for CQE to generate dynamic dimensional information as per the old Baltic style query generation. -->
- <xsl:element name="parameterMapEntry">
- <xsl:element name="key">dynamicDimensionInfo</xsl:element>
- <xsl:element name="value">true</xsl:element>
- </xsl:element>
- <xsl:call-template name="annotate">
- <xsl:with-param name="value" select="$strWarnDimensionInfo"/>
- </xsl:call-template>
- </xsl:template>
- <!-- Template: Annotate the project element -->
- <xsl:template match="*[local-name() = 'project']/*[1]">
- <xsl:if test="$AllUpgradeDatatypeQuerySubjects">
- <xsl:call-template name="annotate">
- <xsl:with-param name="value" select="$strWarnModelPortability"/>
- </xsl:call-template>
- </xsl:if>
- <!-- Copy the anchor -->
- <xsl:call-template name="myCopy"/>
- </xsl:template>
- <!-- Template: All dbQuery and stored procedure Query Subjects are set to "needs reevaluation", and marked with
- a hidden custom property to identify all querySubjects requiring the use of the "enhanced model portability" governor. -->
- <xsl:template match="*[local-name() = 'querySubject'][*[local-name() = 'definition' and *[local-name() = 'dbQuery' or local-name() = 'storedProcedure']]]">
- <xsl:variable name="namespace_name" select="string(ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="querySubject_name" select="string(current()/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:element name="{name(.)}">
- <!-- Set the status -->
- <xsl:attribute name="status">needsReevaluation</xsl:attribute>
- <xsl:for-each select="./*">
- <xsl:choose>
- <xsl:when test="generate-id(.) = generate-id(../*[local-name() = 'name' or local-name() = 'description' or local-name() = 'lastChanged' or local-name() = 'screenTip' or local-name() = 'property'][last()])">
- <!-- Copy the anchor element over -->
- <xsl:call-template name="myCopy"/>
- <!-- Append the custom property used for "Verify Model" -->
- <xsl:element name="property">
- <xsl:attribute name="name">enhancedModelPortabilityRequired</xsl:attribute>
- <xsl:attribute name="type">hidden</xsl:attribute>
- <xsl:value-of select="true"/>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
- <!-- ============================================================================== -->
- <!-- Step 13: Add roles for the SAP Levels
- -->
- <xsl:template match="*[local-name()='queryItem' and *[local-name()='columnName' and .='[MEMBER_UNIQUE_NAME]']]/*[last()]" mode="dimQueryItem">
- <!-- Copy anchor -->
- <xsl:element name="{local-name(.)}">
- <xsl:for-each select="@*">
- <xsl:attribute name="{local-name(.)}"><xsl:value-of select="."/></xsl:attribute>
- </xsl:for-each>
- <xsl:apply-templates select="node()" mode="dimQueryItem"/>
- </xsl:element>
- <xsl:copy-of select="$AllBusinessKeyRoles"/>
- </xsl:template>
- <xsl:template name="AddSapAttribute">
- <xsl:param name="attribNameID"/>
- <xsl:param name="attribDescID"/>
- <xsl:param name="attribDataType"/>
- <xsl:param name="attribExtName"/>
- <xsl:param name="attribRole"/>
- <xsl:param name="sortOnRef" select="false()"/>
- <xsl:param name="attribHidden" select="true()"/>
- <xsl:param name="bLocalize" select="true()"/>
- <xsl:element name="queryItem">
- <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
- <xsl:element name="name">
- <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$attribNameID"/>
- <xsl:with-param name="localeVal" select="."/>
- <xsl:with-param name="bLocalize" select="$bLocalize"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:for-each>
- <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
- <xsl:element name="description">
- <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$attribDescID"/>
- <xsl:with-param name="localeVal" select="."/>
- <xsl:with-param name="bLocalize" select="$bLocalize"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:for-each>
- <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
- <xsl:element name="screenTip">
- <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$attribDescID"/>
- <xsl:with-param name="localeVal" select="."/>
- <xsl:with-param name="bLocalize" select="$bLocalize"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:for-each>
- <xsl:element name="externalName">
- <xsl:value-of select="$attribExtName"/>
- </xsl:element>
- <xsl:if test="$attribHidden">
- <xsl:element name="hidden">true</xsl:element>
- </xsl:if>
- <xsl:element name="usage">attribute</xsl:element>
- <xsl:element name="datatype">
- <xsl:value-of select="$attribDataType"/>
- </xsl:element>
- <xsl:element name="promptInfo">
- <xsl:element name="promptType">
- <xsl:choose>
- <!-- sortOnRef is supplied when the hierarchyType is 'date' -->
- <xsl:when test="$attribExtName = 'levelNumber'">selectDate</xsl:when>
- <xsl:otherwise>selectValue</xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:element>
- <xsl:if test="$sortOnRef">
- <xsl:element name="sortOnRef"/>
- </xsl:if>
- <xsl:element name="roles">
- <xsl:element name="role">
- <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
- <xsl:element name="name">
- <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
- <xsl:value-of select="$attribRole"/>
- </xsl:element>
- </xsl:for-each>
- </xsl:element>
- </xsl:element>
- </xsl:element>
- </xsl:template>
- <!-- ============================================================================== -->
- <!-- Step 14: Convert 3 Part references to 5 part references
- -->
- <!-- Template: Convert promptDisplayItemRef from a 3-Part reference to a 5-Part Reference -->
- <xsl:template match="*[local-name()='promptDisplayItemRef']/text()" mode="dimQueryItem">
- <xsl:variable name="refobj_value" select="."/>
- <xsl:variable name="namespace_name" select="substring-before(substring-after(., '['), ']')"/>
- <!-- takes between '[' and ']' -->
- <xsl:variable name="querySubject_name" select="substring-before(substring-after(., '].[' ), ']')"/>
- <!-- takes between '].[' and ']' -->
- <xsl:variable name="queryItem_name" select="substring-before(substring-after(., concat('].[', $querySubject_name, '].[') ), ']')"/>
- <!-- takes between '[namespace].[qs].[' and ']' -->
- <xsl:variable name="querySubject" select="ancestor::*[local-name()='querySubject'][1]"/>
- <xsl:variable name="level_name">
- <xsl:variable name="attribute_refobj_name" select="$querySubject/*[local-name()='levels']/*[local-name()='level']/*[local-name()='attributes']/*[local-name()='refobj' and .= $refobj_value]/../../*[local-name()='name']"/>
- <xsl:variable name="levelkey_refobj_name" select="$querySubject/*[local-name()='levels']/*[local-name()='level']/*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj' and .= $refobj_value]/../../../*[local-name()='name']"/>
- <xsl:value-of select="$attribute_refobj_name|$levelkey_refobj_name"/>
- </xsl:variable>
- <!-- Create the <expression> to append after the anchor-->
- <xsl:variable name="dimension_name">
- <xsl:call-template name="getDimensionName">
- <xsl:with-param name="querySubject" select="$querySubject"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="hierarchy_name" select="string($querySubject/*[local-name()='hierarchies']/*[local-name()='hierarchy']/*[local-name()='name'])"/>
- <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $queryItem_name, ']')"/>
- </xsl:template>
- <!-- ============================================================================== -->
- <!-- Step 15: Set filterItemRef and sortOnRef to the member unique name
- * The key, short name, medium name, and long name properties must
- all set their filterItemRef property to the member unique name of the associated level
- See Trakker 463250, WO 1049
- * a sortOnRef value pointing to the memberUniqueName must be added to all queryItem attributes.
- -->
- <xsl:template match="*[local-name()='queryItem' and *[local-name()='usage' and .='attribute']]" mode="dimQueryItem">
- <xsl:element name="queryItem">
- <xsl:call-template name="myCopyAttributes"/>
- <xsl:apply-templates select="*[local-name() != 'promptInfo' and local-name() != 'sortOnRef']" mode="dimQueryItem"/>
- <xsl:variable name="queryItem" select="."/>
- <xsl:variable name="queryItem_name" select="string($queryItem/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="querySubject" select="$queryItem/ancestor::*[local-name()='querySubject'][1]"/>
- <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="namespace_name" select="string($querySubject/ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="refobj_value" select="concat('[', $namespace_name, '].[', $querySubject_name, '].[', $queryItem_name, ']')"/>
- <xsl:variable name="level" select="$querySubject/*[local-name()='levels']/*[local-name()='level' and *[local-name()='attributes']/*[local-name()='refobj' and .= $refobj_value]]"/>
- <xsl:variable name="level_name" select="$level/*[local-name()='name']"/>
- <xsl:variable name="dimension_name">
- <xsl:call-template name="getDimensionName">
- <xsl:with-param name="querySubject" select="$querySubject"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="hierarchy_name" select="string($querySubject/*[local-name()='hierarchies']/*[local-name()='hierarchy']/*[local-name()='name'])"/>
- <xsl:variable name="memberUniqueName">
- <xsl:call-template name="substring-findDelimited">
- <xsl:with-param name="strString" select="$level/*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']"/>
- <xsl:with-param name="strLeftDelimiter" select="concat('].[', $querySubject_name, '].[')"/>
- <xsl:with-param name="strRightDelimiter" select="']'"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:element name="promptInfo">
- <xsl:apply-templates select="*[local-name()='promptInfo']/*" mode="dimQueryItem"/>
- <xsl:if test="$level_name">
- <!-- Create the <expression> to append after the anchor-->
- <xsl:element name="promptFilterItemRef">
- <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $memberUniqueName, ']')"/>
- </xsl:element>
- </xsl:if>
- </xsl:element>
- <xsl:if test="$querySubject/*[local-name() = 'property' and @*[local-name() = 'name' and .='dimensionType']] = 'time'">
- <xsl:element name="sortOnRef">
- <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $memberUniqueName, ']')"/>
- </xsl:element>
- </xsl:if>
- </xsl:element>
- </xsl:template>
- <!-- ============================================================================== -->
- <!-- Step 16: Add missing Level00 information to unit of measure and currency dimensions.
- In Baltic, support was removed for this information. In Bering, support was
- added back in.
- WARNING! The level00 information is generated based on the level01 information
- in the model. If the SAPBW datasource level00 information has been
- customized, it may not correspond to the generated level00 information.
- -->
- <xsl:template name="addLevel00">
- <!-- mode="dimQueryItem" -->
- <xsl:param name="hierarchy_name"/>
- <xsl:param name="basedOnQI"/>
-
- <xsl:variable name="querySubject" select="ancestor::*[local-name()='querySubject'][1]"/>
- <xsl:variable name="external01" select="./*[local-name()='externalName']"/>
- <xsl:variable name="externalName" select="concat(substring-before(substring-after($external01, '].['), '01]'), '00')"/>
- <xsl:variable name="externalNameRefobj" select="concat(substring-before($external01, '].['), '].[', $externalName, ']')"/>
- <xsl:variable name="namespace_name2" select="string(ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="querySubject_name2" select="string(ancestor::*[local-name()='querySubject'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:element name="{local-name()}">
- <xsl:call-template name="annotate">
- <!--xsl:with-param name="value" select="concat('Created level: ', $hierarchy_name, ' located under namespace: ', $namespace_name2)"/-->
- <xsl:with-param name="value">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
- <xsl:with-param name="localeVal" select="$defaultLocale"/>
- <xsl:with-param name="string1" select="$OBJECT_TYPE_LEVEL"/>
- <xsl:with-param name="string2" select="$hierarchy_name"/>
- <xsl:with-param name="string3" select="$OBJECT_TYPE_NAMESPACE"/>
- <xsl:with-param name="string4" select="$namespace_name2"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="myCopyAttributes"/>
- <xsl:variable name="levelNames">
- <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
- <xsl:variable name="localItr" select="."/>
- <xsl:element name="name">
- <xsl:attribute name="locale"><xsl:value-of select="$localItr"/></xsl:attribute>
- <xsl:value-of select="concat($querySubject/*[local-name()='name' and @*[local-name()='locale' and . = $localItr]], ' ', xalan:nodeset($AllLevelLocalizedStrings)/*[local-name()=$localItr])"/>
- </xsl:element>
- </xsl:for-each>
- </xsl:variable>
- <xsl:copy-of select="$levelNames"/>
- <xsl:call-template name="localizeElement">
- <xsl:with-param name="elementName" select="'description'"/>
- <xsl:with-param name="defaultValue" select="string($externalName)"/>
- </xsl:call-template>
- <xsl:call-template name="localizeElement">
- <xsl:with-param name="elementName" select="'screenTip'"/>
- <xsl:with-param name="defaultValue" select="string($externalName)"/>
- </xsl:call-template>
- <xsl:copy-of select="./*[local-name() = 'property']"/>
- <xsl:for-each select="*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']">
- <xsl:variable name="namespace_name" select="substring-before(substring-after(., '['), ']')"/>
- <!-- takes between '[' and ']' -->
- <xsl:variable name="querySubject_name" select="substring-before(substring-after(., '].[' ), ']')"/>
- <!-- takes between '].[' and ']' -->
- <xsl:variable name="queryItem_name" select="substring-before(substring-after(., concat('].[', $querySubject_name, '].[') ), ']')"/>
- <!-- takes between '[namespace].[qs].[' and ']' -->
- <xsl:call-template name="addLevel00QueryItem">
- <xsl:with-param name="basedOnQI" select="key('queryItem_using_qsID_qiName', concat(generate-id($querySubject), '||', $queryItem_name))"/>
- <xsl:with-param name="hierarchy_name" select="$hierarchy_name"/>
- <xsl:with-param name="levelNames" select="$levelNames"/>
- <xsl:with-param name="queryItem_name" select="concat($queryItem_name, ' ', $strLevelAll)"/>
- </xsl:call-template>
- </xsl:for-each>
- <xsl:copy-of select="$AllSapAttributes"/>
- <xsl:for-each select="*[local-name()='attributes']/*[local-name()='refobj']">
- <xsl:variable name="namespace_name" select="substring-before(substring-after(., '['), ']')"/>
- <!-- takes between '[' and ']' -->
- <xsl:variable name="querySubject_name" select="substring-before(substring-after(., '].[' ), ']')"/>
- <!-- takes between '].[' and ']' -->
- <xsl:variable name="queryItem_name" select="substring-before(substring-after(., concat('].[', $querySubject_name, '].[') ), ']')"/>
- <!-- takes between '[namespace].[qs].[' and ']' -->
- <xsl:call-template name="addLevel00QueryItem">
- <xsl:with-param name="basedOnQI" select="key('queryItem_using_qsID_qiName', concat(generate-id($querySubject), '||', $queryItem_name))"/>
- <xsl:with-param name="hierarchy_name" select="$hierarchy_name"/>
- <xsl:with-param name="levelNames" select="$levelNames"/>
- <xsl:with-param name="queryItem_name" select="concat($queryItem_name, ' ', $strLevelAll)"/>
- </xsl:call-template>
- </xsl:for-each>
- <xsl:element name="isUnique">true</xsl:element>
- <xsl:element name="externalName"><xsl:value-of select="$externalNameRefobj"/></xsl:element>
- <xsl:element name="externalOrdinal">00</xsl:element>
- </xsl:element>
- </xsl:template>
- <xsl:template name="addLevel00QueryItem">
- <xsl:param name="basedOnQI"/>
- <xsl:param name="hierarchy_name"/>
- <xsl:param name="levelNames"/>
- <xsl:param name="queryItem_name"/>
- <xsl:variable name="level_name" select="xalan:nodeset($levelNames)/*[1]"/>
- <xsl:element name="queryItem">
- <xsl:variable name="bIsMemberUniqueName" select="$basedOnQI/*[local-name()='columnName' and .='[MEMBER_UNIQUE_NAME]']"/>
- <xsl:choose>
- <xsl:when test="$bIsMemberUniqueName">
- <xsl:copy-of select="$levelNames"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="localizeElement">
- <xsl:with-param name="elementName" select="'name'"/>
- <xsl:with-param name="defaultValue" select="$queryItem_name"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:call-template name="localizeElement">
- <xsl:with-param name="elementName" select="'description'"/>
- <xsl:with-param name="defaultValue" select="$queryItem_name"/>
- </xsl:call-template>
- <xsl:call-template name="localizeElement">
- <xsl:with-param name="elementName" select="'screenTip'"/>
- <xsl:with-param name="defaultValue" select="$queryItem_name"/>
- </xsl:call-template>
- <xsl:copy-of select="$basedOnQI/*[local-name() != 'name' and local-name() != 'description' and local-name() != 'screenTip' and local-name() != 'promptInfo']"/>
- <xsl:element name="promptInfo">
- <xsl:element name="promptType">selectValue</xsl:element>
- <xsl:choose>
- <xsl:when test="$bIsMemberUniqueName">
- <xsl:element name="promptDisplayItemRef">
- <xsl:variable name="promptDisplayItemRef">
- <xsl:apply-templates select="$basedOnQI/*[local-name() = 'promptInfo']/*[local-name() = 'promptDisplayItemRef']/text()"/>
- </xsl:variable>
- <xsl:variable name="namespace_name" select="substring-before(substring-after($promptDisplayItemRef, '['), ']')"/>
- <!-- takes between '[' and ']' -->
- <xsl:variable name="querySubject_name" select="substring-before(substring-after($promptDisplayItemRef, '].[' ), ']')"/>
- <!-- takes between '[namespace].[' and ']' -->
- <xsl:variable name="queryItem01_name" select="substring-before(substring-after($promptDisplayItemRef, concat('].[', $querySubject_name, '].[') ), ']')"/>
- <!-- takes between '[namespace].[querySubject].[' and ']' -->
- <xsl:value-of select="concat('[', $namespace_name, '].[', $dimensionNamePrefix, $querySubject_name, '].[', $hierarchy_name, '].[', $level_name, '].[', concat($queryItem01_name, ' ', $strLevelAll), ']')"/>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="promptFilterItemRef">
- <xsl:variable name="querySubject" select="$basedOnQI/ancestor::*[local-name()='querySubject'][1]"/>
- <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="namespace_name" select="string($querySubject/ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="queryItem01_name" select="string($basedOnQI/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
- <xsl:variable name="memberUniqueName">
- <xsl:variable name="level01" select="$querySubject/*[local-name()='levels']/*[local-name()='level' and *[local-name()='attributes']/*[local-name()='refobj' and .= $queryItem01_name]]"/>
- <xsl:call-template name="substring-findDelimited">
- <xsl:with-param name="strString" select="$level01/*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']"/>
- <xsl:with-param name="strLeftDelimiter" select="concat('].[', $querySubject_name, '].[')"/>
- <xsl:with-param name="strRightDelimiter" select="']'"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:value-of select="concat('[', $namespace_name, '].[', $dimensionNamePrefix, $querySubject_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $level_name, ']')"/>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- <xsl:if test="$bIsMemberUniqueName">
- <xsl:copy-of select="$AllBusinessKeyRoles"/>
- </xsl:if>
- </xsl:element>
- </xsl:template>
- <!-- ============================================================================== -->
- <!-- Step 17: Baltic SAPBW datasource variables have readonly caption properties.
- In Bering, the property value is no longer readonly.
- -->
- <xsl:template match="/*[local-name()='project']/*[local-name()='dataSources']/*[local-name()='dataSource']/*[local-name()='property' and @*[local-name()='name' and .='SAP BW Variables']]/*[local-name()='property']/*[local-name()='property' and @*[local-name()='name' and .='caption']]/*[local-name()='property']">
- <xsl:element name="{local-name()}">
- <xsl:call-template name="myCopyAttributes"/>
- <xsl:attribute name="type">string</xsl:attribute>
- <xsl:apply-templates select="node()"/>
- </xsl:element>
- </xsl:template>
- <!-- =============================================================================== -->
- <!-- Global 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="32"/>
- <xsl:variable name="dimensionNamePrefix">_</xsl:variable>
- <xsl:variable name="levelNamePrefix">_</xsl:variable>
- <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:variable name="strWarnDimensionInfo">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$MODELUPGRADE_WARN_DIMENSION_INFO"/>
- <xsl:with-param name="localeVal" select="$defaultLocale"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="strWarnModelPortability">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$MODELUPGRADE_WARN_MODEL_PORTABILITY"/>
- <xsl:with-param name="localeVal" select="$defaultLocale"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:key
- name="querySubject_using_ns_qs"
- match="*[local-name()='querySubject']"
- use="concat(
- '[',
- ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]],
- '].[',
- *[local-name() = 'name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]],
- ']')"/>
- <xsl:key
- name="measureQS_using_ns_qs"
- match="*[local-name()='querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]][.//*[local-name()='queryItem' and not(not(*[local-name()='usage' and .='fact']) and not(*[local-name()='hidden' and .='true']))]]"
- use="concat(
- '[',
- ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]],
- '].[',
- *[local-name() = 'name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]],
- ']')"/>
- <xsl:key
- name="defHierQS_using_ns_qs"
- match="*[local-name()='querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]][*[local-name() = 'property' and @*[local-name() = 'name' and .='defaultHierarchy'] and .='true']]"
- use="concat(
- '[',
- ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]],
- '].[',
- *[local-name() = 'name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]],
- ']')"/>
- <xsl:key
- name="defHierQS_using_ns_dimExternalName"
- match="*[local-name()='querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]][*[local-name() = 'property' and @*[local-name() = 'name' and .='defaultHierarchy'] and .='true']]"
- use="concat(
- '[',
- ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]],
- ']',
- *[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension'])"/>
- <xsl:key
- name="altHierQS_using_ns_dimExternalName"
- match="*[local-name()='querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]][*[local-name() = 'property' and @*[local-name() = 'name' and .='defaultHierarchy'] and .='false']]"
- use="concat(
- '[',
- ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]],
- ']',
- *[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension'])"/>
- <xsl:key
- name="altHierQS_using_qsID"
- match="*[local-name()='querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]][*[local-name() = 'property' and @*[local-name() = 'name' and .='defaultHierarchy'] and .='false']]"
- use="generate-id(.)"/>
- <xsl:key
- name="querySubject_using_type"
- match="*[local-name()='querySubject']"
- use="local-name(*[local-name() = 'definition']/*)"/>
- <xsl:key
- name="candidates_using_dimExternalName_dataSourceRef"
- match="*[local-name()='querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]]"
- use="concat(
- *[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension'],
- '||',
- *[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='sources']/*[local-name()='dataSourceRef'])"/>
- <xsl:key
- name="queryItem_using_qsID"
- match="*[local-name()='queryItem' and ancestor::*[local-name() = 'querySubject']]"
- use="generate-id(ancestor::*[local-name()='querySubject'])"/>
- <xsl:key
- name="queryItem_using_qsID_qiName"
- match="*[local-name() = 'queryItem' and ancestor::*[local-name() = 'querySubject']]"
- use="concat(
- generate-id(ancestor::*[local-name()='querySubject']),
- '||',
- *[local-name() = 'name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]])"/>
- <xsl:variable name="AllQS" select="//*[local-name()='querySubject']"/>
- <xsl:variable name="AllmdQueryQS" select="key('querySubject_using_type','mdQuery')"/>
- <!-- NOTE: There's two types of dimensions in an MDQuery querySubject
- (1) Dimensions with levels and (2) Measure dimensions -->
- <!-- NOTE: AllmdQueryMeasureDimensions...there can be only *one* measure dimension per cube -->
- <xsl:variable name="AllmdQueryMeasureDimensions" select="$AllmdQueryQS[*[local-name() = 'definition' and *[local-name() = 'mdQuery']] and *[local-name()='queryItem' and not(not(*[local-name()='usage' and .='fact']) and not(*[local-name()='hidden' and .='true']))]]"/>
- <xsl:variable name="AllmdQueryDimensionAttributes" select="$AllmdQueryQS//*[local-name()='queryItem']"/>
- <!-- NOTE: The following expression uses the Becker Difference: $ns1[count(.|$ns2)!=count($ns2)] -->
- <xsl:variable name="AllmdQueryNonMeasureQS" select="$AllmdQueryQS[count(.|$AllmdQueryMeasureDimensions)!=count($AllmdQueryMeasureDimensions)]"/>
- <xsl:variable name="AllDefaultHierarchyQS" select="$AllmdQueryNonMeasureQS[not(key('altHierQS_using_qsID', generate-id()))]"/>
- <xsl:variable name="UpgradeDatatype">
- <qsType>dbQuery</qsType>
- <qsType>storedProcedure</qsType>
- </xsl:variable>
- <xsl:variable name="AllUpgradeDatatypeQuerySubjects" select="key('querySubject_using_type', xalan:nodeset($UpgradeDatatype)/*)"/>
- <xsl:variable name="AllProjectLocales_makeNodeset">
- <xsl:call-template name="lowercaseValues">
- <xsl:with-param name="nodeset" select="/*[local-name()='project']/*[local-name()='locales']/*[local-name()='locale']"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="AllProjectLocales" select="xalan:nodeset($AllProjectLocales_makeNodeset)"/>
- <xsl:variable name="AllBusinessKeyRoles">
- <xsl:element name="roles">
- <xsl:element name="role">
- <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
- <xsl:element name="name">
- <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
- <xsl:value-of select=" '_businessKey' "/>
- </xsl:element>
- </xsl:for-each>
- </xsl:element>
- </xsl:element>
- </xsl:variable>
- <xsl:variable name="AllSapAttributes_sortOnRef">
- <xsl:call-template name="AddSapAttribute">
- <xsl:with-param name="attribNameID" select="$CAPTION_dimensionUniqueName"/>
- <xsl:with-param name="attribDescID" select="$DESCRIPTION_dimensionUniqueName"/>
- <xsl:with-param name="attribDataType" select="'character'"/>
- <xsl:with-param name="attribExtName" select="'dimensionUniqueName'"/>
- <xsl:with-param name="attribRole" select="'_dimensionUniqueName'"/>
- <xsl:with-param name="sortOnRef" select="true()"/>
- </xsl:call-template>
- <xsl:call-template name="AddSapAttribute">
- <xsl:with-param name="attribNameID" select="$CAPTION_hierarchyUniqueName"/>
- <xsl:with-param name="attribDescID" select="$DESCRIPTION_hierarchyUniqueName"/>
- <xsl:with-param name="attribDataType" select="'character'"/>
- <xsl:with-param name="attribExtName" select="'hierarchyUniqueName'"/>
- <xsl:with-param name="attribRole" select="'_hierarchyUniqueName'"/>
- <xsl:with-param name="sortOnRef" select="true()"/>
- </xsl:call-template>
- <xsl:call-template name="AddSapAttribute">
- <xsl:with-param name="attribNameID" select="$CAPTION_levelLabel"/>
- <xsl:with-param name="attribDescID" select="$DESCRIPTION_levelLabel"/>
- <xsl:with-param name="attribDataType" select="'character'"/>
- <xsl:with-param name="attribExtName" select="'levelLabel'"/>
- <xsl:with-param name="attribRole" select="'_levelLabel'"/>
- <xsl:with-param name="sortOnRef" select="true()"/>
- </xsl:call-template>
- <xsl:call-template name="AddSapAttribute">
- <xsl:with-param name="attribNameID" select="$CAPTION_levelNumber"/>
- <xsl:with-param name="attribDescID" select="$DESCRIPTION_levelNumber"/>
- <xsl:with-param name="attribDataType" select="'int32'"/>
- <xsl:with-param name="attribExtName" select="'levelNumber'"/>
- <xsl:with-param name="attribRole" select="'_levelNumber'"/>
- <xsl:with-param name="sortOnRef" select="true()"/>
- </xsl:call-template>
- <xsl:call-template name="AddSapAttribute">
- <xsl:with-param name="attribNameID" select="$CAPTION_levelUniqueName"/>
- <xsl:with-param name="attribDescID" select="$DESCRIPTION_levelUniqueName"/>
- <xsl:with-param name="attribDataType" select="'character'"/>
- <xsl:with-param name="attribExtName" select="'levelUniqueName'"/>
- <xsl:with-param name="attribRole" select="'_levelUniqueName'"/>
- <xsl:with-param name="sortOnRef" select="true()"/>
- </xsl:call-template>
- <xsl:call-template name="AddSapAttribute">
- <xsl:with-param name="attribNameID" select="$CAPTION_memberCaption"/>
- <xsl:with-param name="attribDescID" select="$DESCRIPTION_memberCaption"/>
- <xsl:with-param name="attribDataType" select="'character'"/>
- <xsl:with-param name="attribExtName" select="'memberCaption'"/>
- <xsl:with-param name="attribRole" select="'_memberCaption'"/>
- <xsl:with-param name="attribHidden" select="false()"/>
- <xsl:with-param name="sortOnRef" select="true()"/>
- </xsl:call-template>
- <xsl:call-template name="AddSapAttribute">
- <xsl:with-param name="attribNameID" select="$CAPTION_memberDescription"/>
- <xsl:with-param name="attribDescID" select="$DESCRIPTION_memberDescription"/>
- <xsl:with-param name="attribDataType" select="'character'"/>
- <xsl:with-param name="attribExtName" select="'description'"/>
- <xsl:with-param name="attribRole" select="'_memberDescription'"/>
- <xsl:with-param name="sortOnRef" select="true()"/>
- </xsl:call-template>
- <xsl:call-template name="AddSapAttribute">
- <xsl:with-param name="attribNameID" select="$CAPTION_memberUniqueName"/>
- <xsl:with-param name="attribDescID" select="$DESCRIPTION_memberUniqueName"/>
- <xsl:with-param name="attribDataType" select="'character'"/>
- <xsl:with-param name="attribExtName" select="'memberUniqueName'"/>
- <xsl:with-param name="attribRole" select="'_memberUniqueName'"/>
- <xsl:with-param name="sortOnRef" select="true()"/>
- </xsl:call-template>
- <xsl:call-template name="AddSapAttribute">
- <xsl:with-param name="attribNameID" select="$CAPTION_parentUniqueName"/>
- <xsl:with-param name="attribDescID" select="$DESCRIPTION_parentUniqueName"/>
- <xsl:with-param name="attribDataType" select="'character'"/>
- <xsl:with-param name="attribExtName" select="'parentUniqueName'"/>
- <xsl:with-param name="attribRole" select="'_parentUniqueName'"/>
- <xsl:with-param name="sortOnRef" select="true()"/>
- </xsl:call-template>
- <xsl:call-template name="AddSapAttribute">
- <xsl:with-param name="attribNameID" select="'_rollupType'"/>
- <xsl:with-param name="attribDescID" select="'_rollupType'"/>
- <xsl:with-param name="attribDataType" select="'character'"/>
- <xsl:with-param name="attribExtName" select="'_rollupType'"/>
- <xsl:with-param name="attribRole" select="'_rollupType'"/>
- <xsl:with-param name="sortOnRef" select="true()"/>
- <xsl:with-param name="bLocalize" select="false()"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="AllSapAttributes">
- <xsl:variable name="nodeset_AllSapAttributes_sortOnRef" select="xalan:nodeset($AllSapAttributes_sortOnRef)"/>
- <xsl:apply-templates select="$nodeset_AllSapAttributes_sortOnRef/node()" mode="sapAttributes"/>
- </xsl:variable>
- <xsl:variable name="AllLevelLocalizedStrings">
- <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
- <xsl:element name="{.}">
- <xsl:call-template name="getLocalizedString">
- <xsl:with-param name="stringID" select="$LEVEL_ALL"/>
- <xsl:with-param name="localeVal" select="."/>
- </xsl:call-template>
- </xsl:element>
- </xsl:for-each>
- </xsl:variable>
- </xsl:stylesheet>
|