123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?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"
- exclude-result-prefixes="xsl">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
-
- <xsl:key name="env-param" match="/root/env/param" use="@name"/>
- <xsl:template match="/root/env" priority="3">
- <xsl:apply-templates/>
- </xsl:template>
- <!-- handle the email to field -->
- <xsl:template match="param[@name='email_to']" priority="2">
- <param name="to">
- <xsl:call-template name="parse-addresses">
- <xsl:with-param name="addresses" select="."/>
- <xsl:with-param name="propertyType" select="'to'"/>
- </xsl:call-template>
- </param>
- </xsl:template>
- <!-- handle the email cc field -->
- <xsl:template match="param[@name='email_cc']" priority="2">
- <param name="cc">
- <xsl:call-template name="parse-addresses">
- <xsl:with-param name="addresses" select="."/>
- <xsl:with-param name="propertyType" select="'cc'"/>
- </xsl:call-template>
- </param>
- </xsl:template>
- <!-- handle the email bcc field -->
- <xsl:template match="param[@name='email_bcc']" priority="2">
- <param name="bcc">
- <xsl:call-template name="parse-addresses">
- <xsl:with-param name="addresses" select="."/>
- <xsl:with-param name="propertyType" select="'bcc'"/>
- </xsl:call-template>
- </param>
- </xsl:template>
- <!-- recursively trim the trailing spaces from a string -->
- <xsl:template name="trimTrailingSpaces">
- <xsl:param name="strInput" select="''" />
- <xsl:variable name="strLen" select="string-length($strInput)" />
- <xsl:variable name="strOutput" select="substring($strInput, 1, $strLen - 1 )" />
- <xsl:variable name="strLastChar" select="substring($strInput, $strLen, 1 )" />
- <xsl:choose>
- <xsl:when test="$strLastChar = ' '">
- <!-- call the template recursively until it is trimmed -->
- <xsl:call-template name="trimTrailingSpaces">
- <xsl:with-param name="strInput" select="$strOutput" />
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$strInput" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- recursively trim the leading spaces from a string -->
- <xsl:template name="trimLeadingSpaces">
- <xsl:param name="strInput" select="''" />
- <xsl:variable name="strLen" select="string-length($strInput)" />
- <xsl:variable name="strOutput" select="substring($strInput, 2, $strLen - 1 )" />
- <xsl:variable name="strFirstChar" select="substring($strInput, 1, 1 )" />
- <xsl:choose>
- <xsl:when test="$strFirstChar = ' '">
- <!-- call the template recursively until it is trimmed -->
- <xsl:call-template name="trimLeadingSpaces">
- <xsl:with-param name="strInput" select="$strOutput" />
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$strInput" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- recursively trim the trailing and leading spaces from a string (calls templates trimLeadingSpaces and trimTrailingSpaces) -->
- <xsl:template name="trimTrailingLeadingSpaces">
- <xsl:param name="strInput" select="''" />
- <!-- trim off leading spaces (recursively) -->
- <xsl:variable name="strTrimmed1">
- <xsl:call-template name="trimLeadingSpaces">
- <xsl:with-param name="strInput" select="$strInput" />
- </xsl:call-template>
- </xsl:variable>
- <!-- trim off trailing spaces (recursively) -->
- <xsl:variable name="strTrimmed2">
- <xsl:call-template name="trimTrailingSpaces">
- <xsl:with-param name="strInput" select="$strTrimmed1" />
- </xsl:call-template>
- </xsl:variable>
- <xsl:value-of select="$strTrimmed2" />
- </xsl:template>
- <xsl:template name="parse-addresses">
- <xsl:param name="addresses" select="''"/>
- <xsl:param name="propertyType"/>
- <xsl:if test="$addresses != ''">
- <xsl:variable name="before">
- <xsl:choose>
- <xsl:when test="contains($addresses,';')">
- <!-- Trim leading and trailing spaces -->
- <xsl:call-template name="trimTrailingLeadingSpaces">
- <xsl:with-param name="strInput" select="substring-before($addresses,';')" />
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="trimTrailingLeadingSpaces">
- <xsl:with-param name="strInput" select="$addresses" />
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="after">
- <xsl:if test="contains($addresses,';')">
- <!-- Trim leading and trailing spaces -->
- <xsl:call-template name="trimTrailingLeadingSpaces">
- <xsl:with-param name="strInput" select="substring-after($addresses,';')" />
- </xsl:call-template>
- </xsl:if>
- </xsl:variable>
- <xsl:if test="$before!=''">
-
- <!-- this is where we check to see if the address was types in or selected from the add entries dialog -->
- <xsl:choose>
- <xsl:when test="/root/*[local-name()='addedRecipients']/*[*[local-name()='displayName' and string(.) = $before]]/*[local-name()='type' and string(.)=$propertyType]">
- <param name="{$propertyType}"><xsl:value-of select="/root/*[local-name()='addedRecipients']/*[*[local-name()='displayName' and string(.) = $before]]/*[local-name()='searchPath']"/></param>
- </xsl:when>
- <xsl:when test="/root/*[local-name()='addedRecipients']/*[*[local-name()='displayName' and string(.) = $before]]/*[local-name()='type' and string(.)=concat($propertyType,'Group')]">
- <param name="{concat($propertyType,'Group')}"><xsl:value-of select="/root/*[local-name()='addedRecipients']/*[*[local-name()='displayName' and string(.) = $before]]/*[local-name()='searchPath']"/></param>
- </xsl:when>
- <xsl:otherwise>
- <param name="{concat($propertyType,'Address')}"><xsl:value-of select="$before"/></param>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- <xsl:if test="$after!=''">
- <xsl:call-template name="parse-addresses">
- <xsl:with-param name="addresses" select="$after"/>
- <xsl:with-param name="propertyType" select="$propertyType"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:if>
- </xsl:template>
-
- <!-- copy all other params -->
- <xsl:template match="*[local-name()='param']" priority="1">
- <xsl:element name="param">
- <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
- <xsl:value-of select="."/>
- </xsl:element>
- </xsl:template>
-
- <xsl:template match="text()" priority="0"/>
- </xsl:stylesheet>
|