xform_8to9.xsl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. <!--XSLT version 8-->
  10. <!--XSL Transformation from a schema v8 model to a valid BMT schema v9 model-->
  11. <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/9/0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  12. <xsl:output encoding="utf-8" method="xml" indent="yes"/>
  13. <!--root match-->
  14. <xsl:template match="/">
  15. <!--make sure that this transformation is performed on a schema v8 model-->
  16. <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/8')) ">
  17. <xsl:message terminate="yes">The input file for this transformer must be a schema v8 model.</xsl:message>
  18. </xsl:if>
  19. <xsl:apply-templates/>
  20. </xsl:template>
  21. <!--generic match, copies over the element unless it is redefined later in the file-->
  22. <xsl:template match="*">
  23. <xsl:element name="{name(.)}">
  24. <xsl:for-each select="@*">
  25. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  26. </xsl:for-each>
  27. <xsl:apply-templates/>
  28. </xsl:element>
  29. </xsl:template>
  30. <!--change the schema to v9 version-->
  31. <xsl:template match="*[local-name()='project'] ">
  32. <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/9/0">
  33. <xsl:for-each select="@*">
  34. <xsl:choose>
  35. <!--change schema from v8 to v9-->
  36. <xsl:when test="name(.) = 'xsi:schemaLocation'">
  37. <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/9/4 BMTModelSpecification.xsd'"/></xsl:attribute>
  38. </xsl:when>
  39. <xsl:otherwise>
  40. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  41. </xsl:otherwise>
  42. </xsl:choose>
  43. </xsl:for-each>
  44. <xsl:apply-templates select="*[local-name()='name' or local-name()='lastChanged' or local-name()='description' or local-name()='screenTip']"/>
  45. <xsl:apply-templates select="*[local-name()='locales' or local-name()='defaultLocale' or local-name()='templates']"/>
  46. <xsl:apply-templates select="*[local-name()='logicalModel'] "/>
  47. <xsl:if test="not(*[ local-name()='logicalModel' ])">
  48. <logicalModel>
  49. <name locale="{*[local-name()='defaultLocale']}">Model</name>
  50. </logicalModel>
  51. </xsl:if>
  52. <xsl:apply-templates select="*[local-name()='parameterMaps'] "/>
  53. <xsl:if test="not(*[ local-name()='parameterMaps' ])">
  54. <parameterMaps/>
  55. </xsl:if>
  56. <xsl:apply-templates select="*[local-name()='securityViews'] "/>
  57. <xsl:if test="not(*[ local-name()='securityViews' ])">
  58. <securityViews/>
  59. </xsl:if>
  60. <xsl:apply-templates select="*[local-name()='packages'] "/>
  61. <xsl:if test="not(*[ local-name()='packages' ])">
  62. <packages/>
  63. </xsl:if>
  64. <xsl:apply-templates select="*[local-name()='functions'] "/>
  65. <xsl:if test="not(*[ local-name()='functions' ])">
  66. <functions/>
  67. </xsl:if>
  68. </xsl:element>
  69. </xsl:template>
  70. <!--convert securityView to new schema-->
  71. <xsl:template match="*[local-name() = 'parameterMap']">
  72. <parameterMap>
  73. <name>
  74. <xsl:value-of select="*[local-name()='name' ]"/>
  75. </name>
  76. <xsl:apply-templates select="*[local-name() !='name' and local-name() !='lastChanged' and local-name() !='description' and local-name() !='screenTip']"/>
  77. </parameterMap>
  78. </xsl:template>
  79. <xsl:template match="*[local-name() = 'package']">
  80. <package>
  81. <xsl:apply-templates/>
  82. <xsl:if test="not(*[ local-name()='functions' ])">
  83. <functions/>
  84. </xsl:if>
  85. </package>
  86. </xsl:template>
  87. <!--remove package (but not packages container) completely-->
  88. <xsl:template match="*[local-name() = 'securityFilterDefinition' or local-name()='decisionRole' ]"/>
  89. <!-- revert a typo in 4to5 -->
  90. <xsl:template match="*[local-name() = 'collectionsSequenceName' ]">
  91. <collationSequenceName>
  92. <xsl:value-of select="."/>
  93. </collationSequenceName>
  94. </xsl:template>
  95. <xsl:template match="*[local-name() = 'collectionsSequenceLevel' ]">
  96. <collationSequenceLevel>
  97. <xsl:value-of select="."/>
  98. </collationSequenceLevel>
  99. </xsl:template>
  100. <xsl:template match="*[local-name() = 'originalCollectionsSequenceName' ]">
  101. <originalCollationSequenceName>
  102. <xsl:value-of select="."/>
  103. </originalCollationSequenceName>
  104. </xsl:template>
  105. </xsl:stylesheet>