xform_14to15.xsl 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 14-->
  10. <!--XSL Transformation from a schema v14 model to a valid BMT schema v15 model-->
  11. <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/15/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 v14 model-->
  16. <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/14')) ">
  17. <xsl:message terminate="yes">The input file for this transformer must be a schema v14 model.</xsl:message>
  18. </xsl:if>
  19. <xsl:apply-templates/>
  20. </xsl:template>
  21. <!-- general copy -->
  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 project attribute to v15 version-->
  31. <xsl:template match="*[local-name()='project'] ">
  32. <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/15/0">
  33. <xsl:for-each select="@*">
  34. <xsl:choose>
  35. <!--change schema from v14 to v15-->
  36. <xsl:when test="name(.) = 'xsi:schemaLocation'">
  37. <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/15/0 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/>
  45. </xsl:element>
  46. </xsl:template>
  47. <!-- property position are changed globally -->
  48. <xsl:template match="*[local-name() = 'querySubject' or local-name()='relationship' or local-name()='level' or local-name()='hierarchy'] ">
  49. <xsl:element name="{ local-name() }">
  50. <xsl:for-each select="@*">
  51. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  52. </xsl:for-each>
  53. <xsl:apply-templates select="*[local-name() = 'name' or local-name()='description' or local-name()='lastChanged' or local-name()='screenTip' or local-name()='property']"/>
  54. <xsl:apply-templates select="*[not(local-name() = 'name' or local-name()='description' or local-name()='lastChanged' or local-name()='screenTip' or local-name()='property')]"/>
  55. </xsl:element>
  56. </xsl:template>
  57. <!-- change position for MIMEType, precision, property, displayType and promptInfo-->
  58. <xsl:template match="* [ local-name() = 'queryItem' ]">
  59. <queryItem>
  60. <xsl:apply-templates select="*[ local-name() = 'name' ]"/>
  61. <xsl:apply-templates select="*[ local-name() = 'description' ]"/>
  62. <xsl:apply-templates select="*[ local-name() = 'lastChanged' ]"/>
  63. <xsl:apply-templates select="*[ local-name() = 'screenTip' ]"/>
  64. <xsl:apply-templates select="*[ local-name() = 'property' ]"/>
  65. <xsl:apply-templates select="*[ local-name() = 'columnName' ]"/>
  66. <xsl:apply-templates select="*[ local-name() = 'hidden' ]"/>
  67. <xsl:apply-templates select="*[ local-name() = 'usage' ]"/>
  68. <xsl:apply-templates select="*[ local-name() = 'format' ]"/>
  69. <xsl:apply-templates select="*[ local-name() = 'currency' ]"/>
  70. <xsl:apply-templates select="*[ local-name() = 'datatype' ]"/>
  71. <xsl:apply-templates select="*[ local-name() = 'precision' ]"/>
  72. <xsl:apply-templates select="*[ local-name() = 'scale' ]"/>
  73. <xsl:apply-templates select="*[ local-name() = 'size' ]"/>
  74. <xsl:apply-templates select="*[ local-name() = 'nullable' ]"/>
  75. <xsl:apply-templates select="*[ local-name() = 'displayType' ]"/>
  76. <xsl:apply-templates select="*[ local-name() = 'MIMEType' ]"/>
  77. <xsl:apply-templates select="*[ local-name() = 'promptInfo' ]"/>
  78. <xsl:apply-templates select="*[ local-name() = 'regularAggregate' ]"/>
  79. <xsl:apply-templates select="*[ local-name() = 'semiAggregate' ]"/>
  80. <xsl:apply-templates select="*[ local-name() = 'unSortable' ]"/>
  81. <xsl:apply-templates select="*[ local-name() = 'collationSequenceName' ]"/>
  82. <xsl:apply-templates select="*[ local-name() = 'collationSequenceLevel' ]"/>
  83. <xsl:apply-templates select="*[ local-name() = 'originalCollationSequenceName' ]"/>
  84. <xsl:apply-templates select="*[ local-name() = 'originalEncodingName' ] "/>
  85. </queryItem>
  86. </xsl:template>
  87. </xsl:stylesheet>