xform_55to56.xsl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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 55 to 56 Notes:
  12. This is an XSLT transformation from a Bering schema version 55 model to a Bering
  13. schema version 56 model.
  14. This Upgrade is required to accomodate the following Model Schema changes.
  15. * type of scopeRelationship/scope/measureScope/excluded from xs:string to xs:boolean.. default value is 'false'
  16. * measure/dbAggregationRule has been moved to measure/aggregationRule
  17. In addition to the schema changes, some queryItem formatting changes were made in
  18. Bering that need to be addressed.
  19. * percentage scale's representation has changed to a negative value.
  20. * the following strings have changed
  21. Baltic Bering
  22. ====== ======
  23. "hide century" ==> "hideCentury"
  24. "show century" ==> "showCentury"
  25. "1 digit" ==> "1-digit"
  26. "2 digits" ==> "2-digits"
  27. "3 digits" ==> "3-digits"
  28. "short name" ==> "shortName"
  29. "full name" ==> "fullName"
  30. ===============================================================================
  31. -->
  32. <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/56/0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  33. <xsl:include href="fmmd_generalTemplates.xsl"/>
  34. <xsl:strip-space elements="*"/>
  35. <xsl:output encoding="utf-8" method="xml" indent="no"/>
  36. <!-- Template: change the type of scopeRelationship/scope/measureScope/excluded from xs:string to xs:boolean.. default value is 'false' -->
  37. <xsl:template match="*[local-name()='scopeRelationship']/*[local-name()='scope']/*[local-name()='measureScope' and @*[local-name()='excluded']]">
  38. <xsl:element name="{local-name(.)}">
  39. <xsl:choose>
  40. <xsl:when test="@*[local-name()='excluded'] = 'excluded'">
  41. <xsl:attribute name="excluded">true</xsl:attribute>
  42. </xsl:when>
  43. <xsl:otherwise>
  44. <!-- NOTE: default is false -->
  45. <!--
  46. <xsl:attribute name="excluded">false</xsl:attribute>
  47. -->
  48. </xsl:otherwise>
  49. </xsl:choose>
  50. <!-- copy the children nodes -->
  51. <xsl:apply-templates select="./*"/>
  52. </xsl:element>
  53. </xsl:template>
  54. <!-- Template: measure/dbAggregationRule has been deleted in it's current location -->
  55. <xsl:template match="*[local-name()='dimension']//*[local-name()='measure']/*[local-name()='dbAggregationRule']"/>
  56. <!-- Template: measure/aggregationRule has been deleted in it's current location if the measure also had a dbAggregationRule -->
  57. <xsl:template match="*[local-name()='dimension']//*[local-name()='measure' and ./*[local-name()='dbAggregationRule']]/*[local-name()='aggregationRule']"/>
  58. <!-- Template: old measure/dbAggregationRule is now measure/aggregationRule-->
  59. <xsl:template match="*[local-name()='dimension']//*[local-name()='measure' and ./*[local-name()='dbAggregationRule']]/*[local-name()='externalName' or local-name()='hidden' or local-name()='usage' or local-name()='format' or local-name()='currency' or local-name()='bmtcr1:datatype' or local-name()='precision' or local-name()='scale' or local-name()='size' or local-name()='nullable'][last()]">
  60. <!-- Copy the anchor element over -->
  61. <xsl:call-template name="myCopy"/>
  62. <!-- Insert the new aggregationRule -->
  63. <xsl:element name="aggregationRule">
  64. <xsl:value-of select="../*[local-name()='dbAggregationRule']"/>
  65. </xsl:element>
  66. </xsl:template>
  67. <!-- Template: Convert queryItem formats -->
  68. <xsl:template match="*[local-name()='queryItem' or local-name()='measure' or local-name()='calculation']/*[local-name()='format']/text()">
  69. <!-- Convert PercentScale value to a negative value -->
  70. <xsl:variable name="strLeftDelimiter" select="'percentScale=&amp;quot;'"/>
  71. <xsl:variable name="strRightDelimiter" select="'&amp;quot;'"/>
  72. <xsl:variable name="strPercentScale">
  73. <xsl:call-template name="substring-findDelimited">
  74. <xsl:with-param name="strString" select="."/>
  75. <xsl:with-param name="strLeftDelimiter" select="$strLeftDelimiter"/>
  76. <xsl:with-param name="strRightDelimiter" select="$strRightDelimiter"/>
  77. </xsl:call-template>
  78. </xsl:variable>
  79. <xsl:variable name="nPercentScale" select="number($strPercentScale)"/>
  80. <xsl:variable name="PercentScale">
  81. <xsl:choose>
  82. <xsl:when test="$nPercentScale > 0">
  83. <xsl:call-template name="substring-replace">
  84. <xsl:with-param name="strString" select="."/>
  85. <xsl:with-param name="strFind" select="concat($strLeftDelimiter, $nPercentScale, $strRightDelimiter)"/>
  86. <xsl:with-param name="strReplace" select="concat($strLeftDelimiter, '-', $nPercentScale, $strRightDelimiter)"/>
  87. </xsl:call-template>
  88. </xsl:when>
  89. <xsl:otherwise>
  90. <xsl:value-of select="."/>
  91. </xsl:otherwise>
  92. </xsl:choose>
  93. </xsl:variable>
  94. <!-- showYears -->
  95. <!-- Convert showYears="show Century" ==> showYears="showCentury" -->
  96. <xsl:variable name="showCentury">
  97. <xsl:call-template name="substring-replace">
  98. <xsl:with-param name="strString" select="$PercentScale"/>
  99. <xsl:with-param name="strFind" select="'showYears=&amp;quot;show century&amp;quot;'"/>
  100. <xsl:with-param name="strReplace" select="'showYears=&amp;quot;showCentury&amp;quot;'"/>
  101. </xsl:call-template>
  102. </xsl:variable>
  103. <!-- Convert showYears="hide Century" ==> showYears="hideCentury" -->
  104. <xsl:variable name="hideCentury">
  105. <xsl:call-template name="substring-replace">
  106. <xsl:with-param name="strString" select="$showCentury"/>
  107. <xsl:with-param name="strFind" select="'showYears=&amp;quot;hide century&amp;quot;'"/>
  108. <xsl:with-param name="strReplace" select="'showYears=&amp;quot;hideCentury&amp;quot;'"/>
  109. </xsl:call-template>
  110. </xsl:variable>
  111. <!-- showMonths -->
  112. <!-- Convert showMonths="1 digit" ==> showMonths="1-digit" -->
  113. <xsl:variable name="showMonths_1digit">
  114. <xsl:call-template name="substring-replace">
  115. <xsl:with-param name="strString" select="$hideCentury"/>
  116. <xsl:with-param name="strFind" select="'showMonths=&amp;quot;1 digit&amp;quot;'"/>
  117. <xsl:with-param name="strReplace" select="'showMonths=&amp;quot;1-digit&amp;quot;'"/>
  118. </xsl:call-template>
  119. </xsl:variable>
  120. <!-- Convert showMonths="2 digits" ==> showMonths="2-digits" -->
  121. <xsl:variable name="showMonths_2digits">
  122. <xsl:call-template name="substring-replace">
  123. <xsl:with-param name="strString" select="$showMonths_1digit"/>
  124. <xsl:with-param name="strFind" select="'showMonths=&amp;quot;2 digits&amp;quot;'"/>
  125. <xsl:with-param name="strReplace" select="'showMonths=&amp;quot;2-digits&amp;quot;'"/>
  126. </xsl:call-template>
  127. </xsl:variable>
  128. <!-- Convert showMonths="short name" ==> showMonths="shortName" -->
  129. <xsl:variable name="showMonths_shortName">
  130. <xsl:call-template name="substring-replace">
  131. <xsl:with-param name="strString" select="$showMonths_2digits"/>
  132. <xsl:with-param name="strFind" select="'showMonths=&amp;quot;short name&amp;quot;'"/>
  133. <xsl:with-param name="strReplace" select="'showMonths=&amp;quot;shortName&amp;quot;'"/>
  134. </xsl:call-template>
  135. </xsl:variable>
  136. <!-- Convert showMonths="full name" ==> showMonths="fullName" -->
  137. <xsl:variable name="showMonths_fullName">
  138. <xsl:call-template name="substring-replace">
  139. <xsl:with-param name="strString" select="$showMonths_shortName"/>
  140. <xsl:with-param name="strFind" select="'showMonths=&amp;quot;full name&amp;quot;'"/>
  141. <xsl:with-param name="strReplace" select="'showMonths=&amp;quot;fullName&amp;quot;'"/>
  142. </xsl:call-template>
  143. </xsl:variable>
  144. <!-- showWeekdays -->
  145. <!-- Convert showWeekdays="short name" ==> showWeekdays="shortName" -->
  146. <xsl:variable name="showWeekdays_shortName">
  147. <xsl:call-template name="substring-replace">
  148. <xsl:with-param name="strString" select="$showMonths_fullName"/>
  149. <xsl:with-param name="strFind" select="'showWeekdays=&amp;quot;short name&amp;quot;'"/>
  150. <xsl:with-param name="strReplace" select="'showWeekdays=&amp;quot;shortName&amp;quot;'"/>
  151. </xsl:call-template>
  152. </xsl:variable>
  153. <!-- Convert showWeekdays="full name" ==> showWeekdays="fullName" -->
  154. <xsl:variable name="showWeekdays_fullName">
  155. <xsl:call-template name="substring-replace">
  156. <xsl:with-param name="strString" select="$showWeekdays_shortName"/>
  157. <xsl:with-param name="strFind" select="'showWeekdays=&amp;quot;full name&amp;quot;'"/>
  158. <xsl:with-param name="strReplace" select="'showWeekdays=&amp;quot;fullName&amp;quot;'"/>
  159. </xsl:call-template>
  160. </xsl:variable>
  161. <!-- showDays -->
  162. <!-- Convert showDays="1 digit" ==> showDays="1-digit" -->
  163. <xsl:variable name="showWeekdays_1digit">
  164. <xsl:call-template name="substring-replace">
  165. <xsl:with-param name="strString" select="$showWeekdays_fullName"/>
  166. <xsl:with-param name="strFind" select="'showDays=&amp;quot;1 digit&amp;quot;'"/>
  167. <xsl:with-param name="strReplace" select="'showDays=&amp;quot;1-digit&amp;quot;'"/>
  168. </xsl:call-template>
  169. </xsl:variable>
  170. <!-- Convert showDays="2 digits" ==> showDays="2-digits" -->
  171. <xsl:variable name="showWeekdays_2digits">
  172. <xsl:call-template name="substring-replace">
  173. <xsl:with-param name="strString" select="$showWeekdays_1digit"/>
  174. <xsl:with-param name="strFind" select="'showDays=&amp;quot;2 digits&amp;quot;'"/>
  175. <xsl:with-param name="strReplace" select="'showDays=&amp;quot;2-digits&amp;quot;'"/>
  176. </xsl:call-template>
  177. </xsl:variable>
  178. <!-- showHours -->
  179. <!-- Convert showHours="1 digit" ==> showHours="1-digit" -->
  180. <xsl:variable name="showHours_1digit">
  181. <xsl:call-template name="substring-replace">
  182. <xsl:with-param name="strString" select="$showWeekdays_2digits"/>
  183. <xsl:with-param name="strFind" select="'showHours=&amp;quot;1 digit&amp;quot;'"/>
  184. <xsl:with-param name="strReplace" select="'showHours=&amp;quot;1-digit&amp;quot;'"/>
  185. </xsl:call-template>
  186. </xsl:variable>
  187. <!-- Convert showHours="2 digits" ==> showHours="2-digits" -->
  188. <xsl:variable name="showHours_2digits">
  189. <xsl:call-template name="substring-replace">
  190. <xsl:with-param name="strString" select="$showHours_1digit"/>
  191. <xsl:with-param name="strFind" select="'showHours=&amp;quot;2 digits&amp;quot;'"/>
  192. <xsl:with-param name="strReplace" select="'showHours=&amp;quot;2-digits&amp;quot;'"/>
  193. </xsl:call-template>
  194. </xsl:variable>
  195. <!-- showMinutes -->
  196. <!-- Convert showMinutes="1 digit" ==> showMinutes="1-digit" -->
  197. <xsl:variable name="showMinutes_1digit">
  198. <xsl:call-template name="substring-replace">
  199. <xsl:with-param name="strString" select="$showHours_2digits"/>
  200. <xsl:with-param name="strFind" select="'showMinutes=&amp;quot;1 digit&amp;quot;'"/>
  201. <xsl:with-param name="strReplace" select="'showMinutes=&amp;quot;1-digit&amp;quot;'"/>
  202. </xsl:call-template>
  203. </xsl:variable>
  204. <!-- Convert showMinutes="2 digits" ==> showMinutes="2-digits" -->
  205. <xsl:variable name="showMinutes_2digits">
  206. <xsl:call-template name="substring-replace">
  207. <xsl:with-param name="strString" select="$showMinutes_1digit"/>
  208. <xsl:with-param name="strFind" select="'showMinutes=&amp;quot;2 digits&amp;quot;'"/>
  209. <xsl:with-param name="strReplace" select="'showMinutes=&amp;quot;2-digits&amp;quot;'"/>
  210. </xsl:call-template>
  211. </xsl:variable>
  212. <!-- showSeconds -->
  213. <!-- Convert showSeconds="1 digit" ==> showSeconds="1-digit" -->
  214. <xsl:variable name="showSeconds_1digit">
  215. <xsl:call-template name="substring-replace">
  216. <xsl:with-param name="strString" select="$showMinutes_2digits"/>
  217. <xsl:with-param name="strFind" select="'showSeconds=&amp;quot;1 digit&amp;quot;'"/>
  218. <xsl:with-param name="strReplace" select="'showSeconds=&amp;quot;1-digit&amp;quot;'"/>
  219. </xsl:call-template>
  220. </xsl:variable>
  221. <!-- Convert showSeconds="2 digits" ==> showSeconds="2-digits" -->
  222. <xsl:variable name="showSeconds_2digits">
  223. <xsl:call-template name="substring-replace">
  224. <xsl:with-param name="strString" select="$showSeconds_1digit"/>
  225. <xsl:with-param name="strFind" select="'showSeconds=&amp;quot;2 digits&amp;quot;'"/>
  226. <xsl:with-param name="strReplace" select="'showSeconds=&amp;quot;2-digits&amp;quot;'"/>
  227. </xsl:call-template>
  228. </xsl:variable>
  229. <!-- showMilliSeconds -->
  230. <!-- Convert showMilliSeconds="1 digit" ==> showMilliSeconds="1-digit" -->
  231. <xsl:variable name="showMilliSeconds_1digit">
  232. <xsl:call-template name="substring-replace">
  233. <xsl:with-param name="strString" select="$showSeconds_2digits"/>
  234. <xsl:with-param name="strFind" select="'showMilliSeconds=&amp;quot;1 digit&amp;quot;'"/>
  235. <xsl:with-param name="strReplace" select="'showMilliSeconds=&amp;quot;1-digit&amp;quot;'"/>
  236. </xsl:call-template>
  237. </xsl:variable>
  238. <!-- Convert showMilliSeconds="2 digits" ==> showMilliSeconds="2-digits" -->
  239. <xsl:variable name="showMilliSeconds_2digits">
  240. <xsl:call-template name="substring-replace">
  241. <xsl:with-param name="strString" select="$showMilliSeconds_1digit"/>
  242. <xsl:with-param name="strFind" select="'showMilliSeconds=&amp;quot;2 digits&amp;quot;'"/>
  243. <xsl:with-param name="strReplace" select="'showMilliSeconds=&amp;quot;2-digits&amp;quot;'"/>
  244. </xsl:call-template>
  245. </xsl:variable>
  246. <!-- Convert showMilliSeconds="3 digits" ==> showMilliSeconds="3-digits" -->
  247. <xsl:variable name="showMilliSeconds_3digits">
  248. <xsl:call-template name="substring-replace">
  249. <xsl:with-param name="strString" select="$showMilliSeconds_2digits"/>
  250. <xsl:with-param name="strFind" select="'showMilliSeconds=&amp;quot;3 digits&amp;quot;'"/>
  251. <xsl:with-param name="strReplace" select="'showMilliSeconds=&amp;quot;3-digits&amp;quot;'"/>
  252. </xsl:call-template>
  253. </xsl:variable>
  254. <xsl:value-of select="$showMilliSeconds_3digits"/>
  255. </xsl:template>
  256. <!-- Globlal variables-->
  257. <xsl:variable name="sEmptyNamespace" select="string(document('')/*/namespace::*[name()=''])"/>
  258. <xsl:variable name="nNewSchema" select="number(substring-before(substring-after($sEmptyNamespace, 'http://www.developer.cognos.com/schemas/bmt/'), '/'))"/>
  259. <xsl:variable name="nOldSchema" select="$nNewSchema - 1"/>
  260. </xsl:stylesheet>