123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: ASV
- (C) Copyright IBM Corp. 2005, 2010
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--
- Agent Service version 1.0
- NB this stylesheet is run on a DOM I complient parser by rsvp
- there is only minimal namespace handling
- NB that means that if there is an attribute with a namespace like bus:name you have to test it with name() = 'bus:name' no other test will work
- -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rsext="xalan://com.cognos.reportserver.ext.RSExt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
- <xsl:template match="/">
- <!-- Check for a table header -->
- <dataset version="1.0">
- <xsl:element name="metadata">
- <xsl:apply-templates select="//DR[./DRI[@type='columnTitle']]" mode="metadata"/>
- </xsl:element>
- <xsl:element name="data">
- <xsl:apply-templates select="//DR[./DRI[@type='datavalue']]" mode="data"/>
- </xsl:element>
- <xsl:element name="drills">
- <xsl:apply-templates select="//DRILLS"/>
- </xsl:element>
- </dataset>
- </xsl:template>
- <xsl:template match="DR" mode="metadata">
- <xsl:for-each select="DRI">
- <xsl:variable name="position" select="position()"/>
-
- <xsl:element name="item">
- <xsl:attribute name="name"><xsl:value-of select="//DR/DRI[@type='columnTitle'][position()=$position]/OTI"/></xsl:attribute>
-
- <xsl:variable name="drillIndex">
- <xsl:value-of select="number(//DR[./DRI[@type='datavalue']][last()]/DRI[position()=$position]//drillTargets/drillTarget/@drillIdx) + 1"/>
- </xsl:variable>
-
- <xsl:attribute name="type">
- <!-- the xsd type is a new feature for raw xml in late bering mr2 -->
- <xsl:choose>
- <xsl:when test="//DR[./DRI[@type='datavalue']]/DRI[position()=$position]/OTI/@xsdType">
- <xsl:value-of select="//DR[./DRI[@type='datavalue']]/DRI[position()=$position]/OTI/@xsdType"/>
- </xsl:when>
- <xsl:when test="//DR[./DRI[@type='datavalue']]/DRI[position()=$position]//OIMG">
- <xsl:text>xsdString</xsl:text>
- </xsl:when>
- <xsl:when test="./OTI/@xsdType">
- <xsl:value-of select="./OTI/@xsdType"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="./OTI/@valueType"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <xsl:variable name="drillType">
- <xsl:value-of select="//DRILLS/DRILL[position()=$drillIndex]/*[name()='bus:parameters']/item/*[name()='bus:type']"/>
- </xsl:variable>
-
- <!--will we have a mun value available ? welcome to the crazy world of raw xml -->
- <xsl:attribute name="mun">
- <xsl:choose>
- <xsl:when test="//DR[./DRI[@type='datavalue']]/DRI[position()=$position]//drillTargets/drillTarget/drillParameter/@mun != ''">true</xsl:when>
- <xsl:when test="$drillType='memberUniqueName' and //DR[./DRI[@type='datavalue']]/DRI[position()=$position]//drillTargets/drillTarget/drillParameter/@value != ''">true</xsl:when>
- <xsl:otherwise>false</xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:element>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="DR" mode="data">
- <xsl:element name="row">
- <xsl:apply-templates select="./DRI[@type='datavalue']//*[local-name()='OTI' or local-name()='OIMG']"/>
- </xsl:element>
- </xsl:template>
- <xsl:template match="DRILL">
- <xsl:element name="drill">
- <xsl:attribute name="objectPath">
- <xsl:value-of select="@path"/>
- </xsl:attribute>
- <xsl:apply-templates select="*[name()='bus:parameters']"/>
- </xsl:element>
- </xsl:template>
-
- <xsl:template match="*[name()='bus:parameters']">
- <xsl:apply-templates select="*[name()='item']"/>
- </xsl:template>
-
- <xsl:template match="item[parent::node()[name()='bus:parameters']]">
- <xsl:element name="parameter">
- <xsl:attribute name="name"><xsl:value-of select="*[name()='bus:name']"/></xsl:attribute>
- <xsl:attribute name="type"><xsl:value-of select="*[name()='bus:type']"/></xsl:attribute>
- </xsl:element>
- </xsl:template>
- <!-- In the case of regular report data it looks like this
- <DR>
- <DRI >
- <OTI ></OTI>
- </DRI>
- </DR>
- In the case of drilled parameters the report data looks like this
- <DR>
- <DRI>
- <drillTargets>
- ... <drillTarget drillIdx="0">
- <drillParameter name="product" value="[great outdoors].[Products].[Products].[Product name]->:[PC].[@MEMBER].[30013]" displayValue="Star Gazer 2"/>
- </drillTarget>
- <OTI></OTI>
- </drillTargets>
- </DRI>
- </DR>
- So this match should accept both types
- -->
-
- <xsl:template match="OTI">
- <xsl:if test="not(contains(@style,'visibility:hidden'))">
- <xsl:element name="value">
- <xsl:if test="@RawXML != text()">
- <xsl:attribute name="rawValue"><xsl:value-of select="@RawXML"/></xsl:attribute>
- </xsl:if>
- <xsl:if test="normalize-space(.) = '' ">
- <xsl:attribute name="xs:nil">true</xsl:attribute>
- </xsl:if>
- <xsl:attribute name="presentationValue"><xsl:value-of select="text()"/></xsl:attribute>
-
- <!-- fix for bug 522357 - we grab the mun value from the drill trhrough results-->
- <xsl:for-each select="../drillTarget">
-
- <xsl:variable name="drillIndex">
- <xsl:value-of select="number(./@drillIdx) + 1"/>
- </xsl:variable>
- <xsl:variable name="drillValue">
- <xsl:choose>
- <xsl:when test="./drillParameter/@mun"><xsl:value-of select="./drillParameter/@mun"/></xsl:when>
- <xsl:when test="//DRILLS/DRILL[position()=$drillIndex]/*[name()='bus:parameters']/item/*[name()='bus:type'] = 'memberUniqueName'">
- <!--the value attribute contains a mun when the drill parameter is memberUniqueName -->
- <xsl:value-of select="./drillParameter/@value"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:element name="drillthrough">
- <xsl:attribute name="drillPosition"><xsl:value-of select="@drillIdx"/></xsl:attribute>
- <xsl:attribute name="drillValue"><xsl:value-of select="$drillValue"/></xsl:attribute>
- <xsl:attribute name="parameterName"><xsl:value-of select="./drillParameter/@name"/></xsl:attribute>
- </xsl:element>
-
- </xsl:for-each>
- </xsl:element>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="OIMG">
- <xsl:element name="value">
- <xsl:attribute name="presentationValue"><xsl:value-of select="@src"/></xsl:attribute>
-
- <!-- fix for bug 522357 - we grab the mun value from the drill trhrough results-->
- <xsl:for-each select=".//drillTarget">
-
- <xsl:variable name="drillIndex">
- <xsl:value-of select="number(./@drillIdx) + 1"/>
- </xsl:variable>
- <xsl:variable name="drillValue">
- <xsl:choose>
- <xsl:when test="./drillParameter/@mun"><xsl:value-of select="./drillParameter/@mun"/></xsl:when>
- <xsl:when test="//DRILLS/DRILL[position()=$drillIndex]/*[name()='bus:parameters']/item/*[name()='bus:type'] = 'memberUniqueName'">
- <!--the value attribute contains a mun when the drill parameter is memberUniqueName -->
- <xsl:value-of select="./drillParameter/@value"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:element name="drillthrough">
- <xsl:attribute name="drillPosition"><xsl:value-of select="@drillIdx"/></xsl:attribute>
- <xsl:attribute name="drillValue"><xsl:value-of select="$drillValue"/></xsl:attribute>
- <xsl:attribute name="parameterName"><xsl:value-of select="./drillParameter/@name"/></xsl:attribute>
- </xsl:element>
-
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
-
- </xsl:stylesheet>
|