123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?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 13-->
- <!--XSL Transformation from a schema v13 model to a valid BMT schema v14 model-->
- <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/14/0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xalan="http://xml.apache.org/xslt" extension-element-prefixes="xalan">
- <xsl:output encoding="utf-8" method="xml" indent="yes"/>
- <xsl:key name="DS_KEY" match="*[local-name()='source']" use="concat(*[local-name()='database'], ':', *[local-name()='catalog'], ':', *[local-name()='schema'])"/>
- <!--root match-->
- <xsl:template match="/">
- <!--make sure that this transformation is performed on a schema v13 model-->
- <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/13')) ">
- <xsl:message terminate="yes">The input file for this transformer must be a schema v13 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 v14 version-->
- <xsl:template match="*[local-name()='project'] ">
- <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/14/0">
- <xsl:for-each select="@*">
- <xsl:choose>
- <!--change schema from v13 to v14-->
- <xsl:when test="name(.) = 'xsi:schemaLocation'">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/14/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>
- <!--Create a new mandatory empty dataSources object-->
- <xsl:template match="*[local-name()='logicalModel']">
- <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:element name="dataSources"/>
- </xsl:template>
- <!--Create a new "promptInfo" property and move all prompt properties under this new property.
- For "promptCascadeOn", "promptDisplayItems", "promptFilterItem", remove if it contains nothing ... if it contains at least one "refobj" entry, then
- rename to reftype and set its value to being value of the first "refobj" found-->
- <xsl:template match="*[local-name()='queryItem'] ">
- <xsl:variable name="cascadeOnFlag" select="count(*[name()='promptCascadeOn'])"/>
- <xsl:variable name="displayItemsFlag" select="count(*[name()='promptDisplayItems'])"/>
- <xsl:variable name="filterItemsFlag" select="count(*[name()='promptFilterItems'])"/>
- <xsl:variable name="promptType" select="*[name()='promptType']"/>
- <xsl:element name="queryItem">
- <xsl:for-each select="*">
- <xsl:choose>
- <xsl:when test="name()='displayType'">
- <xsl:element name="{name(.)}">
- <xsl:value-of select="."/>
- </xsl:element>
- <xsl:if test="($cascadeOnFlag > 0) or ($displayItemsFlag > 0) or ($filterItemsFlag > 0)">
- <xsl:element name="promptInfo">
- <xsl:element name="promptType">
- <xsl:value-of select="$promptType"/>
- </xsl:element>
- <xsl:for-each select="../*[local-name()='promptCascadeOn']">
- <xsl:variable name="refcount" select="count(./*[local-name()='refobj'])"/>
- <xsl:if test="($refcount > 0)">
- <xsl:element name="promptCascadeOnRef">
- <xsl:value-of select="../*[local-name()='promptCascadeOn']/*[local-name()='refobj']"/>
- </xsl:element>
- </xsl:if>
- </xsl:for-each>
- <xsl:for-each select="../*[local-name()='promptDisplayItems']">
- <xsl:variable name="refcount" select="count(./*[local-name()='refobj'])"/>
- <xsl:if test="($refcount > 0)">
- <xsl:element name="promptDisplayItemRef">
- <xsl:value-of select="../*[local-name()='promptCascadeOn']/*[local-name()='refobj']"/>
- </xsl:element>
- </xsl:if>
- </xsl:for-each>
- <xsl:for-each select="../*[local-name()='promptFilterItems']">
- <xsl:variable name="refcount" select="count(./*[local-name()='refobj'])"/>
- <xsl:if test="($refcount > 0)">
- <xsl:element name="promptFilterItemRef">
- <xsl:value-of select="../*[local-name()='promptFilterItems']/*[local-name()='refobj']"/>
- </xsl:element>
- </xsl:if>
- </xsl:for-each>
- </xsl:element>
- </xsl:if>
- </xsl:when>
- <xsl:when test="name()='promptType'"/>
- <xsl:when test="name()='promptCascadeOn'"/>
- <xsl:when test="name()='promptDisplayItems'"/>
- <xsl:when test="name()='promptFilterItems'"/>
- <!--Copy over the elements and its attributes-->
- <xsl:otherwise>
- <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:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
- </xsl:stylesheet>
|