123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?xml version="1.0"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: fmmd
- (C) Copyright IBM Corp. 2003, 2013
- US Government Users Restricted Rights - Use, duplication or disclosure
- restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--XSLT version 31-->
- <!--XSL Transformation from a schema v31 model to a valid BMT schema v32 model-->
- <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">
- <xsl:output encoding="utf-8" method="xml" indent="yes"/>
- <!--root match-->
- <xsl:template match="/">
- <!--make sure that this transformation is performed on a schema v31 model-->
- <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/31')) ">
- <xsl:message terminate="yes">The input file for this transformer must be a schema v31 model.</xsl:message>
- </xsl:if>
- <xsl:apply-templates select="node()"/>
- </xsl:template>
- <!-- general copy -->
- <xsl:template match="*">
- <xsl:element name="{name(.)}">
- <xsl:for-each select="@*">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
- </xsl:for-each>
- <xsl:apply-templates select="node()"/>
- </xsl:element>
- </xsl:template>
- <!--change the schema to v32 version-->
- <xsl:template match="*[local-name()='project'] ">
- <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/32/0">
- <xsl:for-each select="@*">
- <xsl:choose>
- <!--change schema from v31 to v32-->
- <xsl:when test="name(.) = 'xsi:schemaLocation'">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/32/0 BMTModelSpecification.xsd'"/></xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- <xsl:apply-templates select="node()"/>
- </xsl:element>
- </xsl:template>
- <!-- 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.-->
- <xsl:template match="*[local-name() = 'securityViews' ] ">
- <securityViews>
- <xsl:apply-templates/>
- <xsl:if test="*[local-name() = 'securityView' and @isRoleBased = 'true']">
- <xsl:if test="not(*[local-name() = 'securityView' and @isRoleBased = 'true']/*[local-name()='name' and . = '_Everyone [Directory > Cognos]' ])">
- <securityView isRoleBased="true">
- <name>_Everyone [Directory > Cognos]</name>
- <definition>
- <xsl:if test="/*[local-name()='project']/*[local-name() = 'namespace' and not(*[local-name()='secured'])]">
- <set includeRule="include">
- <refobj>
- <xsl:value-of select="concat('[',/*[local-name()='project']/*[local-name() = 'namespace']/*[local-name() = 'name'], ']')"/>
- </refobj>
- </set>
- </xsl:if>
- </definition>
- <access>
- <decisionRole>
- <securityObject type="group">
- <displayPath>Everyone [Directory > Cognos]</displayPath>
- <cmSearchPath>CAMID("::Everyone")</cmSearchPath>
- </securityObject>
- </decisionRole>
- </access>
- </securityView>
- </xsl:if>
- </xsl:if>
- </securityViews>
- </xsl:template>
- <!-- 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.-->
- <xsl:template match="*[local-name() = 'packages' ] ">
- <packages>
- <xsl:apply-templates/>
- <xsl:if test="*[local-name() = 'package' and @isRoleBased = 'true' ] and not(*[local-name() = 'package' and @isRoleBased = 'true' ]/*[local-name() = 'name' and . ='_Everyone [Directory > Cognos]' ] )">
- <package isRoleBased="true">
- <name locale="{/*[local-name() = 'project']/*[local-name() = 'defaultLocale']}">_Everyone [Directory > Cognos]</name>
- <xsl:apply-templates select="/*[local-name() = 'project']/*[local-name() = 'locales']"/>
- <definition>
- <viewref>[].[securityViews].[_Everyone [Directory > Cognos]]]</viewref>
- </definition>
- <adminAccess/>
- </package>
- </xsl:if>
- </packages>
- </xsl:template>
- <!-- check if the root namespace object is secured ... if not, then add a reference to it in the package's "include" list -->
- <!-- Remove all "hide" sets from role-based packages -->
- <xsl:template match="*[local-name() = 'securityView' and @isRoleBased = 'true' ]/*[local-name() = 'definition'] ">
- <xsl:element name="{name(.)}">
- <xsl:choose>
- <xsl:when test=" ( ../*[local-name()='name' and . = '_Everyone [Directory > Cognos]'] )">
- <xsl:if test="*[local-name() = 'set' and @includeRule = 'include'] or not(/*[local-name()='project']/*[local-name() = 'namespace']/*[local-name()='secured']) ">
- <set includeRule="include">
- <xsl:apply-templates select="*[local-name() = 'set' and @includeRule = 'include']/* "/>
- <xsl:if test="not( /*[local-name()='project']/*[local-name() = 'namespace']/*[local-name()='secured'])">
- <refobj>
- <xsl:value-of select="concat('[',/*[local-name()='project']/*[local-name() = 'namespace']/*[local-name() = 'name'], ']')"/>
- </refobj>
- </xsl:if>
- </set>
- </xsl:if>
- <xsl:apply-templates select="*[local-name() = 'set' and @includeRule != 'hide' and @includeRule != 'include']"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="*[local-name() = 'set' and @includeRule != 'hide']"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:template>
- <!-- renaming of element querySubject/definition/dbQuery/calculations/calculationDefinition/sqlName to querySubject/definition/dbQuery/calculations/calculationDefinition/dataItemName -->
- <xsl:template match="*[local-name() = 'sqlName'] ">
- <dataItemName>
- <xsl:value-of select="."/>
- </dataItemName>
- </xsl:template>
- <!-- Remove a the secured property from the reportObjectType -->
- <xsl:template match="*[local-name() = 'secured'] "/>
- <xsl:template match="comment()">
- <xsl:copy/>
- </xsl:template>
- </xsl:stylesheet>
|