xform_32to50.xsl 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788
  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: fmmd
  5. (C) Copyright IBM Corp. 2003, 2013
  6. US Government Users Restricted Rights - Use, duplication or disclosure
  7. restricted by GSA ADP Schedule Contract with IBM Corp.
  8. -->
  9. <!--
  10. ===============================================================================
  11. Model Upgrade 32 to 50 Notes:
  12. This is an XSLT transformation from a Baltic schema version 32 model to a Bering
  13. schema version 50 model
  14. This Upgrade is required to accomodate Model Schema changes made in Bering for
  15. the following OLAP model objects:
  16. Dimension, Level, Hierarchy, Measure, and scopeRelationship.
  17. In brief, the following steps describe the transformations being performed.
  18. Note that most of the steps deal with migrating OLAP information with the
  19. exception of step 6 which is a small fix for the way the model file was
  20. originally written out, and doesn't correspond to a change in the
  21. BmtModelSpecification.xsd
  22. Steps:
  23. ======
  24. 1. Dimension objects
  25. Dimension objects are Baltic mdQuery Query Subjects having one or more
  26. levels.
  27. Measure Dimensions are Query Subjects having a definition 'mdQuery'
  28. and having all QIs usage set to 'facts' or hidden 'true'.
  29. Query Subjects of type mdQuery are converted to two objects: a Dimension
  30. object and a modelQuery querySubject with it's queryItems pointing to the
  31. dimensions' attributes (see Step 7)
  32. 1.1MR1 Hierarchies and Levels container objects are no longer used, and
  33. instead their children are simply output directly. Level(s) followed
  34. by Hierarchy objects must be moved near the end of the dimension, according
  35. to the schema.
  36. 2. Hierarchy objects
  37. The content of the Hierarchy element has been reformatted, and is now
  38. localized.
  39. "defaultHierarchy" is no longer a custom property belonging to the dimension
  40. and is now a property of the Hierarchy.
  41. 3. Level objects
  42. The content of Level element has been reformatted, and is now
  43. localized.
  44. 1.1MR1 QueryItem(s) pertaining to the particular level are now listed
  45. inside the level and 1.1MR1 Level attributes no longer exist.
  46. 4. Dimension Query item objects
  47. Filter out any query items which are refered to by the
  48. levels/level/attributes/refobjs and
  49. levels/level/key/queryItems_collection/refobjs.
  50. 5. Scope Relationship objects
  51. 1.1MR1 relationships with refobjs pointing to the new Dimensions objects,
  52. have been changed to "scopeRelationship" objects.
  53. 6. General miscellaneous cleanup.
  54. 6.1 Fixes for Baltic models which don't follow the BmtModelSpecification.
  55. BmtModelSpecification.xsd schema.
  56. * Empty security filter definitions must be removed.
  57. * Models using role-based packages, isRoleBased was mistakenly written as
  58. an element in Framework Manager releases 1.02, 1.1RTM and 1.1HOT. In
  59. 1.1MR1 it was corrected and switched to an attribute.
  60. NOTE: Previous releases of FM aren't affected since FM searched for the value in
  61. both locations.
  62. * upgrade "sql99" attribute to "native". sql99 is no longer supported in Bering.
  63. 6.2 Remove empty keys from querySubjects
  64. * Any key which has an empty queryItem collection will be removed because it
  65. is incomplete and has no meaning.
  66. 7: Convert the mdQuery querySubject to a model querySubject, with all
  67. queryItems referencing the associated hidden dimension from Step 1
  68. 8: Legacy dimensional information for Hierarchies and Levels
  69. Baltic Hierarchies and Levels are always copied as-is. The Baltic
  70. BmtModelSpecification definitions for these two objects have been carried
  71. forward for backwards compatibilty reasons, and the content is hidden from
  72. users. There is no editor in Bering which can update the legacy information.
  73. When a Baltic model is opened in the Bering studio applications, the model
  74. is upgraded on the fly. The legacy dimensional information for levels and
  75. hierarchies is there to preserve Baltic model behaviour in the Bering
  76. studio applications. When the model is upgraded in Framework Manager, the
  77. legacy information is flagged during "Verify Model" to be repaired.
  78. It's considered a best-practice approach to always run "Verify Model" once
  79. a model has been successfully upgraded in Framework Manager. This is to
  80. allow the user to make modelling decisions appropriate for their model.
  81. The legacy information for the individual objects is removed once the
  82. object has been successfully edited or repaired and the model has been
  83. saved.
  84. NOTE: For Baltic mdQuery querySubjects (ie SAPBW), Hierachy and Level
  85. objects are also upgraded to the equivalent Bering definition. So in
  86. Bering, the equivalent model querySubject has both the old Baltic and the
  87. new Bering definition for Hierarchy and Level embedded in it.
  88. 9: Generate missing localized elements for levels and hierarchies.
  89. Some localized dimension info properties were not supported in Baltic and
  90. as a result were not stored in the model.
  91. Placeholder values are generated using the locale key and the value stored
  92. in the default locale, for the following hierarchy and level properties:
  93. name, description and screenTip.
  94. 10. Hide the Bering dimensions from the published packages
  95. When upgrading a SAPBW querySubject from Baltic to Bering, a model
  96. querySubject is created along with a new Bering dimension object, which the
  97. model querySubject references. The dimension is "hidden" from view, and all
  98. the user sees is the model querySubject which has all the Baltic properties
  99. carried forward in Bering.
  100. This is to preserve any Baltic behaviour the modeler was relying upon, such
  101. as re-ordering the queryItems which cannot be done with dimensions.
  102. 11. Translate all locale keys to lowercase
  103. It seems some models contain a mix of upper and lower case when specifying
  104. the locale key.
  105. This template converts them all to lowercase going forward, to eliminate any
  106. possible mismatches due to case. Calls to translate(., $uppercase, $lowercase)
  107. are now all over this script when referring to a locale-based value
  108. 12. Governors for Data type Upgrade and Generating default dimensional information
  109. A) Data type Upgrade
  110. This upgrade is required to accomodate new data types introduced in Bering
  111. which affect dbQuery and storedProcedure query subjects.
  112. A number of new data types have been introduced in Bering that were previously
  113. mapped to other existing data types in Baltic. Framework Manager isn't able
  114. to differenciate which of the data types in a relational based Batlic model
  115. are correct or invalid, without connecting to the database to verify them.
  116. A governor called "enhanced model portability" allows for the creation of model
  117. query against different databases by ignoring the data types stored in the model.
  118. This governor is turned on if query subjects requiring this upgrade are found
  119. to exist in the model. (NOTE: This bypasses the problem but introduces a
  120. performance penalty. The model should be repaired after the upgrade has been
  121. completed so that the governor can be turned back off)
  122. All dbQuery and stored procedure Query Subjects are set to "needs reevaluation"
  123. during upgrade, and are identified afterwards during the "Upgrade Report" and
  124. "Verify Model" phase as needing to be repaired.
  125. Once all affected query subjects have been repaired by the "Verify Model" phase,
  126. the governor's old value can be restored.
  127. B) Generate default dimensional information
  128. This upgrade is required to indicate that the query engine should generate
  129. dynamic dimension info when formulating queries. This is basically the old
  130. Baltic style query generation.
  131. Verify Model will flag a warning when generateDynamicDimInfo is set to TRUE.
  132. 13. Add SAP roles to the levels
  133. In Bering, roles were added to the schema which impact Baltic SAP levels.
  134. 14. Convert 3 Part references to 5 part references
  135. In Bering, roles were added to the schema which impact Baltic SAP levels.
  136. 15. Set filterItemRef and sortOnRef to the member unique name
  137. * The key, short name, medium name, and long name properties must
  138. all set their filterItemRef property to the member unique name of the associated level
  139. See Trakker 463250, WO 1049
  140. * a sortOnRef value pointing to the memberUniqueName must be added to all queryItem attributes.
  141. 16. Add missing Level00 information to unit of measure and currency dimensions.
  142. In Baltic, support was removed for this information. In Bering, support was
  143. added back in.
  144. WARNING! The level00 information is generated based on the level01 information
  145. in the model. If the SAPBW datasource level00 information has been
  146. customized, it may not correspond to the generated level00 information.
  147. 17. SAPBW datasource variables have readonly captions.
  148. ===============================================================================
  149. -->
  150. <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">
  151. <xsl:include href="fmmd_generalTemplates.xsl"/>
  152. <xsl:strip-space elements="*"/>
  153. <xsl:output encoding="utf-8" method="xml" indent="no"/>
  154. <!-- =============================================================================== -->
  155. <!-- Step 1: Transform OLAP querySubjects into Dimensions
  156. Convert mdQuery querySubject objects which have either of the following characteristics...
  157. * at least one level (ie. a regular dimension).
  158. * all QIs usage set to 'facts' or hidden. (ie. a measure dimension)
  159. .. to a modelQuery querySubject and a corresponding dimension.
  160. NOTES:
  161. * The modelQuery querySubject's queryItems use refObjs expressions to point to the
  162. corresponding dimension attributes.
  163. * The dimension object, and the dimension's hierarchy and level objects will be renamed
  164. with underscores to prevent global naming conflicts.
  165. * The dimension is to made hidden in the package.
  166. * The queryItemFolders object is dropped only when creating measure dimensions. In some Baltic models
  167. there may be folders containing a mix of measures and queryItems objects. Bering now distinguishes
  168. between a queryItemFolder and a measureFolder and it's impossible to create duplicate folder specifications
  169. for both types of model objects.
  170. -->
  171. <!--
  172. Template: The querySubject is an mdQuery containing at least one level.
  173. Create 1) a dimension with 2) a modelQuery querySubject with all queryItems pointing to the dimension.
  174. -->
  175. <xsl:template match="*[local-name() = 'querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]][*[local-name() = 'levels' and *[local-name() = 'level']]]">
  176. <!-- Developer's NOTE: The statement below uses a [1] filter. XSLT always returns the nearest ancestor 1st -->
  177. <xsl:variable name="querySubject" select="."/>
  178. <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]])"/>
  179. <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  180. <!-- Create a modelQuery querySubject -->
  181. <xsl:apply-templates select="current()" mode="MakeQSwithDimRefs"/>
  182. <!-- 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 -->
  183. <xsl:variable name="IsQSRegularDimension">
  184. <xsl:call-template name="isRegularDimension">
  185. <xsl:with-param name="querySubject" select="$querySubject"/>
  186. </xsl:call-template>
  187. </xsl:variable>
  188. <xsl:if test="$IsQSRegularDimension = string(true())">
  189. <xsl:variable name="dimension_name" select="concat($dimensionNamePrefix, $querySubject_name)"/>
  190. <xsl:element name="dimension">
  191. <!-- Copy the attributes over to the dimension -->
  192. <xsl:call-template name="myCopyAttributes"/>
  193. <!-- Log it -->
  194. <xsl:call-template name="annotate">
  195. <!--xsl:with-param name="value" select="concat('Creating dimension from query subject ', $querySubject_name, ' found under namespace:', $namespace_name)"/-->
  196. <xsl:with-param name="value">
  197. <xsl:call-template name="getLocalizedString">
  198. <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
  199. <xsl:with-param name="localeVal" select="$defaultLocale"/>
  200. <xsl:with-param name="string1" select="$OBJECT_TYPE_DIMENSION"/>
  201. <xsl:with-param name="string2" select="$querySubject_name"/>
  202. <xsl:with-param name="string3" select="$OBJECT_TYPE_NAMESPACE"/>
  203. <xsl:with-param name="string4" select="$namespace_name"/>
  204. </xsl:call-template>
  205. </xsl:with-param>
  206. </xsl:call-template>
  207. <xsl:for-each select="node()[not(local-name() = 'property' and @*[local-name() = 'name' and .='defaultHierarchy'])][not(local-name() = 'levels' or local-name() = 'hierarchies')]">
  208. <xsl:choose>
  209. <xsl:when test="local-name() = 'name'">
  210. <!-- Change the dimension name so that it's prefixed with an underscore.
  211. Note: dimension name is localized and all values must be updated -->
  212. <xsl:element name="name">
  213. <xsl:call-template name="myCopyAttributes"/>
  214. <xsl:value-of select="concat($dimensionNamePrefix, node())"/>
  215. </xsl:element>
  216. </xsl:when>
  217. <xsl:when test="local-name() = 'queryItem'">
  218. <xsl:call-template name="copyDimensionQueryItems"/>
  219. </xsl:when>
  220. <xsl:otherwise>
  221. <xsl:apply-templates select="." mode="dimQueryItem"/>
  222. </xsl:otherwise>
  223. </xsl:choose>
  224. </xsl:for-each>
  225. <!-- Filter out the "hierarchies" container element -->
  226. <xsl:variable name="dataSourceRef" select="./*[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='sources']/*[local-name()='dataSourceRef']"/>
  227. <xsl:variable name="dimExternalName" select="$querySubject/*[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension']"/>
  228. <xsl:variable name="candidates" select="key('candidates_using_dimExternalName_dataSourceRef', concat($dimExternalName,'||', $dataSourceRef))"/>
  229. <xsl:for-each select="$candidates">
  230. <xsl:variable name="suggestedName">
  231. <xsl:value-of select="string(./*[local-name()='name'])"/>
  232. </xsl:variable>
  233. <xsl:variable name="candidateSuggestedName" select="$candidates[*[local-name()='name' and . =$suggestedName]]"/>
  234. <xsl:variable name="candidateName">
  235. <xsl:choose>
  236. <xsl:when test="count($candidateSuggestedName) > 1 and
  237. position() != 1 and
  238. $candidateSuggestedName[1] != .">
  239. <xsl:value-of select="concat($suggestedName, '_' , generate-id(.))"/>
  240. </xsl:when>
  241. <xsl:otherwise>
  242. <xsl:value-of select="$suggestedName"/>
  243. </xsl:otherwise>
  244. </xsl:choose>
  245. </xsl:variable>
  246. <!-- If the 2 nodes are exactly equivalent from a string point of view then do not create another hierarchy-->
  247. <xsl:if test="$candidateSuggestedName[1] = .">
  248. <xsl:call-template name="hierarchy">
  249. <xsl:with-param name="namespace_name" select="$namespace_name"/>
  250. <xsl:with-param name="dimension_name" select="$dimension_name"/>
  251. <xsl:with-param name="extName" select="./*[local-name()='hierarchies']/*[local-name()='hierarchy']/*[local-name()='externalName']"/>
  252. <xsl:with-param name="hierarchy_name" select="$candidateName"/>
  253. </xsl:call-template>
  254. </xsl:if>
  255. </xsl:for-each>
  256. </xsl:element>
  257. </xsl:if>
  258. </xsl:template>
  259. <!--
  260. Template: The querySubject is an mdQuery and with all queryItems are either all facts or hidden.
  261. Create 1) a hidden measure dimension 2) a modelQuery querySubject with all queryItems pointing to the dimension.
  262. -->
  263. <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']))]]">
  264. <!-- Developer's NOTE: The statement below uses a [1] filter. XSLT always returns the nearest ancestor 1st -->
  265. <xsl:variable name="namespace_name" select="string(ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  266. <xsl:variable name="querySubject_name" select="string(./*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  267. <!-- Create a modelQuery querySubject -->
  268. <xsl:apply-templates select="current()" mode="MakeQSwithDimRefs"/>
  269. <!-- Create a hidden measure dimension -->
  270. <xsl:element name="dimension">
  271. <!-- Copy the attributes over to the dimension -->
  272. <xsl:call-template name="myCopyAttributes"/>
  273. <xsl:call-template name="annotate">
  274. <!--xsl:with-param name="value" select="concat('Created measure dimension from query subject: ', $querySubject_name, ' found under namespace:' , $namespace_name)"/-->
  275. <xsl:with-param name="value">
  276. <xsl:call-template name="getLocalizedString">
  277. <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
  278. <xsl:with-param name="localeVal" select="$defaultLocale"/>
  279. <xsl:with-param name="string1" select="$OBJECT_TYPE_DIMENSION"/>
  280. <xsl:with-param name="string2" select="$querySubject_name"/>
  281. <xsl:with-param name="string3" select="$OBJECT_TYPE_NAMESPACE"/>
  282. <xsl:with-param name="string4" select="$namespace_name"/>
  283. </xsl:call-template>
  284. </xsl:with-param>
  285. </xsl:call-template>
  286. <!-- Change the dimension name so that it's prefixed with an underscore.
  287. Note: dimension name is localized and all values must be updated -->
  288. <xsl:for-each select="./*[local-name()='name']">
  289. <xsl:element name="name">
  290. <xsl:call-template name="myCopyAttributes"/>
  291. <xsl:value-of select="concat($dimensionNamePrefix, .)"/>
  292. </xsl:element>
  293. </xsl:for-each>
  294. <!-- Output the non-queryItem elements -->
  295. <!-- NOTE: The partial filter <local-name()!='name'> prevents the dimension's name from being output a second time. -->
  296. <xsl:apply-templates select="./*[local-name() != 'name' and local-name() != 'queryItem' and local-name() != 'queryItemFolder']"/>
  297. <!-- Output the queryItems which are "measure" elements -->
  298. <!-- NOTE1: queryItems can be nested in a queryItemFolder -->
  299. <!-- 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 -->
  300. <xsl:for-each select="key('queryItem_using_qsID', generate-id(.))[*[local-name() = 'usage' and .='fact']]">
  301. <xsl:call-template name="myCopy">
  302. <xsl:with-param name="elemName">measure</xsl:with-param>
  303. </xsl:call-template>
  304. </xsl:for-each>
  305. </xsl:element>
  306. </xsl:template>
  307. <!-- =============================================================================== -->
  308. <!-- Step 2: Fix OLAP QS : Fix the hierarchy object -->
  309. <xsl:template name="hierarchy">
  310. <xsl:param name="namespace_name"/>
  311. <xsl:param name="dimension_name"/>
  312. <xsl:param name="extName"/>
  313. <xsl:param name="hierarchy_name"/>
  314. <!-- Developer's NOTE: The statements below uses a [1] filter. XSLT always returns the nearest document-ordered ancestor 1st -->
  315. <xsl:variable name="querySubject" select="."/>
  316. <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  317. <xsl:element name="hierarchy">
  318. <xsl:call-template name="myCopyAttributes"/>
  319. <xsl:call-template name="localizeElement">
  320. <xsl:with-param name="basedOnItem" select="$querySubject"/>
  321. <xsl:with-param name="elementName" select="'name'"/>
  322. <xsl:with-param name="defaultValue" select="$hierarchy_name"/>
  323. </xsl:call-template>
  324. <xsl:call-template name="localizeElement">
  325. <xsl:with-param name="basedOnItem" select="$querySubject"/>
  326. <xsl:with-param name="elementName" select="'description'"/>
  327. <xsl:with-param name="defaultValue" select="$hierarchy_name"/>
  328. </xsl:call-template>
  329. <xsl:variable name="screenTip_Value">
  330. <xsl:call-template name="substring-findDelimited">
  331. <xsl:with-param name="strString" select="./*[local-name()='externalName']"/>
  332. <xsl:with-param name="strLeftDelimiter" select="'['"/>
  333. <xsl:with-param name="strRightDelimiter" select="']'"/>
  334. </xsl:call-template>
  335. </xsl:variable>
  336. <xsl:call-template name="localizeElement">
  337. <xsl:with-param name="basedOnItem" select="$querySubject"/>
  338. <xsl:with-param name="elementName" select="'screenTip'"/>
  339. <xsl:with-param name="defaultValue" select="$screenTip_Value"/>
  340. </xsl:call-template>
  341. <xsl:variable name="bUnitofMeasure_or_Currency" select="$querySubject/*[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension' and (.='[0UNIT]' or .='[0CURRENCY]')]"/>
  342. <xsl:for-each select="./*[local-name() = 'property']">
  343. <xsl:choose>
  344. <xsl:when test="$bUnitofMeasure_or_Currency and @*[local-name() = 'name' and . = 'hierarchyCardinality']">
  345. <xsl:element name="property">
  346. <xsl:attribute name="name">hierarchyCardinality</xsl:attribute>
  347. 50
  348. </xsl:element>
  349. </xsl:when>
  350. <xsl:otherwise>
  351. <xsl:call-template name="myCopy"/>
  352. </xsl:otherwise>
  353. </xsl:choose>
  354. </xsl:for-each>
  355. <xsl:element name="externalName">
  356. <xsl:value-of select="$extName"/>
  357. </xsl:element>
  358. <!-- Developer's NOTE: The statement below uses a [1] filter. XSLT always returns the nearest ancestor 1st -->
  359. <xsl:call-template name="annotate">
  360. <!--xsl:with-param name="value" select="concat('Created hierarchy: ', $hierarchy_name, ' located under namespace: ', $namespace_name)"/-->
  361. <xsl:with-param name="value">
  362. <xsl:call-template name="getLocalizedString">
  363. <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
  364. <xsl:with-param name="localeVal" select="$defaultLocale"/>
  365. <xsl:with-param name="string1" select="$OBJECT_TYPE_HIERARCHY"/>
  366. <xsl:with-param name="string2" select="$hierarchy_name"/>
  367. <xsl:with-param name="string3" select="$OBJECT_TYPE_NAMESPACE"/>
  368. <xsl:with-param name="string4" select="$namespace_name"/>
  369. </xsl:call-template>
  370. </xsl:with-param>
  371. </xsl:call-template>
  372. <xsl:if test="$bUnitofMeasure_or_Currency">
  373. <!-- Insert missing level00 model information for "units of measure" and "currency" dimensions -->
  374. <xsl:variable name="level01_name" select="./*[local-name() = 'levels']/*[local-name() = 'level']/*[local-name() = 'name'][1]"/>
  375. <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]]"/>
  376. <xsl:for-each select="$querySubject/*[local-name()='levels']/*[local-name()='level' and *[local-name()='name' and . = $level01_name]]">
  377. <xsl:call-template name="addLevel00">
  378. <xsl:with-param name="hierarchy_name" select="$hierarchy_name"/>
  379. <xsl:with-param name="basedOnQI" select="$basedOnQI"/>
  380. </xsl:call-template>
  381. </xsl:for-each>
  382. </xsl:if>
  383. <xsl:for-each select="./*[local-name() = 'levels']/*[local-name() = 'level']/*[local-name() = 'name']">
  384. <xsl:variable name="level_name" select="string(.)"/>
  385. <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]]"/>
  386. <xsl:for-each select="$querySubject/*[local-name()='levels']/*[local-name()='level' and *[local-name()='name' and . = $level_name]]">
  387. <xsl:call-template name="level">
  388. <xsl:with-param name="namespace_name" select="$namespace_name"/>
  389. <xsl:with-param name="dimension_name" select="$dimension_name"/>
  390. <xsl:with-param name="querySubject" select="$querySubject"/>
  391. <xsl:with-param name="hierarchy_name" select="$hierarchy_name"/>
  392. <xsl:with-param name="level_name" select="$level_name"/>
  393. <xsl:with-param name="basedOnQI" select="$basedOnQI"/>
  394. </xsl:call-template>
  395. </xsl:for-each>
  396. </xsl:for-each>
  397. </xsl:element>
  398. </xsl:template>
  399. <!-- =============================================================================== -->
  400. <!-- Step 3: Fix OLAP QS : Fix the level object -->
  401. <xsl:template name="level">
  402. <xsl:param name="namespace_name"/>
  403. <xsl:param name="dimension_name"/>
  404. <xsl:param name="querySubject"/>
  405. <xsl:param name="hierarchy_name"/>
  406. <xsl:param name="level_name"/>
  407. <xsl:param name="basedOnQI"/>
  408. <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  409. <xsl:element name="{local-name()}">
  410. <xsl:call-template name="annotate">
  411. <!--xsl:with-param name="value" select="concat('Created level: ', $level_name, ' located under namespace: ', $namespace_name)"/-->
  412. <xsl:with-param name="value">
  413. <xsl:call-template name="getLocalizedString">
  414. <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
  415. <xsl:with-param name="localeVal" select="$defaultLocale"/>
  416. <xsl:with-param name="string1" select="$OBJECT_TYPE_LEVEL"/>
  417. <xsl:with-param name="string2" select="$level_name"/>
  418. <xsl:with-param name="string3" select="$OBJECT_TYPE_NAMESPACE"/>
  419. <xsl:with-param name="string4" select="$namespace_name"/>
  420. </xsl:call-template>
  421. </xsl:with-param>
  422. </xsl:call-template>
  423. <xsl:call-template name="myCopyAttributes"/>
  424. <xsl:call-template name="localizeElement">
  425. <xsl:with-param name="basedOnItem" select="$basedOnQI"/>
  426. <xsl:with-param name="elementName" select="'name'"/>
  427. <xsl:with-param name="defaultValue" select="$level_name"/>
  428. </xsl:call-template>
  429. <xsl:call-template name="localizeElement">
  430. <xsl:with-param name="basedOnItem" select="$basedOnQI"/>
  431. <xsl:with-param name="elementName" select="'description'"/>
  432. <xsl:with-param name="defaultValue" select="$level_name"/>
  433. </xsl:call-template>
  434. <xsl:variable name="screenTip_Value">
  435. <xsl:call-template name="substring-findDelimited">
  436. <xsl:with-param name="strString" select="./*[local-name()='externalName']"/>
  437. <xsl:with-param name="strLeftDelimiter" select="'].['"/>
  438. <xsl:with-param name="strRightDelimiter" select="']'"/>
  439. </xsl:call-template>
  440. </xsl:variable>
  441. <xsl:call-template name="localizeElement">
  442. <xsl:with-param name="basedOnItem" select="$basedOnQI"/>
  443. <xsl:with-param name="elementName" select="'screenTip'"/>
  444. <xsl:with-param name="defaultValue" select="$screenTip_Value"/>
  445. </xsl:call-template>
  446. <xsl:for-each select="./*[local-name() = 'property']">
  447. <xsl:call-template name="myCopy"/>
  448. </xsl:for-each>
  449. <xsl:for-each select="*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']">
  450. <xsl:variable name="refobj_qsName" select="substring-before(substring-after(., '].[' ), ']')"/>
  451. <!-- takes between '].[' and ']' -->
  452. <xsl:variable name="refobj_qiName" select="substring-before(substring-after(., concat('].[', $refobj_qsName, '].[') ), ']')"/>
  453. <!-- takes between '[namespace].[qs].[' and ']' -->
  454. <xsl:apply-templates select="key('queryItem_using_qsID_qiName', concat(generate-id($querySubject), '||', $refobj_qiName))" mode="dimQueryItem"/>
  455. <xsl:variable name="bPromptType_selectDate" select="$basedOnQI/*[local-name()='datatype'] = 'date'"/>
  456. <xsl:variable name="bDimensionType_Time" select="$querySubject/*[local-name() = 'property' and @*[local-name() = 'name' and .='dimensionType']] = 'time'"/>
  457. <xsl:choose>
  458. <xsl:when test="$bDimensionType_Time or $bPromptType_selectDate">
  459. <xsl:variable name="sortOnRef_value">
  460. <xsl:if test="$bDimensionType_Time"><xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $refobj_qiName, ']')"/></xsl:if>
  461. </xsl:variable>
  462. <xsl:variable name="promptType_value">
  463. <xsl:if test="$bPromptType_selectDate"><xsl:value-of select="'selectDate'"/></xsl:if>
  464. </xsl:variable>
  465. <xsl:variable name="sortOnRef_SapAttributes" select="xalan:nodeset($AllSapAttributes_sortOnRef)"/>
  466. <xsl:apply-templates select="$sortOnRef_SapAttributes/node()" mode="sapAttributes">
  467. <xsl:with-param name="sortOnRef" select="$sortOnRef_value"/>
  468. <xsl:with-param name="promptType" select="$promptType_value"/>
  469. </xsl:apply-templates>
  470. </xsl:when>
  471. <xsl:otherwise>
  472. <xsl:copy-of select="$AllSapAttributes"/>
  473. </xsl:otherwise>
  474. </xsl:choose>
  475. </xsl:for-each>
  476. <xsl:for-each select="*[local-name()='attributes']/*[local-name()='refobj']">
  477. <xsl:variable name="refobj_qsName" select="substring-before(substring-after(., '].[' ), ']')"/>
  478. <!-- takes between '].[' and ']' -->
  479. <xsl:variable name="refobj_qiName" select="substring-before(substring-after(., concat('].[', $refobj_qsName, '].[') ), ']')"/>
  480. <!-- takes between '[namespace].[qs].[' and ']' -->
  481. <xsl:apply-templates select="key('queryItem_using_qsID_qiName', concat(generate-id($querySubject), '||', $refobj_qiName))" mode="dimQueryItem"/>
  482. </xsl:for-each>
  483. <xsl:element name="isUnique">
  484. <xsl:choose>
  485. <xsl:when test="./*[local-name()='key' and @*[local-name()='isUniqueKey' and . = 'true']]">true</xsl:when>
  486. <xsl:otherwise>false</xsl:otherwise>
  487. </xsl:choose>
  488. </xsl:element>
  489. <xsl:apply-templates select="./*[local-name()='externalName']"/>
  490. <xsl:apply-templates select="./*[local-name()='externalOrdinal']"/>
  491. </xsl:element>
  492. </xsl:template>
  493. <xsl:template match="*[local-name()='sortOnRef']" mode="sapAttributes">
  494. <xsl:param name="sortOnRef"/>
  495. <xsl:if test="$sortOnRef != ''">
  496. <xsl:element name="sortOnRef">
  497. <xsl:value-of select="$sortOnRef"/>
  498. </xsl:element>
  499. </xsl:if>
  500. </xsl:template>
  501. <xsl:template match="*[local-name()='promptType'][../../*[local-name()='externalName' and . = 'levelNumber']]/text()" mode="sapAttributes">
  502. <xsl:param name="promptType" select="'selectValue'"/>
  503. <xsl:choose>
  504. <xsl:when test="$promptType = 'selectDate'">selectDate</xsl:when>
  505. <xsl:otherwise>selectValue</xsl:otherwise>
  506. </xsl:choose>
  507. </xsl:template>
  508. <!-- Template: Default XML Copy templates with mode set.
  509. NOTE: Required to recursively pass the mode down. -->
  510. <xsl:template match="*" mode="sapAttributes">
  511. <xsl:param name="sortOnRef"/>
  512. <xsl:param name="promptType"/>
  513. <xsl:element name="{local-name()}">
  514. <xsl:apply-templates select="*|@*|text()" mode="sapAttributes">
  515. <xsl:with-param name="sortOnRef" select="$sortOnRef"/>
  516. <xsl:with-param name="promptType" select="$promptType"/>
  517. </xsl:apply-templates>
  518. </xsl:element>
  519. </xsl:template>
  520. <xsl:template match="@*" mode="sapAttributes">
  521. <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
  522. </xsl:template>
  523. <!-- =============================================================================== -->
  524. <!-- Step 4: Filter out Baltic query items now contained in the level object
  525. Filter out any query items which are refered to by the levels/level/attributes/refobjs and
  526. levels/level/key/queryItems_collection/refobjs.
  527. NOTE: Dimensional query items are processed recursively due to nested folder
  528. hierarchies.
  529. -->
  530. <xsl:template name="copyDimensionQueryItems">
  531. <xsl:variable name="querySubject" select="ancestor::*[local-name()='querySubject'][1]"/>
  532. <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  533. <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]])"/>
  534. <xsl:variable name="queryItem_name" select="string(*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  535. <xsl:variable name="attributes_refobjs" select="../*[local-name()='levels']/*[local-name()='level']/*[local-name()='attributes']/*[local-name()='refobj']"/>
  536. <xsl:variable name="levelkey_refobjs" select="../*[local-name()='levels']/*[local-name()='level']/*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']"/>
  537. <xsl:variable name="refobj_value" select="concat('[', $namespace_name, '].[', $querySubject_name, '].[', $queryItem_name, ']')"/>
  538. <xsl:if test="not($refobj_value = $attributes_refobjs) and not($refobj_value = $levelkey_refobjs)">
  539. <xsl:element name="{local-name()}">
  540. <xsl:call-template name="myCopyAttributes"/>
  541. <xsl:apply-templates select="./*" mode="dimQueryItem"/>
  542. </xsl:element>
  543. </xsl:if>
  544. </xsl:template>
  545. <!-- Template: Change the dimension element to a mdDimension -->
  546. <xsl:template match="*[local-name()='mdQuery']/*[local-name()='dimension']" mode="dimQueryItem">
  547. <xsl:apply-templates select="."/>
  548. </xsl:template>
  549. <!-- Template: Change the measure dimension element to a mdDimension -->
  550. <xsl:template match="*[local-name()='mdQuery']/*[local-name()='dimension']">
  551. <xsl:call-template name="myCopy">
  552. <xsl:with-param name="elemName">mdDimension</xsl:with-param>
  553. </xsl:call-template>
  554. </xsl:template>
  555. <!-- Template: Default XML Copy template with mode set.
  556. NOTE: Required to recursively pass the mode down. -->
  557. <xsl:template match="*" mode="dimQueryItem">
  558. <xsl:if test="local-name()!= 'queryItemFolder' and not(ancestor::*[local-name()='querysubject'][1]/*[local-name()='definition']/*[local-name()='mdQuery'])">
  559. <xsl:element name="{name(.)}">
  560. <xsl:for-each select="@*">
  561. <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
  562. </xsl:for-each>
  563. <xsl:apply-templates select="node()" mode="dimQueryItem"/>
  564. </xsl:element>
  565. </xsl:if>
  566. </xsl:template>
  567. <!-- =============================================================================== -->
  568. <!-- Step 5: Fix OLAP QS : Change relationship objects with refobjs pointing
  569. to Dimensions to "scopeRelationship" objects
  570. Note that the dimensions are prefixed with an underscore.
  571. -->
  572. <xsl:template match="*[local-name()='relationship']">
  573. <!-- NOTE: Relationships are copied over AS-IS. Relationships which are upgraded to scopeRelationships
  574. are kept around for legacy purposes and are likely ignored for the most part. -->
  575. <xsl:call-template name="myCopy"/>
  576. <xsl:variable name="leftRefobj" select="string(*[local-name() = 'expression']/*[local-name() = 'refobj'][1])"/>
  577. <!-- Get name between first '[' and ']' -->
  578. <xsl:variable name="leftnamespace_name" select="substring-before(substring-after($leftRefobj, '['), ']')"/>
  579. <!-- Get name between first '].[' and ']' -->
  580. <xsl:variable name="leftquerysubject_name" select="substring-before(substring-after($leftRefobj, '].['), ']')"/>
  581. <xsl:variable name="leftquerySubject" select="key('querySubject_using_ns_qs', concat('[', $leftnamespace_name, '].[', $leftquerysubject_name, ']'))"/>
  582. <xsl:variable name="leftMeasure" select="key('measureQS_using_ns_qs', concat('[', $leftnamespace_name, '].[', $leftquerysubject_name, ']'))"/>
  583. <xsl:variable name="IsLeftRegularDimension">
  584. <xsl:call-template name="isRegularDimension">
  585. <xsl:with-param name="querySubject" select="$leftquerySubject"/>
  586. </xsl:call-template>
  587. </xsl:variable>
  588. <xsl:variable name="rightRefobj" select="string(*[local-name() = 'expression']/*[local-name() = 'refobj'][2])"/>
  589. <!-- Get name between first '[' and ']' -->
  590. <xsl:variable name="rightnamespace_name" select="substring-before(substring-after($rightRefobj, '['), ']')"/>
  591. <!-- Get name between first '].[' and ']' -->
  592. <xsl:variable name="rightquerysubject_name" select="substring-before(substring-after($rightRefobj, '].['), ']')"/>
  593. <xsl:variable name="rightquerySubject" select="key('querySubject_using_ns_qs', concat('[', $rightnamespace_name, '].[', $rightquerysubject_name, ']'))"/>
  594. <xsl:variable name="rightMeasure" select="key('measureQS_using_ns_qs', concat('[', $rightnamespace_name, '].[', $rightquerysubject_name, ']'))"/>
  595. <xsl:variable name="IsRightRegularDimension">
  596. <xsl:call-template name="isRegularDimension">
  597. <xsl:with-param name="querySubject" select="$rightquerySubject"/>
  598. </xsl:call-template>
  599. </xsl:variable>
  600. <!--NOTE: Only the default hierarchy gets a scope relationship. The other QS are brought over as child hierarchies-->
  601. <xsl:choose>
  602. <xsl:when test="$rightMeasure and ($IsLeftRegularDimension=string(true()))">
  603. <!-- Things are in the proper order -->
  604. <xsl:element name="scopeRelationship">
  605. <xsl:element name="name">
  606. <xsl:value-of select="concat($dimensionNamePrefix, $rightquerysubject_name, ' &lt;--&gt; ', $dimensionNamePrefix, $leftquerysubject_name)"/>
  607. </xsl:element>
  608. <xsl:apply-templates select="*[local-name()='property']"/>
  609. <xsl:element name="left">
  610. <xsl:element name="refobj">
  611. <xsl:value-of select="concat('[', $leftnamespace_name, '].[', $dimensionNamePrefix, $leftquerysubject_name, ']')"/>
  612. </xsl:element>
  613. <xsl:element name="mincard">one</xsl:element>
  614. <xsl:element name="maxcard">one</xsl:element>
  615. </xsl:element>
  616. <xsl:element name="right">
  617. <xsl:element name="refobj">
  618. <xsl:value-of select="concat('[', $rightnamespace_name, '].[', $dimensionNamePrefix, $rightquerysubject_name, ']')"/>
  619. </xsl:element>
  620. <xsl:element name="mincard">many</xsl:element>
  621. <xsl:element name="maxcard">many</xsl:element>
  622. </xsl:element>
  623. </xsl:element>
  624. </xsl:when>
  625. <xsl:when test="$leftMeasure and ($IsRightRegularDimension=string(true()))">
  626. <!-- The right side has to be the measure -->
  627. <xsl:element name="scopeRelationship">
  628. <xsl:element name="name">
  629. <xsl:value-of select="concat($dimensionNamePrefix, $leftquerysubject_name, ' &lt;--&gt; ', $dimensionNamePrefix, $rightquerysubject_name)"/>
  630. </xsl:element>
  631. <xsl:apply-templates select="*[local-name()='property']"/>
  632. <xsl:element name="left">
  633. <xsl:element name="refobj">
  634. <xsl:value-of select="concat('[', $leftnamespace_name, '].[', $dimensionNamePrefix, $leftquerysubject_name, ']')"/>
  635. </xsl:element>
  636. <xsl:element name="mincard">many</xsl:element>
  637. <xsl:element name="maxcard">many</xsl:element>
  638. </xsl:element>
  639. <xsl:element name="right">
  640. <xsl:element name="refobj">
  641. <xsl:value-of select="concat('[', $rightnamespace_name, '].[', $dimensionNamePrefix, $rightquerysubject_name, ']')"/>
  642. </xsl:element>
  643. <xsl:element name="mincard">one</xsl:element>
  644. <xsl:element name="maxcard">one</xsl:element>
  645. </xsl:element>
  646. </xsl:element>
  647. </xsl:when>
  648. </xsl:choose>
  649. </xsl:template>
  650. <!-- =============================================================================== -->
  651. <!-- 6. Fixes for Baltic models which don't follow the BmtModelSpecification. -->
  652. <!-- Template: Empty security filter definitions must be removed -->
  653. <xsl:template match="*[local-name()='securityFilters']/*[local-name()='securityFilterDefinition'][not(./*)]"/>
  654. <!-- Template: Convert isRoleBased from an element to an attribute-->
  655. <xsl:template match="*[local-name()='securityViews']/*[local-name()='securityView' and *[local-name()='isRoleBased']]">
  656. <xsl:element name="{local-name()}">
  657. <xsl:attribute name="isRoleBased"><xsl:value-of select="*[local-name()='isRoleBased']"/></xsl:attribute>
  658. <xsl:for-each select="@*">
  659. <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
  660. </xsl:for-each>
  661. <xsl:apply-templates select="./*[local-name() != 'isRoleBased']"/>
  662. </xsl:element>
  663. </xsl:template>
  664. <!-- Template: Convert sql99 to native -->
  665. <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']]">
  666. <xsl:element name="{local-name()}">
  667. <xsl:attribute name="type">native</xsl:attribute>
  668. <xsl:value-of select="."/>
  669. </xsl:element>
  670. </xsl:template>
  671. <!-- Template: Remove empty keys from querySubjects -->
  672. <xsl:template match="*[local-name() = 'querySubject']/*[local-name() = 'definition']/*[local-name() = 'dbQuery']/*[local-name() = 'key' and not(./*[local-name() = 'queryItems_collection']/*)]"/>
  673. <!-- =============================================================================== -->
  674. <!-- Step 7: Convert the mdQuery querySubject to a model querySubject,
  675. with all queryItems referencing the corresponding hidden dimension which
  676. is created in Step 1.
  677. This is a collection of templates with mode set to 'MakeQSwithDimRefs"
  678. -->
  679. <!-- Template: Change the definition's mdQuery to a modelQuery -->
  680. <xsl:template match="*[local-name()='mdQuery']" mode="MakeQSwithDimRefs">
  681. <xsl:element name="modelQuery">
  682. <xsl:element name="sql"/>
  683. <xsl:apply-templates select="./*[local-name()='filters']" mode="MakeQSwithDimRefs"/>
  684. </xsl:element>
  685. </xsl:template>
  686. <!-- Template: Change the dimension element to a mdDimension (in order to
  687. eliminate confusion between the new Dimension object and the old Baltic
  688. querySubject/definition/mdQuery/Dimension
  689. -->
  690. <xsl:template match="*[local-name()='dimension']" mode="MakeQSwithDimRefs">
  691. <xsl:call-template name="myCopy">
  692. <xsl:with-param name="elemName">mdDimension</xsl:with-param>
  693. </xsl:call-template>
  694. </xsl:template>
  695. <!-- Template: Determines if the given querySubject should be used to create
  696. a regular dimension.
  697. SAPBW dimensions are based on query subjects containing a default hierarchy.
  698. In the case where no default hierarchy is specified, the dimension is based on
  699. the first alternate hierarchy.
  700. -->
  701. <xsl:template name="isRegularDimension">
  702. <xsl:param name="querySubject" select="."/>
  703. <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]])"/>
  704. <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  705. <xsl:variable name="dimExternalName" select="$querySubject/*[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension']"/>
  706. <xsl:variable name="IsDefHierQS" select="key('defHierQS_using_ns_qs', concat('[', $namespace_name, '].[', $querySubject_name, ']'))"/>
  707. <xsl:variable name="defHierQS" select="key('defHierQS_using_ns_dimExternalName', concat('[', $namespace_name, ']', $dimExternalName))"/>
  708. <xsl:variable name="firstAltHier" select="key('altHierQS_using_ns_dimExternalName', concat('[', $namespace_name, ']', $dimExternalName))[1]"/>
  709. <xsl:value-of select="$IsDefHierQS or (not($defHierQS) and (generate-id($firstAltHier) = generate-id($querySubject)))"/>
  710. </xsl:template>
  711. <!-- Template: Determine the dimension name for a given a Baltic querySubject
  712. When given a Baltic query subject not involving an alternate hierarchy,
  713. simply use the name of the querySubject.
  714. When given a Baltic query subject for an alternate hierarchy, either use the name of
  715. the corresponding default hierarchy querySubject or when no default hierarchy
  716. is found, use the name of the first alternate hierarchy found.
  717. NOTE: All generated dimension names are prefixed with an underscore to prevent object
  718. name collisions with the corresponding model query subject.
  719. -->
  720. <xsl:template name="getDimensionName">
  721. <xsl:param name="querySubject" select="."/>
  722. <xsl:variable name="dimExternalName" select="$querySubject/*[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension']"/>
  723. <xsl:if test="$dimExternalName">
  724. <xsl:choose>
  725. <xsl:when test="key('altHierQS_using_qsID', generate-id($querySubject))">
  726. <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]])"/>
  727. <xsl:variable name="defHierQS" select="key('defHierQS_using_ns_dimExternalName', concat('[', $namespace_name, ']', $dimExternalName))"/>
  728. <xsl:choose>
  729. <xsl:when test="$defHierQS">
  730. <xsl:value-of select="concat($dimensionNamePrefix, $defHierQS/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  731. </xsl:when>
  732. <xsl:otherwise>
  733. <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]])"/>
  734. </xsl:otherwise>
  735. </xsl:choose>
  736. </xsl:when>
  737. <xsl:otherwise>
  738. <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  739. <xsl:value-of select="concat($dimensionNamePrefix, $querySubject_name)"/>
  740. </xsl:otherwise>
  741. </xsl:choose>
  742. </xsl:if>
  743. </xsl:template>
  744. <!-- Template: Change the queryItem to use a refobj to the dimension.
  745. Append an <expression> which uses a refobj to the dimension, after the
  746. last property or screenTip element, whichever is positionally the last one
  747. to occur.
  748. Depending on whether or not the model queryItem is pointing to a measure
  749. or an attribute determines whether a 3 or 5 part name is required. 5 part
  750. names require the hierarchy and level names be calculated.
  751. Strip the queryItem's <columnName> since it doesn't apply to
  752. modelQuery querySubjects
  753. NOTE: Baltic querySubjects with dimInfo containing measures are split into a modelQuery
  754. and a hidden measure dimension which the modelQuery points to. However, Baltic hidden
  755. queryItems (which are keys to the dimension hierarchies) have no representation
  756. in the Bering measure dimension, so these expressions which are now in the modelQuery
  757. must be retargeted using relationships in the model existing between the hidden
  758. queryItem and the key for the dimension's hierarchy.
  759. -->
  760. <xsl:template match="*[local-name()='queryItem']" mode="MakeQSwithDimRefs">
  761. <xsl:variable name="queryItem" select="."/>
  762. <xsl:variable name="queryItem_name" select="string($queryItem/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  763. <xsl:variable name="querySubject" select="ancestor::*[local-name()='querySubject'][1]"/>
  764. <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  765. <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]])"/>
  766. <xsl:element name="queryItem">
  767. <!--Copy over the queryItem's attributes-->
  768. <xsl:call-template name="myCopyAttributes"/>
  769. <!--Copy over the queryItem's children-->
  770. <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()])"/>
  771. <xsl:for-each select="node()">
  772. <xsl:choose>
  773. <xsl:when test="local-name() = 'columnName'"/>
  774. <!-- Strip the columnName -->
  775. <xsl:when test="generate-id(.) = $generateidAnchorForExpression">
  776. <!-- The anchor position to insert the <expression> has been found -->
  777. <!-- Copy the anchor element over -->
  778. <xsl:call-template name="myCopy"/>
  779. <!-- Create the <expression> to append after the anchor-->
  780. <xsl:variable name="dimension_name">
  781. <xsl:call-template name="getDimensionName">
  782. <xsl:with-param name="querySubject" select="$querySubject"/>
  783. </xsl:call-template>
  784. </xsl:variable>
  785. <xsl:choose>
  786. <xsl:when test="$AllmdQueryMeasureDimensions[generate-id() = generate-id($querySubject)]">
  787. <xsl:element name="expression">
  788. <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]"/>
  789. <xsl:choose>
  790. <!-- NOTE: If the query item is an embedded calc then the expression already points where it is supposed to so leave it as is -->
  791. <xsl:when test="$embeddedCalc">
  792. <xsl:for-each select="$embeddedCalc/../*[local-name()='expression']/node()">
  793. <xsl:call-template name="myCopy"/>
  794. </xsl:for-each>
  795. </xsl:when>
  796. <!-- 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 -->
  797. <xsl:when test="$queryItem/*[local-name() ='hidden' and . = 'true']">
  798. <xsl:element name="refobj">
  799. <xsl:call-template name="resolveRelationshipReference">
  800. <xsl:with-param name="refObj" select="concat('[', $namespace_name, '].[', $querySubject_name, '].[', $queryItem_name, ']')"/>
  801. </xsl:call-template>
  802. </xsl:element>
  803. </xsl:when>
  804. <!-- NOTE: queryItem is changed to a refobj expression pointing to the Dimension's measure.
  805. [Namespace].[querySubject].[queryItem] is mapped to [Namespace].[Dimension].[Attribute] -->
  806. <xsl:otherwise>
  807. <xsl:element name="refobj">
  808. <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $queryItem_name, ']')"/>
  809. </xsl:element>
  810. </xsl:otherwise>
  811. </xsl:choose>
  812. </xsl:element>
  813. </xsl:when>
  814. <xsl:otherwise>
  815. <!-- NOTE: queryItem is changed to a refobj expression pointing to the Dimension's attribute.
  816. [Namespace].[querySubject].[queryItem] is mapped to [Namespace].[Dimension].[Hierarchy].[Level].[Attribute] -->
  817. <xsl:variable name="attributes_refobjs" select="$querySubject/*[local-name()='levels']/*[local-name()='level']/*[local-name()='attributes']/*[local-name()='refobj']"/>
  818. <xsl:variable name="levelkey_refobjs" select="$querySubject/*[local-name()='levels']/*[local-name()='level']/*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']"/>
  819. <xsl:variable name="refobj_value" select="concat('[', $namespace_name, '].[', $querySubject_name, '].[', $queryItem_name, ']')"/>
  820. <xsl:element name="expression">
  821. <xsl:variable name="attribute_refobj" select="$attributes_refobjs[. = $refobj_value]"/>
  822. <xsl:variable name="levelkey_refobj" select="$levelkey_refobjs[. = $refobj_value]"/>
  823. <xsl:choose>
  824. <xsl:when test="$attribute_refobj">
  825. <xsl:variable name="level_name" select="string($attribute_refobj/../../*[local-name()='name'])"/>
  826. <xsl:variable name="hierarchy_name" select="string($querySubject/*[local-name()='hierarchies']/*[local-name()='hierarchy']/*[local-name()='name'])"/>
  827. <xsl:element name="refobj">
  828. <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $queryItem_name, ']')"/>
  829. </xsl:element>
  830. <xsl:call-template name="annotate">
  831. <!--xsl:with-param name="value" select="concat('Created attribute from query Item called: ', $queryItem_name, ' found under level: ', $level_name)"/-->
  832. <xsl:with-param name="value">
  833. <xsl:call-template name="getLocalizedString">
  834. <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
  835. <xsl:with-param name="localeVal" select="$defaultLocale"/>
  836. <xsl:with-param name="string1" select="$OBJECT_TYPE_ATTRIBUTE"/>
  837. <xsl:with-param name="string2" select="$queryItem_name"/>
  838. <xsl:with-param name="string3" select="$OBJECT_TYPE_LEVEL"/>
  839. <xsl:with-param name="string4" select="$level_name"/>
  840. </xsl:call-template>
  841. </xsl:with-param>
  842. </xsl:call-template>
  843. </xsl:when>
  844. <xsl:when test="$levelkey_refobj">
  845. <xsl:variable name="level_name" select="string($levelkey_refobj/../../../*[local-name()='name'])"/>
  846. <xsl:variable name="hierarchy_name" select="string($querySubject/*[local-name()='hierarchies']/*[local-name()='hierarchy']/*[local-name()='name'])"/>
  847. <xsl:element name="refobj">
  848. <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $queryItem_name, ']')"/>
  849. </xsl:element>
  850. <xsl:call-template name="annotate">
  851. <!--xsl:with-param name="value" select="concat('Created level key from attribute called: ', $queryItem_name, ' found under level: ', $level_name)"/-->
  852. <xsl:with-param name="value">
  853. <xsl:call-template name="getLocalizedString">
  854. <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
  855. <xsl:with-param name="localeVal" select="$defaultLocale"/>
  856. <xsl:with-param name="string1" select="$OBJECT_TYPE_KEY"/>
  857. <xsl:with-param name="string2" select="$queryItem_name"/>
  858. <xsl:with-param name="string3" select="$OBJECT_TYPE_LEVEL"/>
  859. <xsl:with-param name="string4" select="$level_name"/>
  860. </xsl:call-template>
  861. </xsl:with-param>
  862. </xsl:call-template>
  863. </xsl:when>
  864. <xsl:otherwise>
  865. <xsl:message terminate="yes">
  866. <xsl:value-of select="concat('refobj', $nOldSchema, ' model.')"/>
  867. </xsl:message>
  868. </xsl:otherwise>
  869. </xsl:choose>
  870. </xsl:element>
  871. </xsl:otherwise>
  872. </xsl:choose>
  873. </xsl:when>
  874. <xsl:otherwise>
  875. <!--Copy over the queryItem's child -->
  876. <xsl:apply-templates select="."/>
  877. </xsl:otherwise>
  878. </xsl:choose>
  879. </xsl:for-each>
  880. </xsl:element>
  881. </xsl:template>
  882. <!-- Template: Rename the levels element to <_levels> and hierarchies to
  883. <_hierarchies>.
  884. NOTE: Since the mode was specified for processing mdQuery query subjects,
  885. the templates in step 7 are not being triggered automatically since they are not
  886. mode specific.
  887. This template simply removes the mode specification for hierarchies and levels so
  888. that normal template processing occurs.
  889. -->
  890. <xsl:template match="*[local-name()='levels' or local-name()='hierarchies']" mode="MakeQSwithDimRefs">
  891. <xsl:apply-templates select="."/>
  892. </xsl:template>
  893. <!-- Template: Default XML Copy template with mode set.
  894. NOTE: Required to recursively pass the mode down. -->
  895. <xsl:template match="*" mode="MakeQSwithDimRefs">
  896. <xsl:element name="{local-name()}">
  897. <xsl:for-each select="@*">
  898. <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
  899. </xsl:for-each>
  900. <xsl:apply-templates select="node()" mode="MakeQSwithDimRefs"/>
  901. </xsl:element>
  902. </xsl:template>
  903. <!-- =============================================================================== -->
  904. <!-- Step 8: Copy all hierarchies and levels elements in-tact, but rename their
  905. children to <_level> and <_hierarchy>
  906. Hierarchies and Levels are left as-is for backwards compatibilty reasons.
  907. The BmtModelSpecification as it was defined back in Baltic has been carried
  908. forward.
  909. Their children are now prefixed with an underscore.
  910. This is to be able to differentiate inside dimensions objects between the backwards
  911. compatible stuctures and the upgraded ones. Dimensions have both <level>
  912. and <_level> and <hierarchy> and <_hierarchy> elements.
  913. -->
  914. <xsl:template match="*[local-name()='querySubject']/*[local-name()='levels' or local-name()='hierarchies']">
  915. <xsl:element name="{local-name()}">
  916. <xsl:for-each select="./*">
  917. <xsl:call-template name="myCopy">
  918. <xsl:with-param name="elemName" select="concat($levelNamePrefix, local-name())"/>
  919. </xsl:call-template>
  920. </xsl:for-each>
  921. </xsl:element>
  922. </xsl:template>
  923. <!-- =============================================================================== -->
  924. <!-- Step 9: Generate dummy localized elements for dimensions that are missing corresponding Baltic properties.
  925. NOTE: Baltic didn't store localized properties for level and hierarchy name, description and screenTip elements.
  926. The dummy placeholder consists of a prefix containing the locale key and simply uses the existing value in the
  927. <defaultLocale> ie. Design locale, duplicating the behaviour in Framework Manager when a new locale is added to
  928. the model.
  929. Example: Assuming the default locale is "en"...
  930. <level>
  931. <name locale="en">Value</name>
  932. <name locale="fr">(fr) Value</name>
  933. </level>
  934. -->
  935. <xsl:template name="localizeElement">
  936. <xsl:param name="basedOnItem"/>
  937. <xsl:param name="elementName" select="local-name()"/>
  938. <xsl:param name="defaultValue" select="."/>
  939. <xsl:element name="{$elementName}">
  940. <xsl:attribute name="locale"><xsl:value-of select="$defaultLocale"/></xsl:attribute>
  941. <xsl:value-of select="$defaultValue"/>
  942. </xsl:element>
  943. <xsl:for-each select="$AllProjectLocales/*[local-name()='locale' and . != $defaultLocale]">
  944. <xsl:variable name="localItr" select="."/>
  945. <xsl:element name="{$elementName}">
  946. <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
  947. <xsl:choose>
  948. <xsl:when test="$basedOnItem">
  949. <xsl:value-of select="$basedOnItem/*[local-name()=$elementName and @*[local-name()='locale' and . = $localItr]]"/>
  950. </xsl:when>
  951. <xsl:when test="$defaultValue = ''">
  952. <xsl:value-of select="''"/>
  953. </xsl:when>
  954. <xsl:otherwise>
  955. <xsl:value-of select="concat('(', . , ') ' , $defaultValue)"/>
  956. </xsl:otherwise>
  957. </xsl:choose>
  958. </xsl:element>
  959. </xsl:for-each>
  960. </xsl:template>
  961. <!-- =============================================================================== -->
  962. <!-- Step 10: Alter security views to hide the Bering dimensions from the published package
  963. When upgrading a SAPBW querySubject from Baltic to Bering, a model querySubject is created along with a new
  964. Bering dimension object, which the model querySubject references. The dimension is "hidden" from view, and all
  965. the user sees is the model querySubject.
  966. This is to preserve any Baltic behaviour the modeler was relying upon, such as re-ordering the queryItems which
  967. cannot be done with dimensions.
  968. -->
  969. <xsl:template match="*[local-name()='securityView']/*[local-name()='definition']">
  970. <xsl:element name="definition">
  971. <xsl:for-each select="./*[local-name()='set']">
  972. <xsl:element name="set">
  973. <xsl:attribute name="includeRule"><xsl:value-of select="./@*[local-name()='includeRule']"/></xsl:attribute>
  974. <xsl:for-each select="./*[local-name()='refobj']">
  975. <xsl:variable name="id">
  976. <xsl:value-of select="./*[local-name()='refobj']"/>
  977. </xsl:variable>
  978. <xsl:variable name="qsName" select="substring-before(substring-after($id, '].[' ), ']')"/>
  979. <xsl:variable name="regDim" select="$AllmdQueryQS/*[local-name()='name' and .=$qsName]"/>
  980. <xsl:variable name="measureDim" select="$AllmdQueryMeasureDimensions/*[local-name()='name' and .=$qsName]"/>
  981. <xsl:if test="not($regDim) and not($measureDim)">
  982. <xsl:call-template name="myCopy"/>
  983. </xsl:if>
  984. </xsl:for-each>
  985. </xsl:element>
  986. </xsl:for-each>
  987. <xsl:if test="$AllmdQueryQS or $AllmdQueryMeasureDimensions">
  988. <xsl:element name="set">
  989. <xsl:attribute name="includeRule">hide</xsl:attribute>
  990. <!-- For every Baltic mdQuery querySubject dimension, hide the corresponding Bering generated dimension -->
  991. <xsl:for-each select="$AllDefaultHierarchyQS | $AllmdQueryMeasureDimensions">
  992. <xsl:element name="refobj">
  993. <xsl:value-of select="concat('[' ,ancestor::*[local-name()='namespace'][1]/*[local-name()='name'],']', '.' , '[' , $dimensionNamePrefix, ./*[local-name()='name'], ']')"/>
  994. </xsl:element>
  995. </xsl:for-each>
  996. </xsl:element>
  997. </xsl:if>
  998. </xsl:element>
  999. </xsl:template>
  1000. <!-- =============================================================================== -->
  1001. <!-- Step 11: Translate all locale keys to lowercase
  1002. -->
  1003. <xsl:template match="@*[local-name() = 'locale']/text()">
  1004. <xsl:value-of select="translate(., $uppercase, $lowercase)"/>
  1005. </xsl:template>
  1006. <xsl:template match="/*[local-name() = 'project']/*[local-name() = 'locales']/*[local-name() = 'locale']/text()">
  1007. <xsl:value-of select="translate(., $uppercase, $lowercase)"/>
  1008. </xsl:template>
  1009. <xsl:template match="/*[local-name() = 'project']/*[local-name() = 'defaultLocale']/text()">
  1010. <xsl:value-of select="translate(., $uppercase, $lowercase)"/>
  1011. </xsl:template>
  1012. <!-- ============================================================================== -->
  1013. <!-- Step 12: Set the governors and flag all querySubjects requiring data type upgrading to "needs reevaluation".
  1014. * Remove the old governors for "Enhanced Model Portability" (to prevent duplicate occurances)
  1015. * Insert the new governor value for Enhanced Model Portability.
  1016. * Insert the new governor value to Generate default dimensional information
  1017. * Insert the new governor value for "useSQLWithClause"
  1018. * Set all querySubjects of type dbQuery and stored procedure to "needs reevaluation", and annotate them accordingly
  1019. to trigger the Model Report dialog and the "verify model"
  1020. -->
  1021. <!-- 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 -->
  1022. <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')]]">
  1023. </xsl:template>
  1024. <!-- Template: Insert the new governor values -->
  1025. <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()]">
  1026. <xsl:variable name="AllGovernors" select="/*[local-name()='project']/*[local-name()='parameterMaps']/*[local-name()='parameterMap' and *[local-name() = 'name' and . = '_governor']]"/>
  1027. <xsl:variable name="governor_useMetadataCallback" select="$AllGovernors/*[local-name()='parameterMapEntry' and *[local-name()='key' and . = 'useMetadataCallback']]"/>
  1028. <!-- Copy the anchor element -->
  1029. <xsl:if test="not(*[local-name()='key' and (. = 'useMetadataCallback' or . = 'useSQLWithClause')])">
  1030. <xsl:call-template name="myCopy"/>
  1031. </xsl:if>
  1032. <!-- Insert the governors -->
  1033. <!-- Insert the governor "useMetadataCallback" for enhanced model portability if the model contains querySubjects requiring it
  1034. NOTE: This entry is annotated at the project level so it appears at the top of the report. -->
  1035. <xsl:choose>
  1036. <xsl:when test="$AllUpgradeDatatypeQuerySubjects">
  1037. <xsl:element name="parameterMapEntry">
  1038. <xsl:element name="key">useMetadataCallback</xsl:element>
  1039. <xsl:element name="value">false</xsl:element>
  1040. </xsl:element>
  1041. </xsl:when>
  1042. <xsl:otherwise>
  1043. <!-- If the governor previously existed in the model, put the old value back.
  1044. NOTE: The governor is stripped out of the model by the previous template, to prevent a duplicate from being inserted. -->
  1045. <xsl:for-each select="$governor_useMetadataCallback">
  1046. <xsl:call-template name="myCopy"/>
  1047. </xsl:for-each>
  1048. </xsl:otherwise>
  1049. </xsl:choose>
  1050. <!-- Insert the governor "useSQLWithClause" -->
  1051. <xsl:variable name="governor_useSQLWithClause" select="$AllGovernors/*[local-name()='parameterMapEntry' and *[local-name()='key' and . = 'useSQLWithClause']]"/>
  1052. <xsl:choose>
  1053. <!-- If the governor previously existed in the model, put the old value back.
  1054. NOTE: The governor is stripped out of the model by the previous template, to prevent a duplicate from being inserted. -->
  1055. <xsl:when test="$governor_useSQLWithClause">
  1056. <xsl:for-each select="$governor_useSQLWithClause">
  1057. <xsl:call-template name="myCopy"/>
  1058. </xsl:for-each>
  1059. </xsl:when>
  1060. <xsl:otherwise>
  1061. <xsl:element name="parameterMapEntry">
  1062. <xsl:element name="key">useSQLWithClause</xsl:element>
  1063. <xsl:element name="value">false</xsl:element>
  1064. </xsl:element>
  1065. </xsl:otherwise>
  1066. </xsl:choose>
  1067. <!-- Insert the governor "dynamicDimensionInfo" for CQE to generate dynamic dimensional information as per the old Baltic style query generation. -->
  1068. <xsl:element name="parameterMapEntry">
  1069. <xsl:element name="key">dynamicDimensionInfo</xsl:element>
  1070. <xsl:element name="value">true</xsl:element>
  1071. </xsl:element>
  1072. <xsl:call-template name="annotate">
  1073. <xsl:with-param name="value" select="$strWarnDimensionInfo"/>
  1074. </xsl:call-template>
  1075. </xsl:template>
  1076. <!-- Template: Annotate the project element -->
  1077. <xsl:template match="*[local-name() = 'project']/*[1]">
  1078. <xsl:if test="$AllUpgradeDatatypeQuerySubjects">
  1079. <xsl:call-template name="annotate">
  1080. <xsl:with-param name="value" select="$strWarnModelPortability"/>
  1081. </xsl:call-template>
  1082. </xsl:if>
  1083. <!-- Copy the anchor -->
  1084. <xsl:call-template name="myCopy"/>
  1085. </xsl:template>
  1086. <!-- Template: All dbQuery and stored procedure Query Subjects are set to "needs reevaluation", and marked with
  1087. a hidden custom property to identify all querySubjects requiring the use of the "enhanced model portability" governor. -->
  1088. <xsl:template match="*[local-name() = 'querySubject'][*[local-name() = 'definition' and *[local-name() = 'dbQuery' or local-name() = 'storedProcedure']]]">
  1089. <xsl:variable name="namespace_name" select="string(ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  1090. <xsl:variable name="querySubject_name" select="string(current()/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  1091. <xsl:element name="{name(.)}">
  1092. <!-- Set the status -->
  1093. <xsl:attribute name="status">needsReevaluation</xsl:attribute>
  1094. <xsl:for-each select="./*">
  1095. <xsl:choose>
  1096. <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()])">
  1097. <!-- Copy the anchor element over -->
  1098. <xsl:call-template name="myCopy"/>
  1099. <!-- Append the custom property used for "Verify Model" -->
  1100. <xsl:element name="property">
  1101. <xsl:attribute name="name">enhancedModelPortabilityRequired</xsl:attribute>
  1102. <xsl:attribute name="type">hidden</xsl:attribute>
  1103. <xsl:value-of select="true"/>
  1104. </xsl:element>
  1105. </xsl:when>
  1106. <xsl:otherwise>
  1107. <xsl:apply-templates select="."/>
  1108. </xsl:otherwise>
  1109. </xsl:choose>
  1110. </xsl:for-each>
  1111. </xsl:element>
  1112. </xsl:template>
  1113. <!-- ============================================================================== -->
  1114. <!-- Step 13: Add roles for the SAP Levels
  1115. -->
  1116. <xsl:template match="*[local-name()='queryItem' and *[local-name()='columnName' and .='[MEMBER_UNIQUE_NAME]']]/*[last()]" mode="dimQueryItem">
  1117. <!-- Copy anchor -->
  1118. <xsl:element name="{local-name(.)}">
  1119. <xsl:for-each select="@*">
  1120. <xsl:attribute name="{local-name(.)}"><xsl:value-of select="."/></xsl:attribute>
  1121. </xsl:for-each>
  1122. <xsl:apply-templates select="node()" mode="dimQueryItem"/>
  1123. </xsl:element>
  1124. <xsl:copy-of select="$AllBusinessKeyRoles"/>
  1125. </xsl:template>
  1126. <xsl:template name="AddSapAttribute">
  1127. <xsl:param name="attribNameID"/>
  1128. <xsl:param name="attribDescID"/>
  1129. <xsl:param name="attribDataType"/>
  1130. <xsl:param name="attribExtName"/>
  1131. <xsl:param name="attribRole"/>
  1132. <xsl:param name="sortOnRef" select="false()"/>
  1133. <xsl:param name="attribHidden" select="true()"/>
  1134. <xsl:param name="bLocalize" select="true()"/>
  1135. <xsl:element name="queryItem">
  1136. <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
  1137. <xsl:element name="name">
  1138. <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
  1139. <xsl:call-template name="getLocalizedString">
  1140. <xsl:with-param name="stringID" select="$attribNameID"/>
  1141. <xsl:with-param name="localeVal" select="."/>
  1142. <xsl:with-param name="bLocalize" select="$bLocalize"/>
  1143. </xsl:call-template>
  1144. </xsl:element>
  1145. </xsl:for-each>
  1146. <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
  1147. <xsl:element name="description">
  1148. <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
  1149. <xsl:call-template name="getLocalizedString">
  1150. <xsl:with-param name="stringID" select="$attribDescID"/>
  1151. <xsl:with-param name="localeVal" select="."/>
  1152. <xsl:with-param name="bLocalize" select="$bLocalize"/>
  1153. </xsl:call-template>
  1154. </xsl:element>
  1155. </xsl:for-each>
  1156. <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
  1157. <xsl:element name="screenTip">
  1158. <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
  1159. <xsl:call-template name="getLocalizedString">
  1160. <xsl:with-param name="stringID" select="$attribDescID"/>
  1161. <xsl:with-param name="localeVal" select="."/>
  1162. <xsl:with-param name="bLocalize" select="$bLocalize"/>
  1163. </xsl:call-template>
  1164. </xsl:element>
  1165. </xsl:for-each>
  1166. <xsl:element name="externalName">
  1167. <xsl:value-of select="$attribExtName"/>
  1168. </xsl:element>
  1169. <xsl:if test="$attribHidden">
  1170. <xsl:element name="hidden">true</xsl:element>
  1171. </xsl:if>
  1172. <xsl:element name="usage">attribute</xsl:element>
  1173. <xsl:element name="datatype">
  1174. <xsl:value-of select="$attribDataType"/>
  1175. </xsl:element>
  1176. <xsl:element name="promptInfo">
  1177. <xsl:element name="promptType">
  1178. <xsl:choose>
  1179. <!-- sortOnRef is supplied when the hierarchyType is 'date' -->
  1180. <xsl:when test="$attribExtName = 'levelNumber'">selectDate</xsl:when>
  1181. <xsl:otherwise>selectValue</xsl:otherwise>
  1182. </xsl:choose>
  1183. </xsl:element>
  1184. </xsl:element>
  1185. <xsl:if test="$sortOnRef">
  1186. <xsl:element name="sortOnRef"/>
  1187. </xsl:if>
  1188. <xsl:element name="roles">
  1189. <xsl:element name="role">
  1190. <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
  1191. <xsl:element name="name">
  1192. <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
  1193. <xsl:value-of select="$attribRole"/>
  1194. </xsl:element>
  1195. </xsl:for-each>
  1196. </xsl:element>
  1197. </xsl:element>
  1198. </xsl:element>
  1199. </xsl:template>
  1200. <!-- ============================================================================== -->
  1201. <!-- Step 14: Convert 3 Part references to 5 part references
  1202. -->
  1203. <!-- Template: Convert promptDisplayItemRef from a 3-Part reference to a 5-Part Reference -->
  1204. <xsl:template match="*[local-name()='promptDisplayItemRef']/text()" mode="dimQueryItem">
  1205. <xsl:variable name="refobj_value" select="."/>
  1206. <xsl:variable name="namespace_name" select="substring-before(substring-after(., '['), ']')"/>
  1207. <!-- takes between '[' and ']' -->
  1208. <xsl:variable name="querySubject_name" select="substring-before(substring-after(., '].[' ), ']')"/>
  1209. <!-- takes between '].[' and ']' -->
  1210. <xsl:variable name="queryItem_name" select="substring-before(substring-after(., concat('].[', $querySubject_name, '].[') ), ']')"/>
  1211. <!-- takes between '[namespace].[qs].[' and ']' -->
  1212. <xsl:variable name="querySubject" select="ancestor::*[local-name()='querySubject'][1]"/>
  1213. <xsl:variable name="level_name">
  1214. <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']"/>
  1215. <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']"/>
  1216. <xsl:value-of select="$attribute_refobj_name|$levelkey_refobj_name"/>
  1217. </xsl:variable>
  1218. <!-- Create the <expression> to append after the anchor-->
  1219. <xsl:variable name="dimension_name">
  1220. <xsl:call-template name="getDimensionName">
  1221. <xsl:with-param name="querySubject" select="$querySubject"/>
  1222. </xsl:call-template>
  1223. </xsl:variable>
  1224. <xsl:variable name="hierarchy_name" select="string($querySubject/*[local-name()='hierarchies']/*[local-name()='hierarchy']/*[local-name()='name'])"/>
  1225. <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $queryItem_name, ']')"/>
  1226. </xsl:template>
  1227. <!-- ============================================================================== -->
  1228. <!-- Step 15: Set filterItemRef and sortOnRef to the member unique name
  1229. * The key, short name, medium name, and long name properties must
  1230. all set their filterItemRef property to the member unique name of the associated level
  1231. See Trakker 463250, WO 1049
  1232. * a sortOnRef value pointing to the memberUniqueName must be added to all queryItem attributes.
  1233. -->
  1234. <xsl:template match="*[local-name()='queryItem' and *[local-name()='usage' and .='attribute']]" mode="dimQueryItem">
  1235. <xsl:element name="queryItem">
  1236. <xsl:call-template name="myCopyAttributes"/>
  1237. <xsl:apply-templates select="*[local-name() != 'promptInfo' and local-name() != 'sortOnRef']" mode="dimQueryItem"/>
  1238. <xsl:variable name="queryItem" select="."/>
  1239. <xsl:variable name="queryItem_name" select="string($queryItem/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  1240. <xsl:variable name="querySubject" select="$queryItem/ancestor::*[local-name()='querySubject'][1]"/>
  1241. <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  1242. <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]])"/>
  1243. <xsl:variable name="refobj_value" select="concat('[', $namespace_name, '].[', $querySubject_name, '].[', $queryItem_name, ']')"/>
  1244. <xsl:variable name="level" select="$querySubject/*[local-name()='levels']/*[local-name()='level' and *[local-name()='attributes']/*[local-name()='refobj' and .= $refobj_value]]"/>
  1245. <xsl:variable name="level_name" select="$level/*[local-name()='name']"/>
  1246. <xsl:variable name="dimension_name">
  1247. <xsl:call-template name="getDimensionName">
  1248. <xsl:with-param name="querySubject" select="$querySubject"/>
  1249. </xsl:call-template>
  1250. </xsl:variable>
  1251. <xsl:variable name="hierarchy_name" select="string($querySubject/*[local-name()='hierarchies']/*[local-name()='hierarchy']/*[local-name()='name'])"/>
  1252. <xsl:variable name="memberUniqueName">
  1253. <xsl:call-template name="substring-findDelimited">
  1254. <xsl:with-param name="strString" select="$level/*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']"/>
  1255. <xsl:with-param name="strLeftDelimiter" select="concat('].[', $querySubject_name, '].[')"/>
  1256. <xsl:with-param name="strRightDelimiter" select="']'"/>
  1257. </xsl:call-template>
  1258. </xsl:variable>
  1259. <xsl:element name="promptInfo">
  1260. <xsl:apply-templates select="*[local-name()='promptInfo']/*" mode="dimQueryItem"/>
  1261. <xsl:if test="$level_name">
  1262. <!-- Create the <expression> to append after the anchor-->
  1263. <xsl:element name="promptFilterItemRef">
  1264. <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $memberUniqueName, ']')"/>
  1265. </xsl:element>
  1266. </xsl:if>
  1267. </xsl:element>
  1268. <xsl:if test="$querySubject/*[local-name() = 'property' and @*[local-name() = 'name' and .='dimensionType']] = 'time'">
  1269. <xsl:element name="sortOnRef">
  1270. <xsl:value-of select="concat('[', $namespace_name, '].[', $dimension_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $memberUniqueName, ']')"/>
  1271. </xsl:element>
  1272. </xsl:if>
  1273. </xsl:element>
  1274. </xsl:template>
  1275. <!-- ============================================================================== -->
  1276. <!-- Step 16: Add missing Level00 information to unit of measure and currency dimensions.
  1277. In Baltic, support was removed for this information. In Bering, support was
  1278. added back in.
  1279. WARNING! The level00 information is generated based on the level01 information
  1280. in the model. If the SAPBW datasource level00 information has been
  1281. customized, it may not correspond to the generated level00 information.
  1282. -->
  1283. <xsl:template name="addLevel00">
  1284. <!-- mode="dimQueryItem" -->
  1285. <xsl:param name="hierarchy_name"/>
  1286. <xsl:param name="basedOnQI"/>
  1287. <xsl:variable name="querySubject" select="ancestor::*[local-name()='querySubject'][1]"/>
  1288. <xsl:variable name="external01" select="./*[local-name()='externalName']"/>
  1289. <xsl:variable name="externalName" select="concat(substring-before(substring-after($external01, '].['), '01]'), '00')"/>
  1290. <xsl:variable name="externalNameRefobj" select="concat(substring-before($external01, '].['), '].[', $externalName, ']')"/>
  1291. <xsl:variable name="namespace_name2" select="string(ancestor::*[local-name()='namespace'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  1292. <xsl:variable name="querySubject_name2" select="string(ancestor::*[local-name()='querySubject'][1]/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  1293. <xsl:element name="{local-name()}">
  1294. <xsl:call-template name="annotate">
  1295. <!--xsl:with-param name="value" select="concat('Created level: ', $hierarchy_name, ' located under namespace: ', $namespace_name2)"/-->
  1296. <xsl:with-param name="value">
  1297. <xsl:call-template name="getLocalizedString">
  1298. <xsl:with-param name="stringID" select="$MODELUPGRADE_CREATED_OBJECT"/>
  1299. <xsl:with-param name="localeVal" select="$defaultLocale"/>
  1300. <xsl:with-param name="string1" select="$OBJECT_TYPE_LEVEL"/>
  1301. <xsl:with-param name="string2" select="$hierarchy_name"/>
  1302. <xsl:with-param name="string3" select="$OBJECT_TYPE_NAMESPACE"/>
  1303. <xsl:with-param name="string4" select="$namespace_name2"/>
  1304. </xsl:call-template>
  1305. </xsl:with-param>
  1306. </xsl:call-template>
  1307. <xsl:call-template name="myCopyAttributes"/>
  1308. <xsl:variable name="levelNames">
  1309. <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
  1310. <xsl:variable name="localItr" select="."/>
  1311. <xsl:element name="name">
  1312. <xsl:attribute name="locale"><xsl:value-of select="$localItr"/></xsl:attribute>
  1313. <xsl:value-of select="concat($querySubject/*[local-name()='name' and @*[local-name()='locale' and . = $localItr]], ' ', xalan:nodeset($AllLevelLocalizedStrings)/*[local-name()=$localItr])"/>
  1314. </xsl:element>
  1315. </xsl:for-each>
  1316. </xsl:variable>
  1317. <xsl:copy-of select="$levelNames"/>
  1318. <xsl:call-template name="localizeElement">
  1319. <xsl:with-param name="elementName" select="'description'"/>
  1320. <xsl:with-param name="defaultValue" select="string($externalName)"/>
  1321. </xsl:call-template>
  1322. <xsl:call-template name="localizeElement">
  1323. <xsl:with-param name="elementName" select="'screenTip'"/>
  1324. <xsl:with-param name="defaultValue" select="string($externalName)"/>
  1325. </xsl:call-template>
  1326. <xsl:copy-of select="./*[local-name() = 'property']"/>
  1327. <xsl:for-each select="*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']">
  1328. <xsl:variable name="namespace_name" select="substring-before(substring-after(., '['), ']')"/>
  1329. <!-- takes between '[' and ']' -->
  1330. <xsl:variable name="querySubject_name" select="substring-before(substring-after(., '].[' ), ']')"/>
  1331. <!-- takes between '].[' and ']' -->
  1332. <xsl:variable name="queryItem_name" select="substring-before(substring-after(., concat('].[', $querySubject_name, '].[') ), ']')"/>
  1333. <!-- takes between '[namespace].[qs].[' and ']' -->
  1334. <xsl:call-template name="addLevel00QueryItem">
  1335. <xsl:with-param name="basedOnQI" select="key('queryItem_using_qsID_qiName', concat(generate-id($querySubject), '||', $queryItem_name))"/>
  1336. <xsl:with-param name="hierarchy_name" select="$hierarchy_name"/>
  1337. <xsl:with-param name="levelNames" select="$levelNames"/>
  1338. <xsl:with-param name="queryItem_name" select="concat($queryItem_name, ' ', $strLevelAll)"/>
  1339. </xsl:call-template>
  1340. </xsl:for-each>
  1341. <xsl:copy-of select="$AllSapAttributes"/>
  1342. <xsl:for-each select="*[local-name()='attributes']/*[local-name()='refobj']">
  1343. <xsl:variable name="namespace_name" select="substring-before(substring-after(., '['), ']')"/>
  1344. <!-- takes between '[' and ']' -->
  1345. <xsl:variable name="querySubject_name" select="substring-before(substring-after(., '].[' ), ']')"/>
  1346. <!-- takes between '].[' and ']' -->
  1347. <xsl:variable name="queryItem_name" select="substring-before(substring-after(., concat('].[', $querySubject_name, '].[') ), ']')"/>
  1348. <!-- takes between '[namespace].[qs].[' and ']' -->
  1349. <xsl:call-template name="addLevel00QueryItem">
  1350. <xsl:with-param name="basedOnQI" select="key('queryItem_using_qsID_qiName', concat(generate-id($querySubject), '||', $queryItem_name))"/>
  1351. <xsl:with-param name="hierarchy_name" select="$hierarchy_name"/>
  1352. <xsl:with-param name="levelNames" select="$levelNames"/>
  1353. <xsl:with-param name="queryItem_name" select="concat($queryItem_name, ' ', $strLevelAll)"/>
  1354. </xsl:call-template>
  1355. </xsl:for-each>
  1356. <xsl:element name="isUnique">true</xsl:element>
  1357. <xsl:element name="externalName"><xsl:value-of select="$externalNameRefobj"/></xsl:element>
  1358. <xsl:element name="externalOrdinal">00</xsl:element>
  1359. </xsl:element>
  1360. </xsl:template>
  1361. <xsl:template name="addLevel00QueryItem">
  1362. <xsl:param name="basedOnQI"/>
  1363. <xsl:param name="hierarchy_name"/>
  1364. <xsl:param name="levelNames"/>
  1365. <xsl:param name="queryItem_name"/>
  1366. <xsl:variable name="level_name" select="xalan:nodeset($levelNames)/*[1]"/>
  1367. <xsl:element name="queryItem">
  1368. <xsl:variable name="bIsMemberUniqueName" select="$basedOnQI/*[local-name()='columnName' and .='[MEMBER_UNIQUE_NAME]']"/>
  1369. <xsl:choose>
  1370. <xsl:when test="$bIsMemberUniqueName">
  1371. <xsl:copy-of select="$levelNames"/>
  1372. </xsl:when>
  1373. <xsl:otherwise>
  1374. <xsl:call-template name="localizeElement">
  1375. <xsl:with-param name="elementName" select="'name'"/>
  1376. <xsl:with-param name="defaultValue" select="$queryItem_name"/>
  1377. </xsl:call-template>
  1378. </xsl:otherwise>
  1379. </xsl:choose>
  1380. <xsl:call-template name="localizeElement">
  1381. <xsl:with-param name="elementName" select="'description'"/>
  1382. <xsl:with-param name="defaultValue" select="$queryItem_name"/>
  1383. </xsl:call-template>
  1384. <xsl:call-template name="localizeElement">
  1385. <xsl:with-param name="elementName" select="'screenTip'"/>
  1386. <xsl:with-param name="defaultValue" select="$queryItem_name"/>
  1387. </xsl:call-template>
  1388. <xsl:copy-of select="$basedOnQI/*[local-name() != 'name' and local-name() != 'description' and local-name() != 'screenTip' and local-name() != 'promptInfo']"/>
  1389. <xsl:element name="promptInfo">
  1390. <xsl:element name="promptType">selectValue</xsl:element>
  1391. <xsl:choose>
  1392. <xsl:when test="$bIsMemberUniqueName">
  1393. <xsl:element name="promptDisplayItemRef">
  1394. <xsl:variable name="promptDisplayItemRef">
  1395. <xsl:apply-templates select="$basedOnQI/*[local-name() = 'promptInfo']/*[local-name() = 'promptDisplayItemRef']/text()"/>
  1396. </xsl:variable>
  1397. <xsl:variable name="namespace_name" select="substring-before(substring-after($promptDisplayItemRef, '['), ']')"/>
  1398. <!-- takes between '[' and ']' -->
  1399. <xsl:variable name="querySubject_name" select="substring-before(substring-after($promptDisplayItemRef, '].[' ), ']')"/>
  1400. <!-- takes between '[namespace].[' and ']' -->
  1401. <xsl:variable name="queryItem01_name" select="substring-before(substring-after($promptDisplayItemRef, concat('].[', $querySubject_name, '].[') ), ']')"/>
  1402. <!-- takes between '[namespace].[querySubject].[' and ']' -->
  1403. <xsl:value-of select="concat('[', $namespace_name, '].[', $dimensionNamePrefix, $querySubject_name, '].[', $hierarchy_name, '].[', $level_name, '].[', concat($queryItem01_name, ' ', $strLevelAll), ']')"/>
  1404. </xsl:element>
  1405. </xsl:when>
  1406. <xsl:otherwise>
  1407. <xsl:element name="promptFilterItemRef">
  1408. <xsl:variable name="querySubject" select="$basedOnQI/ancestor::*[local-name()='querySubject'][1]"/>
  1409. <xsl:variable name="querySubject_name" select="string($querySubject/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  1410. <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]])"/>
  1411. <xsl:variable name="queryItem01_name" select="string($basedOnQI/*[local-name()='name' and @*[local-name()='locale' and translate(., $uppercase, $lowercase) = $defaultLocale]])"/>
  1412. <xsl:variable name="memberUniqueName">
  1413. <xsl:variable name="level01" select="$querySubject/*[local-name()='levels']/*[local-name()='level' and *[local-name()='attributes']/*[local-name()='refobj' and .= $queryItem01_name]]"/>
  1414. <xsl:call-template name="substring-findDelimited">
  1415. <xsl:with-param name="strString" select="$level01/*[local-name()='key']/*[local-name()='queryItems_collection']/*[local-name()='refobj']"/>
  1416. <xsl:with-param name="strLeftDelimiter" select="concat('].[', $querySubject_name, '].[')"/>
  1417. <xsl:with-param name="strRightDelimiter" select="']'"/>
  1418. </xsl:call-template>
  1419. </xsl:variable>
  1420. <xsl:value-of select="concat('[', $namespace_name, '].[', $dimensionNamePrefix, $querySubject_name, '].[', $hierarchy_name, '].[', $level_name, '].[', $level_name, ']')"/>
  1421. </xsl:element>
  1422. </xsl:otherwise>
  1423. </xsl:choose>
  1424. </xsl:element>
  1425. <xsl:if test="$bIsMemberUniqueName">
  1426. <xsl:copy-of select="$AllBusinessKeyRoles"/>
  1427. </xsl:if>
  1428. </xsl:element>
  1429. </xsl:template>
  1430. <!-- ============================================================================== -->
  1431. <!-- Step 17: Baltic SAPBW datasource variables have readonly caption properties.
  1432. In Bering, the property value is no longer readonly.
  1433. -->
  1434. <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']">
  1435. <xsl:element name="{local-name()}">
  1436. <xsl:call-template name="myCopyAttributes"/>
  1437. <xsl:attribute name="type">string</xsl:attribute>
  1438. <xsl:apply-templates select="node()"/>
  1439. </xsl:element>
  1440. </xsl:template>
  1441. <!-- =============================================================================== -->
  1442. <!-- Global variables: -->
  1443. <!-- =============================================================================== -->
  1444. <xsl:variable name="sEmptyNamespace" select="string(document('')/*/namespace::*[name()=''])"/>
  1445. <xsl:variable name="nNewSchema" select="number(substring-before(substring-after($sEmptyNamespace, 'http://www.developer.cognos.com/schemas/bmt/'), '/'))"/>
  1446. <xsl:variable name="nOldSchema" select="32"/>
  1447. <xsl:variable name="dimensionNamePrefix">_</xsl:variable>
  1448. <xsl:variable name="levelNamePrefix">_</xsl:variable>
  1449. <xsl:variable name="strLevelAll">
  1450. <xsl:call-template name="getLocalizedString">
  1451. <xsl:with-param name="stringID" select="$LEVEL_ALL"/>
  1452. <xsl:with-param name="localeVal" select="$defaultLocale"/>
  1453. </xsl:call-template>
  1454. </xsl:variable>
  1455. <xsl:variable name="strWarnDimensionInfo">
  1456. <xsl:call-template name="getLocalizedString">
  1457. <xsl:with-param name="stringID" select="$MODELUPGRADE_WARN_DIMENSION_INFO"/>
  1458. <xsl:with-param name="localeVal" select="$defaultLocale"/>
  1459. </xsl:call-template>
  1460. </xsl:variable>
  1461. <xsl:variable name="strWarnModelPortability">
  1462. <xsl:call-template name="getLocalizedString">
  1463. <xsl:with-param name="stringID" select="$MODELUPGRADE_WARN_MODEL_PORTABILITY"/>
  1464. <xsl:with-param name="localeVal" select="$defaultLocale"/>
  1465. </xsl:call-template>
  1466. </xsl:variable>
  1467. <xsl:key
  1468. name="querySubject_using_ns_qs"
  1469. match="*[local-name()='querySubject']"
  1470. use="concat(
  1471. '[',
  1472. 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')]],
  1473. '].[',
  1474. *[local-name() = 'name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]],
  1475. ']')"/>
  1476. <xsl:key
  1477. name="measureQS_using_ns_qs"
  1478. 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']))]]"
  1479. use="concat(
  1480. '[',
  1481. 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')]],
  1482. '].[',
  1483. *[local-name() = 'name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]],
  1484. ']')"/>
  1485. <xsl:key
  1486. name="defHierQS_using_ns_qs"
  1487. match="*[local-name()='querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]][*[local-name() = 'property' and @*[local-name() = 'name' and .='defaultHierarchy'] and .='true']]"
  1488. use="concat(
  1489. '[',
  1490. 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')]],
  1491. '].[',
  1492. *[local-name() = 'name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]],
  1493. ']')"/>
  1494. <xsl:key
  1495. name="defHierQS_using_ns_dimExternalName"
  1496. match="*[local-name()='querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]][*[local-name() = 'property' and @*[local-name() = 'name' and .='defaultHierarchy'] and .='true']]"
  1497. use="concat(
  1498. '[',
  1499. 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')]],
  1500. ']',
  1501. *[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension'])"/>
  1502. <xsl:key
  1503. name="altHierQS_using_ns_dimExternalName"
  1504. match="*[local-name()='querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]][*[local-name() = 'property' and @*[local-name() = 'name' and .='defaultHierarchy'] and .='false']]"
  1505. use="concat(
  1506. '[',
  1507. 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')]],
  1508. ']',
  1509. *[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension'])"/>
  1510. <xsl:key
  1511. name="altHierQS_using_qsID"
  1512. match="*[local-name()='querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]][*[local-name() = 'property' and @*[local-name() = 'name' and .='defaultHierarchy'] and .='false']]"
  1513. use="generate-id(.)"/>
  1514. <xsl:key
  1515. name="querySubject_using_type"
  1516. match="*[local-name()='querySubject']"
  1517. use="local-name(*[local-name() = 'definition']/*)"/>
  1518. <xsl:key
  1519. name="candidates_using_dimExternalName_dataSourceRef"
  1520. match="*[local-name()='querySubject'][*[local-name() = 'definition' and *[local-name() = 'mdQuery']]]"
  1521. use="concat(
  1522. *[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='dimension'],
  1523. '||',
  1524. *[local-name()='definition']/*[local-name()='mdQuery']/*[local-name()='sources']/*[local-name()='dataSourceRef'])"/>
  1525. <xsl:key
  1526. name="queryItem_using_qsID"
  1527. match="*[local-name()='queryItem' and ancestor::*[local-name() = 'querySubject']]"
  1528. use="generate-id(ancestor::*[local-name()='querySubject'])"/>
  1529. <xsl:key
  1530. name="queryItem_using_qsID_qiName"
  1531. match="*[local-name() = 'queryItem' and ancestor::*[local-name() = 'querySubject']]"
  1532. use="concat(
  1533. generate-id(ancestor::*[local-name()='querySubject']),
  1534. '||',
  1535. *[local-name() = 'name' and @*[local-name()='locale' and translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate(/*[local-name()='project']/*[local-name()='defaultLocale'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]])"/>
  1536. <xsl:variable name="AllQS" select="//*[local-name()='querySubject']"/>
  1537. <xsl:variable name="AllmdQueryQS" select="key('querySubject_using_type','mdQuery')"/>
  1538. <!-- NOTE: There's two types of dimensions in an MDQuery querySubject
  1539. (1) Dimensions with levels and (2) Measure dimensions -->
  1540. <!-- NOTE: AllmdQueryMeasureDimensions...there can be only *one* measure dimension per cube -->
  1541. <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']))]]"/>
  1542. <xsl:variable name="AllmdQueryDimensionAttributes" select="$AllmdQueryQS//*[local-name()='queryItem']"/>
  1543. <!-- NOTE: The following expression uses the Becker Difference: $ns1[count(.|$ns2)!=count($ns2)] -->
  1544. <xsl:variable name="AllmdQueryNonMeasureQS" select="$AllmdQueryQS[count(.|$AllmdQueryMeasureDimensions)!=count($AllmdQueryMeasureDimensions)]"/>
  1545. <xsl:variable name="AllDefaultHierarchyQS" select="$AllmdQueryNonMeasureQS[not(key('altHierQS_using_qsID', generate-id()))]"/>
  1546. <xsl:variable name="UpgradeDatatype">
  1547. <qsType>dbQuery</qsType>
  1548. <qsType>storedProcedure</qsType>
  1549. </xsl:variable>
  1550. <xsl:variable name="AllUpgradeDatatypeQuerySubjects" select="key('querySubject_using_type', xalan:nodeset($UpgradeDatatype)/*)"/>
  1551. <xsl:variable name="AllProjectLocales_makeNodeset">
  1552. <xsl:call-template name="lowercaseValues">
  1553. <xsl:with-param name="nodeset" select="/*[local-name()='project']/*[local-name()='locales']/*[local-name()='locale']"/>
  1554. </xsl:call-template>
  1555. </xsl:variable>
  1556. <xsl:variable name="AllProjectLocales" select="xalan:nodeset($AllProjectLocales_makeNodeset)"/>
  1557. <xsl:variable name="AllBusinessKeyRoles">
  1558. <xsl:element name="roles">
  1559. <xsl:element name="role">
  1560. <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
  1561. <xsl:element name="name">
  1562. <xsl:attribute name="locale"><xsl:value-of select="."/></xsl:attribute>
  1563. <xsl:value-of select=" '_businessKey' "/>
  1564. </xsl:element>
  1565. </xsl:for-each>
  1566. </xsl:element>
  1567. </xsl:element>
  1568. </xsl:variable>
  1569. <xsl:variable name="AllSapAttributes_sortOnRef">
  1570. <xsl:call-template name="AddSapAttribute">
  1571. <xsl:with-param name="attribNameID" select="$CAPTION_dimensionUniqueName"/>
  1572. <xsl:with-param name="attribDescID" select="$DESCRIPTION_dimensionUniqueName"/>
  1573. <xsl:with-param name="attribDataType" select="'character'"/>
  1574. <xsl:with-param name="attribExtName" select="'dimensionUniqueName'"/>
  1575. <xsl:with-param name="attribRole" select="'_dimensionUniqueName'"/>
  1576. <xsl:with-param name="sortOnRef" select="true()"/>
  1577. </xsl:call-template>
  1578. <xsl:call-template name="AddSapAttribute">
  1579. <xsl:with-param name="attribNameID" select="$CAPTION_hierarchyUniqueName"/>
  1580. <xsl:with-param name="attribDescID" select="$DESCRIPTION_hierarchyUniqueName"/>
  1581. <xsl:with-param name="attribDataType" select="'character'"/>
  1582. <xsl:with-param name="attribExtName" select="'hierarchyUniqueName'"/>
  1583. <xsl:with-param name="attribRole" select="'_hierarchyUniqueName'"/>
  1584. <xsl:with-param name="sortOnRef" select="true()"/>
  1585. </xsl:call-template>
  1586. <xsl:call-template name="AddSapAttribute">
  1587. <xsl:with-param name="attribNameID" select="$CAPTION_levelLabel"/>
  1588. <xsl:with-param name="attribDescID" select="$DESCRIPTION_levelLabel"/>
  1589. <xsl:with-param name="attribDataType" select="'character'"/>
  1590. <xsl:with-param name="attribExtName" select="'levelLabel'"/>
  1591. <xsl:with-param name="attribRole" select="'_levelLabel'"/>
  1592. <xsl:with-param name="sortOnRef" select="true()"/>
  1593. </xsl:call-template>
  1594. <xsl:call-template name="AddSapAttribute">
  1595. <xsl:with-param name="attribNameID" select="$CAPTION_levelNumber"/>
  1596. <xsl:with-param name="attribDescID" select="$DESCRIPTION_levelNumber"/>
  1597. <xsl:with-param name="attribDataType" select="'int32'"/>
  1598. <xsl:with-param name="attribExtName" select="'levelNumber'"/>
  1599. <xsl:with-param name="attribRole" select="'_levelNumber'"/>
  1600. <xsl:with-param name="sortOnRef" select="true()"/>
  1601. </xsl:call-template>
  1602. <xsl:call-template name="AddSapAttribute">
  1603. <xsl:with-param name="attribNameID" select="$CAPTION_levelUniqueName"/>
  1604. <xsl:with-param name="attribDescID" select="$DESCRIPTION_levelUniqueName"/>
  1605. <xsl:with-param name="attribDataType" select="'character'"/>
  1606. <xsl:with-param name="attribExtName" select="'levelUniqueName'"/>
  1607. <xsl:with-param name="attribRole" select="'_levelUniqueName'"/>
  1608. <xsl:with-param name="sortOnRef" select="true()"/>
  1609. </xsl:call-template>
  1610. <xsl:call-template name="AddSapAttribute">
  1611. <xsl:with-param name="attribNameID" select="$CAPTION_memberCaption"/>
  1612. <xsl:with-param name="attribDescID" select="$DESCRIPTION_memberCaption"/>
  1613. <xsl:with-param name="attribDataType" select="'character'"/>
  1614. <xsl:with-param name="attribExtName" select="'memberCaption'"/>
  1615. <xsl:with-param name="attribRole" select="'_memberCaption'"/>
  1616. <xsl:with-param name="attribHidden" select="false()"/>
  1617. <xsl:with-param name="sortOnRef" select="true()"/>
  1618. </xsl:call-template>
  1619. <xsl:call-template name="AddSapAttribute">
  1620. <xsl:with-param name="attribNameID" select="$CAPTION_memberDescription"/>
  1621. <xsl:with-param name="attribDescID" select="$DESCRIPTION_memberDescription"/>
  1622. <xsl:with-param name="attribDataType" select="'character'"/>
  1623. <xsl:with-param name="attribExtName" select="'description'"/>
  1624. <xsl:with-param name="attribRole" select="'_memberDescription'"/>
  1625. <xsl:with-param name="sortOnRef" select="true()"/>
  1626. </xsl:call-template>
  1627. <xsl:call-template name="AddSapAttribute">
  1628. <xsl:with-param name="attribNameID" select="$CAPTION_memberUniqueName"/>
  1629. <xsl:with-param name="attribDescID" select="$DESCRIPTION_memberUniqueName"/>
  1630. <xsl:with-param name="attribDataType" select="'character'"/>
  1631. <xsl:with-param name="attribExtName" select="'memberUniqueName'"/>
  1632. <xsl:with-param name="attribRole" select="'_memberUniqueName'"/>
  1633. <xsl:with-param name="sortOnRef" select="true()"/>
  1634. </xsl:call-template>
  1635. <xsl:call-template name="AddSapAttribute">
  1636. <xsl:with-param name="attribNameID" select="$CAPTION_parentUniqueName"/>
  1637. <xsl:with-param name="attribDescID" select="$DESCRIPTION_parentUniqueName"/>
  1638. <xsl:with-param name="attribDataType" select="'character'"/>
  1639. <xsl:with-param name="attribExtName" select="'parentUniqueName'"/>
  1640. <xsl:with-param name="attribRole" select="'_parentUniqueName'"/>
  1641. <xsl:with-param name="sortOnRef" select="true()"/>
  1642. </xsl:call-template>
  1643. <xsl:call-template name="AddSapAttribute">
  1644. <xsl:with-param name="attribNameID" select="'_rollupType'"/>
  1645. <xsl:with-param name="attribDescID" select="'_rollupType'"/>
  1646. <xsl:with-param name="attribDataType" select="'character'"/>
  1647. <xsl:with-param name="attribExtName" select="'_rollupType'"/>
  1648. <xsl:with-param name="attribRole" select="'_rollupType'"/>
  1649. <xsl:with-param name="sortOnRef" select="true()"/>
  1650. <xsl:with-param name="bLocalize" select="false()"/>
  1651. </xsl:call-template>
  1652. </xsl:variable>
  1653. <xsl:variable name="AllSapAttributes">
  1654. <xsl:variable name="nodeset_AllSapAttributes_sortOnRef" select="xalan:nodeset($AllSapAttributes_sortOnRef)"/>
  1655. <xsl:apply-templates select="$nodeset_AllSapAttributes_sortOnRef/node()" mode="sapAttributes"/>
  1656. </xsl:variable>
  1657. <xsl:variable name="AllLevelLocalizedStrings">
  1658. <xsl:for-each select="$AllProjectLocales/*[local-name()='locale']">
  1659. <xsl:element name="{.}">
  1660. <xsl:call-template name="getLocalizedString">
  1661. <xsl:with-param name="stringID" select="$LEVEL_ALL"/>
  1662. <xsl:with-param name="localeVal" select="."/>
  1663. </xsl:call-template>
  1664. </xsl:element>
  1665. </xsl:for-each>
  1666. </xsl:variable>
  1667. </xsl:stylesheet>