xform_31to32.xsl 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 31-->
  10. <!--XSL Transformation from a schema v31 model to a valid BMT schema v32 model-->
  11. <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/32/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 v31 model-->
  16. <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/31')) ">
  17. <xsl:message terminate="yes">The input file for this transformer must be a schema v31 model.</xsl:message>
  18. </xsl:if>
  19. <xsl:apply-templates select="node()"/>
  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 select="node()"/>
  28. </xsl:element>
  29. </xsl:template>
  30. <!--change the schema to v32 version-->
  31. <xsl:template match="*[local-name()='project'] ">
  32. <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/32/0">
  33. <xsl:for-each select="@*">
  34. <xsl:choose>
  35. <!--change schema from v31 to v32-->
  36. <xsl:when test="name(.) = 'xsi:schemaLocation'">
  37. <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/32/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 select="node()"/>
  45. </xsl:element>
  46. </xsl:template>
  47. <!-- if object-based security is specified in the model, then we need to ensure that a role-based package for the "Everyone" role exists. If not, then create it.-->
  48. <xsl:template match="*[local-name() = 'securityViews' ] ">
  49. <securityViews>
  50. <xsl:apply-templates/>
  51. <xsl:if test="*[local-name() = 'securityView' and @isRoleBased = 'true']">
  52. <xsl:if test="not(*[local-name() = 'securityView' and @isRoleBased = 'true']/*[local-name()='name' and . = '_Everyone [Directory &gt; Cognos]' ])">
  53. <securityView isRoleBased="true">
  54. <name>_Everyone [Directory &gt; Cognos]</name>
  55. <definition>
  56. <xsl:if test="/*[local-name()='project']/*[local-name() = 'namespace' and not(*[local-name()='secured'])]">
  57. <set includeRule="include">
  58. <refobj>
  59. <xsl:value-of select="concat('[',/*[local-name()='project']/*[local-name() = 'namespace']/*[local-name() = 'name'], ']')"/>
  60. </refobj>
  61. </set>
  62. </xsl:if>
  63. </definition>
  64. <access>
  65. <decisionRole>
  66. <securityObject type="group">
  67. <displayPath>Everyone [Directory &gt; Cognos]</displayPath>
  68. <cmSearchPath>CAMID("::Everyone")</cmSearchPath>
  69. </securityObject>
  70. </decisionRole>
  71. </access>
  72. </securityView>
  73. </xsl:if>
  74. </xsl:if>
  75. </securityViews>
  76. </xsl:template>
  77. <!-- if object-based security is specified in the model, then we need to ensure that a role-based package for the "Everyone" role exists. If not, then create it.-->
  78. <xsl:template match="*[local-name() = 'packages' ] ">
  79. <packages>
  80. <xsl:apply-templates/>
  81. <xsl:if test="*[local-name() = 'package' and @isRoleBased = 'true' ] and not(*[local-name() = 'package' and @isRoleBased = 'true' ]/*[local-name() = 'name' and . ='_Everyone [Directory &gt; Cognos]' ] )">
  82. <package isRoleBased="true">
  83. <name locale="{/*[local-name() = 'project']/*[local-name() = 'defaultLocale']}">_Everyone [Directory &gt; Cognos]</name>
  84. <xsl:apply-templates select="/*[local-name() = 'project']/*[local-name() = 'locales']"/>
  85. <definition>
  86. <viewref>[].[securityViews].[_Everyone [Directory &gt; Cognos]]]</viewref>
  87. </definition>
  88. <adminAccess/>
  89. </package>
  90. </xsl:if>
  91. </packages>
  92. </xsl:template>
  93. <!-- check if the root namespace object is secured ... if not, then add a reference to it in the package's "include" list -->
  94. <!-- Remove all "hide" sets from role-based packages -->
  95. <xsl:template match="*[local-name() = 'securityView' and @isRoleBased = 'true' ]/*[local-name() = 'definition'] ">
  96. <xsl:element name="{name(.)}">
  97. <xsl:choose>
  98. <xsl:when test=" ( ../*[local-name()='name' and . = '_Everyone [Directory &gt; Cognos]'] )">
  99. <xsl:if test="*[local-name() = 'set' and @includeRule = 'include'] or not(/*[local-name()='project']/*[local-name() = 'namespace']/*[local-name()='secured']) ">
  100. <set includeRule="include">
  101. <xsl:apply-templates select="*[local-name() = 'set' and @includeRule = 'include']/* "/>
  102. <xsl:if test="not( /*[local-name()='project']/*[local-name() = 'namespace']/*[local-name()='secured'])">
  103. <refobj>
  104. <xsl:value-of select="concat('[',/*[local-name()='project']/*[local-name() = 'namespace']/*[local-name() = 'name'], ']')"/>
  105. </refobj>
  106. </xsl:if>
  107. </set>
  108. </xsl:if>
  109. <xsl:apply-templates select="*[local-name() = 'set' and @includeRule != 'hide' and @includeRule != 'include']"/>
  110. </xsl:when>
  111. <xsl:otherwise>
  112. <xsl:apply-templates select="*[local-name() = 'set' and @includeRule != 'hide']"/>
  113. </xsl:otherwise>
  114. </xsl:choose>
  115. </xsl:element>
  116. </xsl:template>
  117. <!-- renaming of element querySubject/definition/dbQuery/calculations/calculationDefinition/sqlName to querySubject/definition/dbQuery/calculations/calculationDefinition/dataItemName -->
  118. <xsl:template match="*[local-name() = 'sqlName'] ">
  119. <dataItemName>
  120. <xsl:value-of select="."/>
  121. </dataItemName>
  122. </xsl:template>
  123. <!-- Remove a the secured property from the reportObjectType -->
  124. <xsl:template match="*[local-name() = 'secured'] "/>
  125. <xsl:template match="comment()">
  126. <xsl:copy/>
  127. </xsl:template>
  128. </xsl:stylesheet>