update_email_recipients.xslt 5.1 KB

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