12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?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 7-->
- <!--XSL Transformation from a schema v7 model to a valid BMT schema v8 model-->
- <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">
- <xsl:output encoding="utf-8" method="xml" indent="yes"/>
- <!--root match-->
- <xsl:template match="/">
- <!--make sure that this transformation is performed on a schema v7 model-->
- <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/7')) ">
- <xsl:message terminate="yes">The input file for this transformer must be a schema v7 model.</xsl:message>
- </xsl:if>
- <xsl:apply-templates/>
- </xsl:template>
- <!--generic match, copies over the element unless it is redefined later in the file-->
- <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/>
- </xsl:element>
- </xsl:template>
- <!--change the schema to v8 version-->
- <xsl:template match="*[local-name()='project'] ">
- <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/8/0">
- <xsl:for-each select="@*">
- <xsl:choose>
- <!--change schema from v7 to v8-->
- <xsl:when test="name(.) = 'xsi:schemaLocation'">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/8/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/>
- <packages>
- <xsl:apply-templates select="*[local-name()='securityViews']/*[local-name()='securityView']" mode="asPackage"/>
- </packages>
- </xsl:element>
- </xsl:template>
- <xsl:template match="*[local-name() = 'securityView']" mode="asPackage">
- <package>
- <xsl:apply-templates select="*[local-name()='name' or local-name()='lastChanged' or local-name()='description' or local-name()='screenTip']"/>
- <xsl:apply-templates select="/*[local-name()='project']/*[local-name()='locales']"/>
- <definition>
- <viewref>
- <xsl:text>[securityViews].[</xsl:text>
- <xsl:value-of select="*[local-name()='name']"/>
- <xsl:text>]</xsl:text>
- </viewref>
- </definition>
- </package>
- </xsl:template>
- <!--convert securityView to new schema-->
- <xsl:template match="*[local-name() = 'securityView']">
- <securityView>
- <xsl:apply-templates select="*[local-name()='name' or local-name()='lastChanged' or local-name()='description' or local-name()='screenTip']"/>
- <definition>
- <xsl:for-each select="*[local-name()='apex']">
- <xsl:if test="string(.)">
- <set includeRule="include">
- <refobj><xsl:value-of select="."/></refobj>
- </set>
- </xsl:if>
- </xsl:for-each>
- <xsl:for-each select="*[local-name()='exclude' or local-name()='hide']">
- <xsl:for-each select="*[local-name()='refobj'] ">
- <set includeRule="{local-name(..)}">
- <refobj><xsl:value-of select="."/></refobj>
- </set>
- </xsl:for-each>
- </xsl:for-each>
- </definition>
- <access/>
- </securityView>
- </xsl:template>
- <!--remove package (but not packages container) completely-->
- <xsl:template match="*[local-name() = 'packages']"/>
- </xsl:stylesheet>
|