123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: ps
- (C) Copyright IBM Corp. 2005, 2011
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--
- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- -->
- <!--
- 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 != ''">
- <item>
- <searchPath><xsl:value-of select="$searchPath"/></searchPath>
- <userName><xsl:value-of select="*/*[local-name()='userName']"/></userName>
- <defaultName><xsl:value-of select="*/*[local-name()='defaultName']"/></defaultName>
-
- <xsl:if test="key('recipient-to',$searchPath)">
- <type>to</type>
- </xsl:if>
- <xsl:if test="key('recipient-cc',$searchPath)">
- <type>cc</type>
- </xsl:if>
- <xsl:if test="key('recipient-bcc',$searchPath)">
- <type>bcc</type>
- </xsl:if>
- </item>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="text()" priority="0"/>
- </xsl:stylesheet>
|