xform_16to17.xsl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 16-->
  10. <!--XSL Transformation from a schema v16 model to a valid BMT schema v17 model-->
  11. <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/17/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 v16 model-->
  16. <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/16')) ">
  17. <xsl:message terminate="yes">The input file for this transformer must be a schema v16 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 schema to v17 version-->
  31. <xsl:template match="*[local-name()='project'] ">
  32. <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/17/0">
  33. <xsl:for-each select="@*">
  34. <xsl:choose>
  35. <!--change schema from v16 to v17-->
  36. <xsl:when test="name(.) = 'xsi:schemaLocation'">
  37. <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/17/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. <!--remove any existing functions -->
  48. <xsl:template match="* [ local-name() = 'function' ]"/>
  49. <!-- drop the whole querySubject if it is a function type procedure -->
  50. <xsl:template match="* [ local-name() = 'querySubject' ] ">
  51. <xsl:if test="not(*[local-name() = 'definition' ]/*[local-name() = 'storedProcedure']/*[local-name()='type' and . = 'function' ])">
  52. <xsl:element name="{ local-name() }">
  53. <xsl:for-each select="@*">
  54. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  55. </xsl:for-each>
  56. <xsl:apply-templates/>
  57. </xsl:element>
  58. </xsl:if>
  59. </xsl:template>
  60. <!-- fix stored procedure -->
  61. <xsl:template match="* [ local-name() = 'storedProcedure' ]">
  62. <xsl:if test="*[local-name()='type' and . != 'function' ]">
  63. <storedProcedure>
  64. <xsl:apply-templates select="*[local-name() = 'source' or local-name() = 'type' ]"/>
  65. <procParameters>
  66. <xsl:for-each select="*[local-name() = 'procParameter'] ">
  67. <procParameter>
  68. <xsl:apply-templates select="*[local-name() = 'parameterName' or local-name() = 'mode' or local-name() = 'datatype' or local-name() = 'precision']"/>
  69. <xsl:apply-templates select="*[local-name() = 'scale' ]"/>
  70. <xsl:apply-templates select="*[ local-name() = 'size' or local-name() = 'nullable' ]"/>
  71. <xsl:apply-templates select="*[local-name() = 'value' ]"/>
  72. </procParameter>
  73. </xsl:for-each>
  74. </procParameters>
  75. </storedProcedure>
  76. </xsl:if>
  77. </xsl:template>
  78. </xsl:stylesheet>