update_email_recipients.xslt 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2011
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  15. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  16. exclude-result-prefixes="xsl xts xtsext">
  17. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  18. <xsl:key name="prev-recipient-to" match="/root/*[local-name()='previouslyAdded']/item[./*[local-name()='type' and string(.)='to']]/*[local-name()='searchPath']" use="."/>
  19. <xsl:key name="prev-recipient-cc" match="/root/*[local-name()='previouslyAdded']/item[./*[local-name()='type' and string(.)='cc']]/*[local-name()='searchPath']" use="."/>
  20. <xsl:key name="prev-recipient-bcc" match="/root/*[local-name()='previouslyAdded']/item[./*[local-name()='type' and string(.)='bcc']]/*[local-name()='searchPath']" use="."/>
  21. <xsl:template match="/root" priority="2">
  22. <!-- email to -->
  23. <xsl:variable name="new_email_to">
  24. <xsl:for-each select="/root/*[local-name()='selectedEntries']/*[*[local-name()='type'] = 'to']">
  25. <xsl:variable name="searchPath" select="*[local-name()='searchPath']"/>
  26. <xsl:if test="not(key('prev-recipient-to', $searchPath))">
  27. <xsl:variable name="displayName">
  28. <xsl:text/>
  29. <xsl:call-template name="createDisplayName">
  30. <xsl:with-param name="defaultName" select="*[local-name()='defaultName']"/>
  31. <xsl:with-param name="userName" select="*[local-name()='userName']"/>
  32. </xsl:call-template>
  33. <xsl:text/>
  34. </xsl:variable>
  35. <xsl:value-of select="concat($displayName,';')"/>
  36. </xsl:if>
  37. </xsl:for-each>
  38. </xsl:variable>
  39. <!-- email cc -->
  40. <xsl:variable name="new_email_cc">
  41. <xsl:for-each select="/root/*[local-name()='selectedEntries']/*[*[local-name()='type'] = 'cc']">
  42. <xsl:variable name="searchPath" select="*[local-name()='searchPath']"/>
  43. <xsl:if test="not(key('prev-recipient-cc', $searchPath))">
  44. <xsl:variable name="displayName">
  45. <xsl:text/>
  46. <xsl:call-template name="createDisplayName">
  47. <xsl:with-param name="defaultName" select="*[local-name()='defaultName']"/>
  48. <xsl:with-param name="userName" select="*[local-name()='userName']"/>
  49. </xsl:call-template>
  50. <xsl:text/>
  51. </xsl:variable>
  52. <xsl:value-of select="concat($displayName,';')"/>
  53. </xsl:if>
  54. </xsl:for-each>
  55. </xsl:variable>
  56. <!-- email bcc -->
  57. <xsl:variable name="new_email_bcc">
  58. <xsl:for-each select="/root/*[local-name()='selectedEntries']/*[*[local-name()='type'] = 'bcc']">
  59. <xsl:variable name="searchPath" select="*[local-name()='searchPath']"/>
  60. <xsl:if test="not(key('prev-recipient-bcc', $searchPath))">
  61. <xsl:variable name="displayName">
  62. <xsl:text/>
  63. <xsl:call-template name="createDisplayName">
  64. <xsl:with-param name="defaultName" select="*[local-name()='defaultName']"/>
  65. <xsl:with-param name="userName" select="*[local-name()='userName']"/>
  66. </xsl:call-template>
  67. <xsl:text/>
  68. </xsl:variable>
  69. <xsl:value-of select="concat($displayName,';')"/>
  70. </xsl:if>
  71. </xsl:for-each>
  72. </xsl:variable>
  73. <param name="email_to">
  74. <xsl:value-of select="concat($new_email_to, /root/env/param[@name='email_to'])"/>
  75. </param>
  76. <param name="email_cc">
  77. <xsl:value-of select="concat($new_email_cc, /root/env/param[@name='email_cc'])"/>
  78. </param>
  79. <param name="email_bcc">
  80. <xsl:value-of select="concat($new_email_bcc, /root/env/param[@name='email_bcc'])"/>
  81. </param>
  82. <xsl:if test="key('prev-recipient-to', /root/*[local-name()='selectedEntries']/*[*[local-name()='type'] = 'to']/*[local-name()='searchPath']) or
  83. key('prev-recipient-cc', /root/*[local-name()='selectedEntries']/*[*[local-name()='type'] = 'cc']/*[local-name()='searchPath']) or
  84. key('prev-recipient-bcc', /root/*[local-name()='selectedEntries']/*[*[local-name()='type'] = 'bcc']/*[local-name()='searchPath'])">
  85. <param name="duplicateEntryAdded">true</param>
  86. </xsl:if>
  87. </xsl:template>
  88. <!-- build the value for the input field. Has the format of -->
  89. <xsl:template name="createDisplayName">
  90. <xsl:param name="userName" select="''"/>
  91. <xsl:param name="defaultName" select="''"/>
  92. <xsl:choose>
  93. <xsl:when test="$userName !=''">
  94. <xsl:text/>
  95. <xts:string id="IDS_EMAIL_DISPLAY_USER">
  96. <xts:param name="defaultName"><xsl:value-of select="$defaultName"/></xts:param>
  97. <xts:param name="userName"><xsl:value-of select="$userName"/></xts:param>
  98. </xts:string><xsl:text/>
  99. </xsl:when>
  100. <xsl:otherwise>
  101. <xsl:value-of select="$defaultName"/>
  102. </xsl:otherwise>
  103. </xsl:choose>
  104. </xsl:template>
  105. <xsl:template match="text()" priority="0"/>
  106. </xsl:stylesheet>