123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: Viewer
- (C) Copyright IBM Corp. 2001, 2011
- US Government Users Restricted Rights - Use, duplication or
- disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
- xmlns:xsi="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="/getAction">
- <xsl:variable name="path"><xsl:value-of select="/*[local-name()='getAction']/drillAction/param[@name='ui.object']"/></xsl:variable>
- <xsl:variable name="cmQueryResponseRootNode" select="/*[local-name()='getAction']/*[local-name()='cmResponseNode'][@refId=$path]"/>
- <xsl:variable name="cmQueryResponseNode" select="$cmQueryResponseRootNode/*[local-name()='queryResponse']/*[local-name()='queryReply']/*[local-name()='query' or local-name()='report' or local-name()='analysis' or local-name()='reportView'][*[local-name()='searchPath']=$path]"/>
- <xsl:variable name="method"><xsl:value-of select="/*[local-name()='getAction']/*[local-name()='drillAction']/*[local-name()='param'][@name='ui.action']"/></xsl:variable>
- <xsl:variable name="desiredOutputFormat"><xsl:value-of select="/*[local-name()='getAction']/*[local-name()='drillAction']/*[local-name()='param'][@name='run.outputFormat']"/></xsl:variable>
- <xsl:variable name="hasSavedOutput">
- <xsl:choose>
- <xsl:when test="$cmQueryResponseRootNode/*[local-name()='queryResponse']/*[local-name()='queryReply']/*[local-name()='output']">true</xsl:when>
- <xsl:otherwise>false</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="desiredMethod">
- <xsl:call-template name="getDesiredMethod">
- <xsl:with-param name="cmQueryResponseNode" select="$cmQueryResponseNode"/>
- <xsl:with-param name="method" select="$method"/>
- <xsl:with-param name="hasSavedOutput" select="$hasSavedOutput"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="outputFormat">
- <xsl:call-template name="getPermittedOutputFormat">
- <xsl:with-param name="cmQueryResponseNode" select="$cmQueryResponseNode"/>
- <xsl:with-param name="desiredOutputFormat" select="$desiredOutputFormat"/>
- <xsl:with-param name="desiredMethod" select="$desiredMethod"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:element name="env">
- <param name="ui.action"><xsl:value-of select="$desiredMethod"/></param>
- <param name="run.outputFormat"><xsl:value-of select="$outputFormat"/></param>
- <xsl:choose>
- <xsl:when test="string(/getAction/drillAction/param[@name='run.prompt']) = 'true'">
- <param name="run.prompt">true</param>
- </xsl:when>
- <xsl:otherwise>
- <param name="run.prompt">false</param>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="$desiredMethod = 'view'">
- <param name="ui.format"><xsl:value-of select="$outputFormat"/></param>
- <param name="ui.object">
- <xsl:text>defaultOutput(</xsl:text>
- <xsl:value-of select="/getAction/drillAction/param[@name='ui.object']"/>
- <xsl:text>,'</xsl:text>
- <xsl:value-of select="$outputFormat"/>
- <xsl:text>', '')</xsl:text>
- </param>
- </xsl:when>
- <xsl:otherwise>
- <param name="ui.object"><xsl:value-of select="/getAction/drillAction/param[@name='ui.object']"/></param>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:for-each select="/getAction/drillAction/param[not(@name='ui.action' or @name='run.outputFormat' or @name='ui.format' or @name='ui.object')]">
- <xsl:element name="param">
- <xsl:attribute name="name"><xsl:value-of select="./@name"/></xsl:attribute>
- <xsl:value-of select="."/>
- </xsl:element>
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
- <xsl:template match="/getTargets">
- <xsl:for-each select="/*[local-name()='getTargets']/*[local-name()='drillTargets']/*[local-name()='drillTarget']">
- <xsl:variable name="path"><xsl:value-of select="./@path"/></xsl:variable>
- <xsl:variable name="desiredOutputFormat"><xsl:value-of select="./@outputFormat"/></xsl:variable>
- <xsl:variable name="cmQueryResponseRootNode" select="/*[local-name()='getTargets']/*[local-name()='cmResponseNode'][@refId=$path]"/>
- <xsl:variable name="cmQueryResponseNode" select="$cmQueryResponseRootNode/*[local-name()='queryResponse']/*[local-name()='queryReply']/*[local-name()='query' or local-name()='report' or local-name()='analysis' or local-name()='reportView'][*[local-name()='searchPath']=$path]"/>
- <xsl:choose>
- <xsl:when test="$cmQueryResponseNode">
- <xsl:variable name="hasSavedOutput">
- <xsl:choose>
- <xsl:when test="$cmQueryResponseRootNode/*[local-name()='queryResponse']/*[local-name()='queryReply']/*[local-name()='output']">true</xsl:when>
- <xsl:otherwise>false</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="desiredMethod">
- <xsl:call-template name="getDesiredMethod">
- <xsl:with-param name="cmQueryResponseNode" select="$cmQueryResponseNode"/>
- <xsl:with-param name="method" select="./@method"/>
- <xsl:with-param name="hasSavedOutput" select="$hasSavedOutput"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:if test="$desiredMethod!=''">
- <xsl:variable name="outputFormat">
- <xsl:call-template name="getPermittedOutputFormat">
- <xsl:with-param name="cmQueryResponseNode" select="$cmQueryResponseNode"/>
- <xsl:with-param name="desiredOutputFormat" select="$desiredOutputFormat"/>
- <xsl:with-param name="desiredMethod" select="$desiredMethod"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:element name="drillTarget">
- <xsl:attribute name="method">
- <xsl:value-of select="$desiredMethod"/>
- </xsl:attribute>
- <xsl:attribute name="outputFormat">
- <xsl:value-of select="$outputFormat"/>
- </xsl:attribute>
- <xsl:choose>
- <xsl:when test="$desiredMethod = 'view'">
- <xsl:attribute name="format">
- <xsl:value-of select="$outputFormat"/>
- </xsl:attribute>
- <xsl:attribute name="path">
- <xsl:text>defaultOutput(</xsl:text>
- <xsl:value-of select="./@path"/>
- <xsl:text>,'</xsl:text>
- <xsl:value-of select="$outputFormat"/>
- <xsl:text>', '')</xsl:text>
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="path">
- <xsl:value-of select="./@path"/>
- </xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:for-each select="@*[not(name()='method' or name()='outputFormat' or name()='format' or name()='path')]">
- <xsl:attribute name="{name()}">
- <xsl:value-of select="."/>
- </xsl:attribute>
- </xsl:for-each>
- <xsl:copy-of select="./*"/>
- </xsl:element>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:template>
- <xsl:template name="getPermittedOutputFormat">
- <xsl:param name="cmQueryResponseNode"/>
- <xsl:param name="desiredOutputFormat"/>
- <xsl:param name="desiredMethod"/>
- <xsl:choose>
- <xsl:when test="$desiredOutputFormat='default'">
- <xsl:choose>
- <xsl:when test="$desiredMethod='view'">
- <xsl:choose>
- <xsl:when test="$cmQueryResponseNode/*[local-name()='defaultOutputFormat']!=''">
- <xsl:value-of select="$cmQueryResponseNode/*[local-name()='defaultOutputFormat']"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>HTML</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="$cmQueryResponseNode/*[local-name()='executionFormat']!=''">
- <xsl:value-of select="$cmQueryResponseNode/*[local-name()='executionFormat']"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>HTML</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$desiredOutputFormat"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="getDesiredMethod">
- <xsl:param name="cmQueryResponseNode"/>
- <xsl:param name="method"/>
- <xsl:param name="hasSavedOutput"/>
- <xsl:choose>
- <xsl:when test="$method='edit'">
- <xsl:call-template name="getEditMethod">
- <xsl:with-param name="cmQueryResponseNode" select="$cmQueryResponseNode"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$method='default'">
- <xsl:choose>
- <xsl:when test="$cmQueryResponseNode/*[local-name()='defaultPortalAction']='viewOutput'">
- <xsl:choose>
- <xsl:when test="$hasSavedOutput='true'">view</xsl:when>
- <!-- if no output is saved, default to execute -->
- <xsl:otherwise>
- <xsl:call-template name="getEditMethod">
- <xsl:with-param name="cmQueryResponseNode" select="$cmQueryResponseNode"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="$cmQueryResponseNode/*[local-name()='defaultPortalAction']='run'">
- <xsl:text>run</xsl:text>
- </xsl:when>
- <xsl:when test="$cmQueryResponseNode/*[local-name()='defaultPortalAction']='edit'">
- <xsl:call-template name="getEditMethod">
- <xsl:with-param name="cmQueryResponseNode" select="$cmQueryResponseNode"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <!--we may not have read permissions on this obj, if that's the case, default the action to execute-->
- <xsl:text>run</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="$method='view'">
- <xsl:choose>
- <xsl:when test="$hasSavedOutput='true'">view</xsl:when>
- <!-- if no output is saved, default to execute -->
- <xsl:otherwise>
- <xsl:call-template name="getEditMethod">
- <xsl:with-param name="cmQueryResponseNode" select="$cmQueryResponseNode"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$method"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="getEditMethod">
- <xsl:param name="cmQueryResponseNode"/>
- <xsl:choose>
- <xsl:when test="$cmQueryResponseNode/*[local-name()='objectClass']='query'">
- <xsl:text>editQuery</xsl:text>
- </xsl:when>
- <xsl:when test="$cmQueryResponseNode/*[local-name()='objectClass']='analysis'">
- <xsl:text>editAnalysis</xsl:text>
- </xsl:when>
- <!-- for now, if the report author has set the target to be edit, and the target is a report studio report, just do an execute -->
- <xsl:otherwise>
- <xsl:text>run</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="/appendDrillSpecs">
- <xsl:for-each select="/*[local-name()='appendDrillSpecs']/*[local-name()='drillTargets']/*[local-name()='drillTarget']">
- <xsl:element name="drillTarget">
- <xsl:variable name="drillIdx"><xsl:value-of select="./@drillIdx"/></xsl:variable>
- <xsl:for-each select="/*[local-name()='appendDrillSpecs']/*[local-name()='drillSpecs']/*/*[local-name()='DRILL'][(position()-1) = $drillIdx]/@*[not(name()='label')]">
- <xsl:attribute name="{name()}">
- <xsl:value-of select="."/>
- </xsl:attribute>
- </xsl:for-each>
- <xsl:attribute name="label">
- <xsl:choose>
- <xsl:when test="string(./@label) != ''">
- <xsl:value-of select="./@label"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="/*[local-name()='appendDrillSpecs']/*[local-name()='drillSpecs']/*/*[local-name()='DRILL'][(position()-1) = $drillIdx]/@label"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:for-each select="./*[local-name()='drillParameter']">
- <drillParameter>
- <xsl:copy-of select="@*"/>
- <xsl:variable name="parameterName" select="@name"/>
- <xsl:if test="/*[local-name()='appendDrillSpecs']/*[local-name()='drillSpecs']/*/*[local-name()='DRILL'][(position()-1) = $drillIdx]/PARAMETER-PROPERTIES/Parameter[@name=string($parameterName)]">
- <xsl:attribute name="propertyToPass">
- <xsl:value-of select="/*[local-name()='appendDrillSpecs']/*[local-name()='drillSpecs']/*/*[local-name()='DRILL'][(position()-1) = $drillIdx]/PARAMETER-PROPERTIES/Parameter/@propertyToPass"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:copy-of select="./*"/>
- </drillParameter>
- </xsl:for-each>
- <xsl:copy-of select="./*[local-name()!='drillParameter']"/>
- <xsl:copy-of select="/*[local-name()='appendDrillSpecs']/*[local-name()='drillSpecs']/*/*[local-name()='DRILL'][(position()-1) = $drillIdx]/*[local-name()!='PARAMETER-PROPERTIES']"/>
- </xsl:element>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="/sourceContextNodes">
- <xsl:choose>
- <xsl:when test="/sourceContextNodes/*[local-name()='targetParameters']/*[local-name()='promptDataSourceResponse']">
- <targetParameters>
- <parameters>
- <xsl:copy-of select="/sourceContextNodes/*[local-name()='targetParameters']/*[local-name()='promptDataSourceResponse']/*/*/*[local-name()='details']/*[local-name()='item'][@xsi:type='bus:asynchDetailParameters']/*[local-name()='parameters']/*"/>
- </parameters>
- </targetParameters>
- <sourceContextValues>
- <parameterValues>
- <xsl:copy-of select="/sourceContextNodes/*[local-name()='sourceContextValues']/*/*"/>
- </parameterValues>
- </sourceContextValues>
- <dataSourceConnection>
- <xsl:copy-of select="/sourceContextNodes/*[local-name()='targetParameters']/*[local-name()='promptDataSourceResponse']/*/*/*[local-name()='details']/*[local-name()='item'][@xsi:type='bus:asynchDetailParameterValues']/*[local-name()='parameters']"/>
- </dataSourceConnection>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="/sourceContextNodes/*"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="*[local-name()='extractCredential']">
- <xsl:copy-of select="/*[local-name()='extractCredential']/*[local-name()='sourceParameterValues']/*/*[local-name()='item'][starts-with(string(./*[local-name()='name']),'credential:')]"/>
- <xsl:for-each select="/*[local-name()='extractCredential']/*[local-name()='targetParameters']/*[local-name()='parameters']/*[local-name()='item'][@xsi:type='bus:parameterDataSource']">
- <xsl:variable name="dataSourceParameterName"><xsl:value-of select="./*[local-name()='name']"/></xsl:variable>
- <xsl:copy-of select="/*[local-name()='extractCredential']/*[local-name()='sourceParameterValues']/*/*[local-name()='item'][./*[local-name()='name']=$dataSourceParameterName]"/>
- </xsl:for-each>
- </xsl:template>
- <!--When doing a drill through, check to see if there are parameter values being passed in. If so, set the prompt run option to false, otherwise set it to true.
- By setting the prompt run option to true, if there are prompt pages to be displayed, the report server will display the authored prompt pages instead of the
- default prompt page.
- -->
- <xsl:template match="*[local-name()='getPromptRunOption']">
- <param name="run.prompt">
- <xsl:choose>
- <xsl:when test="/*[local-name()='getPromptRunOption']/*/*">
- <xsl:text>false</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>true</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </param>
- </xsl:template>
- </xsl:stylesheet>
|