123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?xml version="1.0"?>
- <xsl:stylesheet xmlns="http://www.developer.cognos.com/schemas/bmt/21/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"/>
-
- <xsl:template match="/">
-
- <xsl:if test="not(contains(/*[local-name() = 'project']/@xsi:schemaLocation, 'http://www.developer.cognos.com/schemas/bmt/20')) ">
- <xsl:message terminate="yes">The input file for this transformer must be a schema v20 model.</xsl:message>
- </xsl:if>
- <xsl:apply-templates/>
- </xsl:template>
-
- <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:template match="*[local-name()='project'] ">
- <xsl:element name="project" namespace="http://www.developer.cognos.com/schemas/bmt/21/0">
- <xsl:for-each select="@*">
- <xsl:choose>
-
- <xsl:when test="name(.) = 'xsi:schemaLocation'">
- <xsl:attribute name="{name(.)}"><xsl:value-of select="'http://www.developer.cognos.com/schemas/bmt/21/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:template match="*[local-name() = 'property']">
- <property name="{@name}">
- <xsl:if test="@type">
- <xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute>
- </xsl:if>
- <xsl:choose>
- <xsl:when test="string(@value)">
- <xsl:value-of select="@value"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </property>
- </xsl:template>
-
- <xsl:template match="*[local-name() = 'table']">
- <table>
- <xsl:variable name="tblName">
- <xsl:choose>
- <xsl:when test="contains(., '].') ">
- <xsl:value-of select="substring-after(., '].')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="quotedName">
- <xsl:choose>
- <xsl:when test="contains($tblName, ' ')">
- <xsl:value-of select="concat('"', $tblName,'"' )"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$tblName"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="contains(., '].')">
- <xsl:value-of select="concat(substring-before(., '].' ), '].', $quotedName)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$quotedName"/>
- </xsl:otherwise>
- </xsl:choose>
- </table>
- </xsl:template>
- </xsl:stylesheet>
|