123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?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 8-->
- <!--XSL Transformation from a schema v8 model to a valid BMT schema v9 model-->
- <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/9/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 v8 model-->
- <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/8')) ">
- <xsl:message terminate="yes">The input file for this transformer must be a schema v8 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 v9 version-->
- <xsl:template match="*[local-name()='project'] ">
- <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/9/0">
- <xsl:for-each select="@*">
- <xsl:choose>
- <!--change schema from v8 to v9-->
- <xsl:when test="name(.) = 'xsi:schemaLocation'">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/9/4 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="*[local-name()='name' or local-name()='lastChanged' or local-name()='description' or local-name()='screenTip']"/>
- <xsl:apply-templates select="*[local-name()='locales' or local-name()='defaultLocale' or local-name()='templates']"/>
- <xsl:apply-templates select="*[local-name()='logicalModel'] "/>
- <xsl:if test="not(*[ local-name()='logicalModel' ])">
- <logicalModel>
- <name locale="{*[local-name()='defaultLocale']}">Model</name>
- </logicalModel>
- </xsl:if>
- <xsl:apply-templates select="*[local-name()='parameterMaps'] "/>
- <xsl:if test="not(*[ local-name()='parameterMaps' ])">
- <parameterMaps/>
- </xsl:if>
- <xsl:apply-templates select="*[local-name()='securityViews'] "/>
- <xsl:if test="not(*[ local-name()='securityViews' ])">
- <securityViews/>
- </xsl:if>
- <xsl:apply-templates select="*[local-name()='packages'] "/>
- <xsl:if test="not(*[ local-name()='packages' ])">
- <packages/>
- </xsl:if>
- <xsl:apply-templates select="*[local-name()='functions'] "/>
- <xsl:if test="not(*[ local-name()='functions' ])">
- <functions/>
- </xsl:if>
- </xsl:element>
- </xsl:template>
- <!--convert securityView to new schema-->
- <xsl:template match="*[local-name() = 'parameterMap']">
- <parameterMap>
- <name>
- <xsl:value-of select="*[local-name()='name' ]"/>
- </name>
- <xsl:apply-templates select="*[local-name() !='name' and local-name() !='lastChanged' and local-name() !='description' and local-name() !='screenTip']"/>
- </parameterMap>
- </xsl:template>
- <xsl:template match="*[local-name() = 'package']">
- <package>
- <xsl:apply-templates/>
- <xsl:if test="not(*[ local-name()='functions' ])">
- <functions/>
- </xsl:if>
- </package>
- </xsl:template>
- <!--remove package (but not packages container) completely-->
- <xsl:template match="*[local-name() = 'securityFilterDefinition' or local-name()='decisionRole' ]"/>
- <!-- revert a typo in 4to5 -->
- <xsl:template match="*[local-name() = 'collectionsSequenceName' ]">
- <collationSequenceName>
- <xsl:value-of select="."/>
- </collationSequenceName>
- </xsl:template>
- <xsl:template match="*[local-name() = 'collectionsSequenceLevel' ]">
- <collationSequenceLevel>
- <xsl:value-of select="."/>
- </collationSequenceLevel>
- </xsl:template>
- <xsl:template match="*[local-name() = 'originalCollectionsSequenceName' ]">
- <originalCollationSequenceName>
- <xsl:value-of select="."/>
- </originalCollationSequenceName>
- </xsl:template>
- </xsl:stylesheet>
|