123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?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 16-->
- <!--XSL Transformation from a schema v16 model to a valid BMT schema v17 model-->
- <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/17/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 v16 model-->
- <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/16')) ">
- <xsl:message terminate="yes">The input file for this transformer must be a schema v16 model.</xsl:message>
- </xsl:if>
- <xsl:apply-templates/>
- </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/>
- </xsl:element>
- </xsl:template>
- <!--change the schema to v17 version-->
- <xsl:template match="*[local-name()='project'] ">
- <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/17/0">
- <xsl:for-each select="@*">
- <xsl:choose>
- <!--change schema from v16 to v17-->
- <xsl:when test="name(.) = 'xsi:schemaLocation'">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/17/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>
- <!--remove any existing functions -->
- <xsl:template match="* [ local-name() = 'function' ]"/>
- <!-- drop the whole querySubject if it is a function type procedure -->
- <xsl:template match="* [ local-name() = 'querySubject' ] ">
- <xsl:if test="not(*[local-name() = 'definition' ]/*[local-name() = 'storedProcedure']/*[local-name()='type' and . = 'function' ])">
- <xsl:element name="{ local-name() }">
- <xsl:for-each select="@*">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
- </xsl:for-each>
- <xsl:apply-templates/>
- </xsl:element>
- </xsl:if>
- </xsl:template>
- <!-- fix stored procedure -->
- <xsl:template match="* [ local-name() = 'storedProcedure' ]">
- <xsl:if test="*[local-name()='type' and . != 'function' ]">
- <storedProcedure>
- <xsl:apply-templates select="*[local-name() = 'source' or local-name() = 'type' ]"/>
- <procParameters>
- <xsl:for-each select="*[local-name() = 'procParameter'] ">
- <procParameter>
- <xsl:apply-templates select="*[local-name() = 'parameterName' or local-name() = 'mode' or local-name() = 'datatype' or local-name() = 'precision']"/>
- <xsl:apply-templates select="*[local-name() = 'scale' ]"/>
- <xsl:apply-templates select="*[ local-name() = 'size' or local-name() = 'nullable' ]"/>
- <xsl:apply-templates select="*[local-name() = 'value' ]"/>
- </procParameter>
- </xsl:for-each>
- </procParameters>
- </storedProcedure>
- </xsl:if>
- </xsl:template>
- </xsl:stylesheet>
|