12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?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 9-->
- <!--XSL Transformation from a schema v9 model to a valid BMT schema v10 model-->
- <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/10/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 v9 model-->
- <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/9')) ">
- <xsl:message terminate="yes">The input file for this transformer must be a schema v9 model.</xsl:message>
- </xsl:if>
- <xsl:apply-templates/>
- </xsl:template>
- <!--remove obsolete object attributes, type, id-->
- <xsl:template match="*">
- <xsl:element name="{name(.)}">
- <xsl:for-each select="@*">
- <xsl:if test="local-name(..) = 'sql' or (name(.) != 'type' and name(.) != 'id') ">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
- </xsl:if>
- </xsl:for-each>
- <xsl:apply-templates/>
- </xsl:element>
- </xsl:template>
- <!--change the schema to v10 version-->
- <xsl:template match="*[local-name()='project'] ">
- <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/10/0">
- <xsl:for-each select="@*">
- <xsl:choose>
- <!--change schema from v9 to v10-->
- <xsl:when test="name(.) = 'xsi:schemaLocation'">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/10/0 BMTModelSpecification.xsd'"/></xsl:attribute>
- </xsl:when>
- <xsl:when test="name(.)='type' or name(.) = 'id' "/>
- <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 obsolete prompt properties -->
- <xsl:template match="*[local-name() = 'securityObject' ]">
- <securityObject type="{@*[local-name() = 'type']}">
- <displayPath>
- <xsl:variable name="defaultLocale" select="/*[local-name()='project']/*[local-name()='defaultLocale']"/>
- <xsl:variable name="dp">
- <xsl:for-each select="*[local-name()='displayPath']">
- <xsl:if test="@*[local-name()='locale' and translate(., 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')=translate($defaultLocale, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')]">
- <xsl:value-of select="."/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <xsl:variable name="noLocale">
- <xsl:for-each select="*[local-name()='displayPath']">
- <xsl:if test="not(@*[local-name()='locale'])">
- <xsl:value-of select="."/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="string($dp)">
- <xsl:value-of select="$dp"/>
- </xsl:when>
- <xsl:when test="string($noLocale)">
- <xsl:value-of select="$noLocale"/>
- </xsl:when>
- <xsl:otherwise><xsl:comment>No displayPath with locale matched to project default locale was found, please correct original model and run upgrade again</xsl:comment></xsl:otherwise>
- </xsl:choose>
-
- </displayPath>
- <xsl:apply-templates select="*[local-name()='cmSearchPath']"/>
- </securityObject>
- </xsl:template>
- <!--remove obsolete prompt properties-->
- <xsl:template match="*[local-name() = 'isFew' or local-name()='isPromptLabel' ]"/>
- </xsl:stylesheet>
|