123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?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 10-->
- <!--XSL Transformation from a schema v10 model to a valid BMT schema v11 model-->
- <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/11/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 v10 model-->
- <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/10')) ">
- <xsl:message terminate="yes">The input file for this transformer must be a schema v10 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 v11 version-->
- <xsl:template match="*[local-name()='project'] ">
- <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/11/0">
- <xsl:for-each select="@*">
- <xsl:choose>
- <!--change schema from v10 to v11-->
- <xsl:when test="name(.) = 'xsi:schemaLocation'">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/11/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>
- <xsl:variable name="UPPERCASE" select=" 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' "/>
- <xsl:variable name="LOWCASE" select=" 'abcdefghijklmnopqrstuvwxyz' "/>
- <!--correct enumerations in queryItem -->
- <xsl:template match="*[local-name() = 'queryItem' ]">
- <queryItem>
- <xsl:for-each select="*">
- <xsl:choose>
- <xsl:when test="local-name() = 'usage' ">
- <usage>
- <xsl:variable name="str" select="substring-after(., 'kUsage')"/>
- <xsl:value-of select="concat(translate(substring($str, 1, 1), $UPPERCASE, $LOWCASE), substring($str, 2))"/>
- </usage>
- </xsl:when>
- <xsl:when test="local-name() = 'semiAggregate' or local-name() = 'regularAggregate'">
- <xsl:element name="{local-name()}">
- <xsl:variable name="str" select="substring-after(., 'kAggregateRule')"/>
- <xsl:value-of select="concat(translate(substring($str, 1, 1), $UPPERCASE, $LOWCASE), substring($str, 2))"/>
- </xsl:element>
- </xsl:when>
- <xsl:when test="local-name() = 'datatype' ">
- <datatype>
- <xsl:variable name="str" select="substring-after(., 'kDataType')"/>
- <xsl:value-of select="concat(translate(substring($str, 1, 1), $UPPERCASE, $LOWCASE), substring($str, 2))"/>
- </datatype>
- </xsl:when>
- <xsl:when test="local-name() = 'displayType' ">
- <displayType>
- <xsl:value-of select="concat(translate(substring(., 1, 1), $UPPERCASE, $LOWCASE), substring(., 2))"/>
- </displayType>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </queryItem>
- </xsl:template>
- <!--correct enumerations in sql/@type and property/@type -->
- <xsl:template match="*[local-name() = 'sql' or local-name()='property' ]">
- <xsl:element name="{local-name()}">
- <xsl:for-each select="@*">
- <xsl:choose>
- <xsl:when test="local-name()='type' ">
- <xsl:attribute name="type"><xsl:value-of select="concat(translate(substring(., 1, 1), $UPPERCASE, $LOWCASE), substring(., 2))"/></xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- <xsl:apply-templates/>
- </xsl:element>
- </xsl:template>
- <!--correct enumerations in mincard and maxcard -->
- <xsl:template match="*[local-name() = 'mincard' or local-name()='maxcard']">
- <xsl:element name="{local-name()}">
- <xsl:variable name="str" select="substring-after(., 'kCardinality')"/>
- <xsl:value-of select="concat(translate(substring($str, 1, 1), $UPPERCASE, $LOWCASE), substring($str, 2))"/>
- </xsl:element>
- </xsl:template>
- </xsl:stylesheet>
|