123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: CCS
- (c) Copyright IBM Corp. 2005, 2010
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <xsl:stylesheet version="1.0" xmlns="http://www.ibm.com/xmlns/prod/cognos/layoutData/200904" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rds="http://developer.cognos.com/schemas/rds/types/2">
- <xsl:param name="transformData" select="'true'"/>
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
- <xsl:template match="/">
- <xsl:choose>
- <xsl:when test="$transformData = 'true'">
- <page>
- <id>4</id>
- <xsl:apply-templates select="data"/>
- </page>
- </xsl:when>
- <xsl:otherwise>
- <rds:page>
- <!--ID is hardcoded to 4 to maintain compatibility with previous releases-->
- <id>4</id>
- <rds:posId>P1</rds:posId>
- <xsl:if test="data/tab/crosstab">
- <rds:header>
- <rds:item>
- <rds:posId>P1H1</rds:posId>
- <rds:conditional>false</rds:conditional>
- <rds:MTextFrame>
- <id>dimLine</id>
- </rds:MTextFrame>
- </rds:item>
- </rds:header>
- <rds:body>
- <rds:item>
- <rds:posId>P1B1</rds:posId>
- <rds:conditional>false</rds:conditional>
- <rds:MCrossTab>
- <id>2</id>
- </rds:MCrossTab>
- </rds:item>
- </rds:body>
- <xsl:if test="data/tab/status_line/@status">
- <rds:footer>
- <rds:item>
- <rds:posId>P1F1</rds:posId>
- <rds:conditional>false</rds:conditional>
- <rds:MTextFrame>
- <id>3</id>
- </rds:MTextFrame>
- </rds:item>
- </rds:footer>
- </xsl:if>
- </xsl:if>
- </rds:page>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="data">
- <header>
- <item>
- <txt>
- <id>dimLine</id>
- <style>dimLine</style>
- <val>
- <xsl:value-of select="tab/dimension_line/@details"/>
- </val>
- <valTyp>text</valTyp>
- <exclPatrn>General</exclPatrn>
- </txt>
- </item>
- </header>
- <body>
- <item>
- <xsl:apply-templates select="tab/crosstab"/>
- </item>
- </body>
- <xsl:if test="tab/status_line/@status">
- <footer>
- <item>
- <txt>
- <id>3</id>
- <val>
- <xsl:value-of select="normalize-space(tab/status_line/@status)"/>
- </val>
- <valTyp>text</valTyp>
- <exclPatrn>General</exclPatrn>
- </txt>
- </item>
- </footer>
- </xsl:if>
- </xsl:template>
- <xsl:template match="crosstab">
- <ctab>
- <id>2</id>
- <corner>
- <style>measurecell</style>
- <style>td</style>
- <xsl:apply-templates select="measure"/>
- </corner>
- <xsl:apply-templates select="columns"/>
- <xsl:apply-templates select="rows"/>
- <table>
- <xsl:apply-templates select="datarow"/>
- </table>
- </ctab>
- </xsl:template>
- <xsl:template match="measure">
- <item>
- <txt>
- <style>measurecell</style>
- <val>
- <xsl:value-of select="concat(@name,' ',@type)"/>
- </val>
- <valTyp>text</valTyp>
- </txt>
- </item>
- </xsl:template>
- <xsl:template match="datarow">
- <row>
- <xsl:for-each select="col">
- <cell>
- <style>td</style>
- <style>
- <xsl:call-template name="cellStyle"/>
- </style>
- <item>
- <txt>
- <style>
- <xsl:call-template name="cellStyle"/>
- </style>
- <xsl:choose>
- <xsl:when test="@calculation = 'true'">
- <val>
- <xsl:value-of select="text()"/>
- </val>
- </xsl:when>
- <xsl:otherwise>
- <val>
- <xsl:value-of select="@value"/>
- </val>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:if test="not(@value) and not(@calculation = 'true')">
- <valErrorState>NA</valErrorState>
- </xsl:if>
- <valTyp>number</valTyp>
- <xsl:if test="@formattedValue">
- <fmtVal><xsl:value-of select="@formattedValue"/></fmtVal>
- </xsl:if>
- <exclPatrn>
- <xsl:value-of select="@format"/>
- </exclPatrn>
- </txt>
- </item>
- </cell>
- </xsl:for-each>
- </row>
- </xsl:template>
- <xsl:template match="row">
- <xsl:param name="rowcount" select="count(.//row)">
- <!--Counting all rows like this is inefficient....-->
- </xsl:param>
- <name>
- <style>td</style>
- <xsl:call-template name="labelStyle"/>
- <item>
- <txt>
- <xsl:call-template name="labelStyle"/>
- <val>
- <xsl:value-of select="@name"/>
- </val>
- <valTyp>text</valTyp>
- </txt>
- </item>
- </name>
- <start>
- <xsl:choose>
- <xsl:when test="@axis_pos">
- <xsl:value-of select="@axis_pos"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@pos"/>
- </xsl:otherwise>
- </xsl:choose>
- </start>
- <size>
- <xsl:choose>
- <xsl:when test="$rowcount > 0">
- <xsl:value-of select="$rowcount"/>
- </xsl:when>
- <xsl:otherwise>1</xsl:otherwise>
- </xsl:choose>
- </size>
- <xsl:for-each select="row">
- <nestedDimension>
- <xsl:apply-templates select="."/>
- </nestedDimension>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="column">
- <xsl:param name="colcount" select="count(.//column)">
- <!--Counting all columns like this is inefficient....-->
- </xsl:param>
- <name>
- <style>td</style>
- <xsl:call-template name="labelStyle"/>
- <item>
- <txt>
- <xsl:call-template name="labelStyle"/>
- <val>
- <xsl:value-of select="@name"/>
- </val>
- <valTyp>text</valTyp>
- </txt>
- </item>
- </name>
- <start>
- <xsl:choose>
- <xsl:when test="@axis_pos">
- <xsl:value-of select="@axis_pos"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@pos"/>
- </xsl:otherwise>
- </xsl:choose>
- </start>
- <size>
- <xsl:choose>
- <xsl:when test="$colcount > 0">
- <xsl:value-of select="$colcount"/>
- </xsl:when>
- <xsl:otherwise>1</xsl:otherwise>
- </xsl:choose>
- </size>
- <xsl:for-each select="column">
- <nestedDimension>
- <xsl:apply-templates select="."/>
- </nestedDimension>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="rows">
- <xsl:for-each select="row">
- <row>
- <xsl:apply-templates select="."/>
- </row>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="columns">
- <xsl:for-each select="column">
- <column>
- <xsl:apply-templates select="."/>
- </column>
- </xsl:for-each>
- </xsl:template>
- <xsl:template name="labelStyle">
- <style>
- <xsl:choose>
- <xsl:when test="@suppressed">
- <xsl:choose>
- <xsl:when test="local-name() = 'row'">
- <xsl:choose>
- <xsl:when test="parent::row">8020rowlabelnested</xsl:when>
- <xsl:otherwise>8020rowlabel</xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="local-name() = 'column'">
- <xsl:choose>
- <xsl:when test="parent::column">8020labelcolnested</xsl:when>
- <xsl:otherwise>8020collabel</xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="@calculation">
- <xsl:choose>
- <xsl:when test="local-name() = 'row'">
- <xsl:choose>
- <xsl:when test="parent::row">calculationrowlabelnested</xsl:when>
- <xsl:otherwise>calculationrowlabel</xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="local-name() = 'column'">
- <xsl:choose>
- <xsl:when test="parent::column">calculationcollabelnested</xsl:when>
- <xsl:otherwise>calculationcollabel</xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="@summary">
- <xsl:choose>
- <xsl:when test="local-name() = 'row'">
- <xsl:choose>
- <xsl:when test="@summ_style_one">summaryrowlabel1</xsl:when>
- <xsl:otherwise>summaryrowlabel2</xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="local-name() = 'column'">
- <xsl:choose>
- <xsl:when test="@summ_style_one">summarycollabel1</xsl:when>
- <xsl:otherwise>summarycollabel2</xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="local-name() = 'row'">
- <xsl:choose>
- <xsl:when test="parent::row">rowLabelNested</xsl:when>
- <xsl:otherwise>rowLabel</xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="local-name() = 'column'">
- <xsl:choose>
- <xsl:when test="parent::column">colLabelNested</xsl:when>
- <xsl:otherwise>colLabel</xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </style>
- </xsl:template>
- <xsl:template name="cellStyle">
- <xsl:choose>
- <xsl:when test="@lowexception">lowexceptioncell</xsl:when>
- <xsl:when test="@highexception">highexceptioncell</xsl:when>
- <xsl:when test="@summary">
- <xsl:choose>
- <xsl:when test="@rank">
- <xsl:choose>
- <xsl:when test="@summ_style_one">summarycell1rank</xsl:when>
- <xsl:otherwise>summarycell2rank</xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="@suppressed or @calculation">
- <xsl:choose>
- <xsl:when test="@summ_style_one">summarycell1italic</xsl:when>
- <xsl:otherwise>summarycell2italic</xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="@summ_style_one">summarycell1</xsl:when>
- <xsl:otherwise>summarycell2</xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="@rank">rankcell</xsl:when>
- <xsl:when test="@calculation">calculationcell</xsl:when>
- <xsl:when test="@suppressed">8020cell</xsl:when>
- <xsl:otherwise>cell</xsl:otherwise>
- </xsl:choose>
- <xsl:if test="@exception">
- <unprocessedException>
- <textColor>
- <xsl:value-of select="@fontcolor"/>
- </textColor>
- <bgColor>
- <xsl:value-of select="@bgcolor"/>
- </bgColor>
- <fontSize>
- <xsl:value-of select="@fontSize"/>
- </fontSize>
- <bold>
- <xsl:value-of select="@bold"/>
- </bold>
- <italic>
- <xsl:value-of select="@italic"/>
- </italic>
- <underline>
- <xsl:value-of select="@underline"/>
- </underline>
- <textAlign>
- <xsl:value-of select="@textAlign"/>
- </textAlign>
- </unprocessedException>
- </xsl:if>
- </xsl:template>
- </xsl:stylesheet>
|