xform_7to8.xsl 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 7-->
  10. <!--XSL Transformation from a schema v7 model to a valid BMT schema v8 model-->
  11. <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/8/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 v7 model-->
  16. <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/7')) ">
  17. <xsl:message terminate="yes">The input file for this transformer must be a schema v7 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 v8 version-->
  31. <xsl:template match="*[local-name()='project'] ">
  32. <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/8/0">
  33. <xsl:for-each select="@*">
  34. <xsl:choose>
  35. <!--change schema from v7 to v8-->
  36. <xsl:when test="name(.) = 'xsi:schemaLocation'">
  37. <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/8/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. <packages>
  46. <xsl:apply-templates select="*[local-name()='securityViews']/*[local-name()='securityView']" mode="asPackage"/>
  47. </packages>
  48. </xsl:element>
  49. </xsl:template>
  50. <xsl:template match="*[local-name() = 'securityView']" mode="asPackage">
  51. <package>
  52. <xsl:apply-templates select="*[local-name()='name' or local-name()='lastChanged' or local-name()='description' or local-name()='screenTip']"/>
  53. <xsl:apply-templates select="/*[local-name()='project']/*[local-name()='locales']"/>
  54. <definition>
  55. <viewref>
  56. <xsl:text>[securityViews].[</xsl:text>
  57. <xsl:value-of select="*[local-name()='name']"/>
  58. <xsl:text>]</xsl:text>
  59. </viewref>
  60. </definition>
  61. </package>
  62. </xsl:template>
  63. <!--convert securityView to new schema-->
  64. <xsl:template match="*[local-name() = 'securityView']">
  65. <securityView>
  66. <xsl:apply-templates select="*[local-name()='name' or local-name()='lastChanged' or local-name()='description' or local-name()='screenTip']"/>
  67. <definition>
  68. <xsl:for-each select="*[local-name()='apex']">
  69. <xsl:if test="string(.)">
  70. <set includeRule="include">
  71. <refobj><xsl:value-of select="."/></refobj>
  72. </set>
  73. </xsl:if>
  74. </xsl:for-each>
  75. <xsl:for-each select="*[local-name()='exclude' or local-name()='hide']">
  76. <xsl:for-each select="*[local-name()='refobj'] ">
  77. <set includeRule="{local-name(..)}">
  78. <refobj><xsl:value-of select="."/></refobj>
  79. </set>
  80. </xsl:for-each>
  81. </xsl:for-each>
  82. </definition>
  83. <access/>
  84. </securityView>
  85. </xsl:template>
  86. <!--remove package (but not packages container) completely-->
  87. <xsl:template match="*[local-name() = 'packages']"/>
  88. </xsl:stylesheet>