xform_9to10.xsl 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 9-->
  10. <!--XSL Transformation from a schema v9 model to a valid BMT schema v10 model-->
  11. <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/10/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 v9 model-->
  16. <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/9')) ">
  17. <xsl:message terminate="yes">The input file for this transformer must be a schema v9 model.</xsl:message>
  18. </xsl:if>
  19. <xsl:apply-templates/>
  20. </xsl:template>
  21. <!--remove obsolete object attributes, type, id-->
  22. <xsl:template match="*">
  23. <xsl:element name="{name(.)}">
  24. <xsl:for-each select="@*">
  25. <xsl:if test="local-name(..) = 'sql' or (name(.) != 'type' and name(.) != 'id') ">
  26. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  27. </xsl:if>
  28. </xsl:for-each>
  29. <xsl:apply-templates/>
  30. </xsl:element>
  31. </xsl:template>
  32. <!--change the schema to v10 version-->
  33. <xsl:template match="*[local-name()='project'] ">
  34. <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/10/0">
  35. <xsl:for-each select="@*">
  36. <xsl:choose>
  37. <!--change schema from v9 to v10-->
  38. <xsl:when test="name(.) = 'xsi:schemaLocation'">
  39. <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/10/0 BMTModelSpecification.xsd'"/></xsl:attribute>
  40. </xsl:when>
  41. <xsl:when test="name(.)='type' or name(.) = 'id' "/>
  42. <xsl:otherwise>
  43. <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
  44. </xsl:otherwise>
  45. </xsl:choose>
  46. </xsl:for-each>
  47. <xsl:apply-templates/>
  48. </xsl:element>
  49. </xsl:template>
  50. <!--remove obsolete prompt properties -->
  51. <xsl:template match="*[local-name() = 'securityObject' ]">
  52. <securityObject type="{@*[local-name() = 'type']}">
  53. <displayPath>
  54. <xsl:variable name="defaultLocale" select="/*[local-name()='project']/*[local-name()='defaultLocale']"/>
  55. <xsl:variable name="dp">
  56. <xsl:for-each select="*[local-name()='displayPath']">
  57. <xsl:if test="@*[local-name()='locale' and translate(., 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')=translate($defaultLocale, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')]">
  58. <xsl:value-of select="."/>
  59. </xsl:if>
  60. </xsl:for-each>
  61. </xsl:variable>
  62. <xsl:variable name="noLocale">
  63. <xsl:for-each select="*[local-name()='displayPath']">
  64. <xsl:if test="not(@*[local-name()='locale'])">
  65. <xsl:value-of select="."/>
  66. </xsl:if>
  67. </xsl:for-each>
  68. </xsl:variable>
  69. <xsl:choose>
  70. <xsl:when test="string($dp)">
  71. <xsl:value-of select="$dp"/>
  72. </xsl:when>
  73. <xsl:when test="string($noLocale)">
  74. <xsl:value-of select="$noLocale"/>
  75. </xsl:when>
  76. <xsl:otherwise><xsl:comment>No displayPath with locale matched to project default locale was found, please correct original model and run upgrade again</xsl:comment></xsl:otherwise>
  77. </xsl:choose>
  78. </displayPath>
  79. <xsl:apply-templates select="*[local-name()='cmSearchPath']"/>
  80. </securityObject>
  81. </xsl:template>
  82. <!--remove obsolete prompt properties-->
  83. <xsl:template match="*[local-name() = 'isFew' or local-name()='isPromptLabel' ]"/>
  84. </xsl:stylesheet>