123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <?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.
- -->
- <!--
- Transform used to change a CM response into the same structure returned by add recipients.
- Usefull since it allow us to use the same transforms to update the to, cc and bcc fields and also
- to update the email recipients blob.
- -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/" exclude-result-prefixes="xsl xts">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
- <xsl:key name="recipient-to" match="/root/*[local-name()='defaultOptions']/*[local-name()='to']/*[local-name()='searchPath']" use="."/>
- <xsl:key name="recipient-cc" match="/root/*[local-name()='defaultOptions']/*[local-name()='cc']/*[local-name()='searchPath']" use="."/>
- <xsl:key name="recipient-bcc" match="/root/*[local-name()='defaultOptions']/*[local-name()='bcc']/*[local-name()='searchPath']" use="."/>
- <xsl:template match="/root" priority="2">
- <xsl:choose>
- <!-- Special case for attachments
- When the report task aren't saved, we get a GUID from Event studio as the searchPath. We can't use those
- GUIDS to query cm, so we must loop through the options blob and merge the cm response with the information
- passed in to get all the information needed to display the attachments in the UI
- -->
- <xsl:when test="/root/action = 'attachments'">
- <!-- loop through the attachment options -->
- <xsl:for-each select="/root/*[local-name()='defaultOptions']/*[local-name()='attachments' or local-name()='eventOutput']/*">
- <xsl:variable name="searchPath" select="*[local-name()='searchPath']"/>
- <item>
- <xsl:variable name="defaultName">
- <xsl:choose>
- <xsl:when test="starts-with($searchPath, 'AgentTask-')">
- <xsl:value-of select="/root/*[local-name()='attachParam']/*[./*[local-name()='searchPath']=$searchPath]/*[local-name()='defaultName']"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="/root/*[local-name()='queryResponse']/*/*[./*[local-name()='searchPath']=$searchPath]/*[local-name()='defaultName']"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="local-name()='eventOutput'">
- <searchPath>
- <xsl:value-of select="$searchPath"/>
- </searchPath>
- <attachmentName>
- <xts:string id="IDS_EMAIL_OPTIONS_EVENT_OUTPUT"/>
- </attachmentName>
- <defaultName>
- <xsl:value-of select="$defaultName"/>
- </defaultName>
- <format/>
- <locale/>
- </xsl:when>
- <xsl:otherwise>
- <searchPath>
- <xsl:value-of select="$searchPath"/>
- </searchPath>
- <attachmentName>
- <xsl:choose>
- <xsl:when test="string-length($defaultName) > 13">
- <xsl:variable name="ellipsis">
- <xts:string id="IDS_LIST_ELLIPSIS"/>
- </xsl:variable>
- <xsl:value-of select="concat(substring($defaultName,1,13),$ellipsis)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$defaultName"/>
- </xsl:otherwise>
- </xsl:choose>
- </attachmentName>
- <defaultName>
- <xsl:value-of select="$defaultName"/>
- </defaultName>
- <format>
- <xsl:value-of select="*[local-name()='format']"/>
- </format>
- <locale>
- <xsl:value-of select="*[local-name()='locale']"/>
- </locale>
- </xsl:otherwise>
- </xsl:choose>
- </item>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:for-each select="*[local-name()='queryResponse']/*[local-name()='queryReply']">
- <xsl:variable name="searchPath" select="*/*[local-name()='searchPath']"/>
- <xsl:variable name="position" select="position()"/>
- <xsl:choose>
- <!-- build the links list -->
- <xsl:when test="/root/action = 'links'">
- <item>
- <searchPath>
- <xsl:value-of select="$searchPath"/>
- </searchPath>
- <objectClass>
- <xsl:value-of select="*/*[local-name()='objectClass']"/>
- </objectClass>
- <displayName>
- <xsl:value-of select="*/*[local-name()='defaultName']"/>
- </displayName>
- </item>
- </xsl:when>
- <!-- build the recipients list -->
- <xsl:otherwise>
- <!-- only add the entry if we got something back from CM -->
- <xsl:if test="$searchPath != ''">
- <!-- To recipient -->
- <xsl:if test="key('recipient-to',$searchPath)">
- <xsl:call-template name="buildItem">
- <xsl:with-param name="searchPath" select="$searchPath"/>
- <xsl:with-param name="query" select="*"/>
- <xsl:with-param name="type">
- <xsl:text>to</xsl:text>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:if>
- <!-- CC recipient -->
- <xsl:if test="key('recipient-cc',$searchPath)">
- <xsl:call-template name="buildItem">
- <xsl:with-param name="searchPath" select="$searchPath"/>
- <xsl:with-param name="query" select="*"/>
- <xsl:with-param name="type">
- <xsl:text>cc</xsl:text>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:if>
- <!-- BCC recipient -->
- <xsl:if test="key('recipient-bcc',$searchPath)">
- <xsl:call-template name="buildItem">
- <xsl:with-param name="searchPath" select="$searchPath"/>
- <xsl:with-param name="query" select="*"/>
- <xsl:with-param name="type">
- <xsl:text>bcc</xsl:text>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:if>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="buildItem">
- <xsl:param name="searchPath"/>
- <xsl:param name="query"/>
- <xsl:param name="type"/>
- <item>
- <searchPath>
- <xsl:value-of select="$searchPath"/>
- </searchPath>
- <userName>
- <xsl:value-of select="$query/*[local-name()='userName']"/>
- </userName>
- <defaultName>
- <xsl:value-of select="$query/*[local-name()='defaultName']"/>
- </defaultName>
- <objectClass>
- <xsl:value-of select="$query/*[local-name()='objectClass']"/>
- </objectClass>
- <xsl:choose>
- <xsl:when test="$query/*[local-name()='objectClass'] = 'account'">
- <type>
- <xsl:value-of select="$type"/>
- </type>
- </xsl:when>
- <xsl:otherwise>
- <type>
- <xsl:value-of select="concat($type,'Group')"/>
- </type>
- </xsl:otherwise>
- </xsl:choose>
- </item>
- </xsl:template>
- <xsl:template match="text()" priority="0"/>
- </xsl:stylesheet>
|