123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <?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.
- -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" exclude-result-prefixes="bus">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
- <!-- -->
- <xsl:template match="/root">
- <selection>
- <!-- tag the version of the additions to the selection spec - it might change in future -->
- <version>2.0</version>
- <!-- save the type of the threshold -->
- <type>
- <xsl:choose>
- <xsl:when test="not(/root/env/param[@name='m_sub_type'])">
- <xsl:text>nonMetric</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="/root/env/param[@name='m_sub_type']"/>
- </xsl:otherwise>
- </xsl:choose>
- </type>
- <xsl:choose>
- <xsl:when test="/root/env/param[@name='m_sub_type'] = 'metric' ">
- <xsl:for-each select="/root/env/param[starts-with(@name, 'm_sub_perfPattern')]">
- <xsl:element name="{substring-after(string(@name),'m_sub_')}">
- <xsl:value-of select="."/>
- </xsl:element>
- </xsl:for-each>
- <xsl:for-each select="/selection/*[starts-with(local-name(),'perfPattern')]">
- <xsl:if test="not(/root/env/param[@name=concat('m_sub_',local-name())])">
- <xsl:copy-of select="."/>
- </xsl:if>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <!-- set the measure value -->
- <measure_value>
- <xsl:choose>
- <!-- we have a value from the environment -->
- <xsl:when test="/root/env/param[@name='m_sub_measure_value'] and /root/env/param[@name='m_sub_measure_value']!='' ">
- <xsl:value-of select="/root/env/param[@name='m_sub_measure_value']"/>
- </xsl:when>
- <!-- we have a value already there -->
- <xsl:when test="/root/selection/measure_value and /root/selection/measure_value !='' ">
- <xsl:value-of select="/root/selection/measure_value"/>
- </xsl:when>
- <!-- we have a default value from the selection spec itself -->
- <xsl:otherwise>
- <xsl:value-of select="/root/selection/selections/query/selection/measures/measure/item/bus:value/item/bus:use"/>
- </xsl:otherwise>
- </xsl:choose>
- </measure_value>
- <!-- measure value1 has to always be there - it's initialized with the default value just incase the between operator is selected -->
- <measure_value1>
- <xsl:choose>
- <!-- we have a value from the environment -->
- <xsl:when test="/root/env/param[@name='m_sub_measure_value1'] and /root/env/param[@name='m_sub_measure_value1']!='' ">
- <xsl:value-of select="/root/env/param[@name='m_sub_measure_value1']"/>
- </xsl:when>
- <!-- we have a value already there -->
- <xsl:when test="/root/selection/measure_value1 and /root/selection/measure_value1 !='' ">
- <xsl:value-of select="/root/selection/measure_value1"/>
- </xsl:when>
- <!-- we have a default value from the selection spec itself -->
- <xsl:otherwise>
- <xsl:value-of select="/root/selection/selections/query/selection/measures/measure/item/bus:value/item/bus:use"/>
- </xsl:otherwise>
- </xsl:choose>
- </measure_value1>
- <xsl:variable name="dtype">
- <xsl:value-of select="/root/selection/selections/query/selection/measures/measure/@dtype"/>
- </xsl:variable>
- <operation>
- <xsl:choose>
- <!-- we have a value from the environment -->
- <xsl:when test="/root/env/param[@name='m_sub_operation'] and /root/env/param[@name='m_sub_operation']!='' ">
- <xsl:value-of select="/root/env/param[@name='m_sub_operation']"/>
- </xsl:when>
- <!-- we have a value there already -->
- <xsl:when test="/root/selection/operation and /root/selection/operation != '' ">
- <xsl:value-of select="/root/selection/operation"/>
- </xsl:when>
- <!-- default the value -->
- <xsl:when test="$dtype='25' or $dtype='26' or $dtype='27' or $dtype='28' or $dtype='29' or $dtype='30' or $dtype='31' or $dtype='32' or $dtype='34' or $dtype='35' or $dtype='36' or $dtype='43' or $dtype='45' or dtype='55' or $dtype='56'">
- <xsl:text>contains</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>greater_than</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </operation>
- <!-- need other values depending on if we have between there or not -->
- <xsl:if test="/root/env/param[@name='m_sub_operation'] and /root/env/param[@name='m_sub_operation']='between' ">
- <measure_value_inclusive>
- <xsl:choose>
- <xsl:when test="/root/env/param[@name='m_sub_measure_value_inclusive']">
- <xsl:value-of select="/root/env/param[@name='m_sub_measure_value_inclusive']"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>false</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </measure_value_inclusive>
- <measure_value_inclusive1>
- <xsl:choose>
- <xsl:when test="/root/env/param[@name='m_sub_measure_value_inclusive1']">
- <xsl:value-of select="/root/env/param[@name='m_sub_measure_value_inclusive1']"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>false</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </measure_value_inclusive1>
- </xsl:if>
- <!-- case insensitive flag -->
- <case_insensitive>
- <xsl:choose>
- <xsl:when test="/root/env/param[@name='m_sub_case_insensitive']">
- <xsl:value-of select="/root/env/param[@name='m_sub_case_insensitive']"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>false</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </case_insensitive>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates mode="copy" select="selection/selections"/>
- </selection>
- </xsl:template>
- <!-- -->
- <xsl:template match="*" mode="copy">
- <xsl:param name="name"/>
- <xsl:copy>
- <!-- copy all the attributes across -->
- <xsl:copy-of select="@*"/>
- <!-- decide if we need to add the selectAll element or not attribute -->
- <xsl:choose>
- <xsl:when test="/root/env/param[@name=concat('m_subData_defaultValue_', $name)] and /root/env/param[@name=concat('m_sub_', $name)]='true' ">
- <xsl:element name="selectAll">false</xsl:element>
- </xsl:when>
- <xsl:when test="/root/env/param[@name=concat('m_subData_defaultValue_', $name)] and not(/root/env/param[@name=concat('m_sub_', $name)]) ">
- <xsl:element name="selectAll">true</xsl:element>
- </xsl:when>
- </xsl:choose>
- <!-- copy all the child nodes -->
- <xsl:for-each select="node()[not(local-name()='selectAll')]">
- <xsl:variable name="nodePosition">
- <xsl:value-of select="number(count(preceding-sibling::*)+1)"/>
- </xsl:variable>
- <xsl:apply-templates mode="copy" select=".">
- <xsl:with-param name="name">
- <xsl:value-of select="concat(string(local-name()), string($nodePosition))"/>
- </xsl:with-param>
- </xsl:apply-templates>
- </xsl:for-each>
- </xsl:copy>
- </xsl:template>
- <!-- -->
- <xsl:template match="text()" mode="copy">
- <xsl:param name="name"/>
- <xsl:value-of select="."/>
- </xsl:template>
- </xsl:stylesheet>
|