1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?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 23-->
- <!--XSL Transformation from a schema v23 model to a valid BMT schema v24 model-->
- <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/24/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 v23 model-->
- <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/23')) ">
- <xsl:message terminate="yes">The input file for this transformer must be a schema v23 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>
- <xsl:variable name="lowcase" select=" 'abcdefghijklmnopqrstuvwxyz' "/>
- <xsl:variable name="UPPERCASE" select=" 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' "/>
- <xsl:variable name="DEFAULT_LOCALE" select="translate(/*/*[local-name() = 'defaultLocale'], $lowcase, $UPPERCASE)"/>
- <!--change the schema to v24 version-->
- <xsl:template match="*[local-name()='project'] ">
- <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/24/0">
- <xsl:for-each select="@*">
- <xsl:choose>
- <!--change schema from v23 to v24-->
- <xsl:when test="name(.) = 'xsi:schemaLocation'">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/24/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:variable name="newName">
- <xsl:for-each select="*[local-name() = 'name']">
- <xsl:if test=" translate( @locale , $lowcase, $UPPERCASE ) = $DEFAULT_LOCALE ">
- <xsl:value-of select="."/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <name>
- <xsl:choose>
- <xsl:when test="string($newName)">
- <xsl:value-of select="$newName"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="*[local-name()='name'][1]"/>
- </xsl:otherwise>
- </xsl:choose>
- </name>
- <xsl:apply-templates select="*[local-name() != 'name' and local-name() != 'description' and local-name() != 'lastChanged' and local-name() != 'screenTip' ]"/>
- </xsl:element>
- </xsl:template>
- <xsl:template match="*[local-name() = 'relationship' or local-name() = 'relationshipShortcut' or local-name() = 'securityView' ]">
- <xsl:element name="{local-name()}">
- <xsl:for-each select="@*">
- <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
- </xsl:for-each>
- <xsl:variable name="newName">
- <xsl:for-each select="*[local-name() = 'name']">
- <xsl:if test=" translate( @locale , $lowcase, $UPPERCASE ) = $DEFAULT_LOCALE ">
- <xsl:value-of select="."/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <name>
- <xsl:choose>
- <xsl:when test="string($newName)">
- <xsl:value-of select="$newName"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="*[local-name()='name'][1]"/>
- </xsl:otherwise>
- </xsl:choose>
- </name>
- <xsl:apply-templates select="*[local-name() != 'name' and local-name() != 'description' and local-name() != 'lastChanged' and local-name() != 'screenTip' ]"/>
- </xsl:element>
- </xsl:template>
- </xsl:stylesheet>
|