123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?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 3-->
- <!--XSL Transformation from a schema v3 model to a valid BMT schema v4 model-->
- <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/4/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 not performed on a schema v4 model-->
- <xsl:if test="/*[local-name() = 'project']/@xsi:schemaLocation = 'http://www.developer.cognos.com/schemas/bmt/4/0 BMTModelSpecification.xsd'">
- <xsl:message terminate="yes">The input file for this transformer must be a schema v3 model. You tried to use a schema v4 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 v4 version-->
- <xsl:template match="*[local-name() = 'project']">
- <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/4/0">
- <xsl:for-each select="@*">
- <xsl:choose>
- <!--change schema from v3 to v4-->
- <xsl:when test="name(.) = 'xsi:schemaLocation'">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/4/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/>
- </xsl:element>
- </xsl:template>
- <!--rename an includeObj and its enum types-->
- <xsl:template match="*[local-name() = 'includeObj']">
- <xsl:element name="includeObjectRef">
- <xsl:choose>
- <xsl:when test=". = 'self'">
- <xsl:value-of select="'include'"/>
- </xsl:when>
- <xsl:when test=". = 'children'">
- <xsl:value-of select="'include'"/>
- </xsl:when>
- <xsl:when test=". = 'excludeChildren'">
- <xsl:value-of select="'exclude'"/>
- </xsl:when>
- <xsl:when test=". = 'excludeSelf'">
- <xsl:value-of select="'suppress'"/>
- </xsl:when>
- </xsl:choose>
- </xsl:element>
- </xsl:template>
- <!--remove name from a storedProcedure, add locale atrribute to name (but not for source/name)-->
- <xsl:template match="*[local-name() = 'name']">
- <xsl:if test="not(name(parent::*) = 'storedProcedure')">
- <xsl:element name="name">
- <xsl:if test="not(name(parent::*) = 'source')">
- <xsl:choose>
- <xsl:when test="not(@locale)">
- <xsl:attribute name="locale"><xsl:value-of select="/*[local-name() = 'project']/*[local-name() = 'defaultLocale']"/></xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="locale"><xsl:value-of select="@locale"/></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- <xsl:apply-templates/>
- </xsl:element>
- </xsl:if>
- </xsl:template>
- <!--remove description from a storedProcedure, add locale atrribute to description-->
- <xsl:template match="*[local-name() = 'description']">
- <xsl:if test="not(name(parent::*) = 'storedProcedure')">
- <xsl:element name="description">
- <xsl:choose>
- <xsl:when test="not(@locale)">
- <xsl:attribute name="locale"><xsl:value-of select="/*[local-name() = 'project']/*[local-name() = 'defaultLocale']"/></xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="locale"><xsl:value-of select="@locale"/></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates/>
- </xsl:element>
- </xsl:if>
- </xsl:template>
- <!--remove format from a storedProcedure, add locale atrribute to format-->
- <xsl:template match="*[local-name() = 'format']">
- <xsl:element name="format">
- <xsl:choose>
- <xsl:when test="not(@locale)">
- <xsl:attribute name="locale"><xsl:value-of select="/*[local-name() = 'project']/*[local-name() = 'defaultLocale']"/></xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="locale"><xsl:value-of select="@locale"/></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates/>
- </xsl:element>
- </xsl:template>
- <!--remove lastChanged from a storedProcedure-->
- <xsl:template match="*[local-name() = 'lastChanged']">
- <xsl:if test="not(name(parent::*) = 'storedProcedure')">
- <xsl:element name="lastChanged">
- <xsl:apply-templates/>
- </xsl:element>
- </xsl:if>
- </xsl:template>
- <!--remove packages and subtree completely-->
- <xsl:template match="*[local-name() = 'packages']"/>
- </xsl:stylesheet>
|