move_recipients.xslt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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:template match="/root">
  19. <!--
  20. append a ; to the end of each field so we can user '<displayName>;' to check if an added recipient is in a given field. We might
  21. end up with two ; at the end of the field, but it won't cause any issues.
  22. -->
  23. <xsl:variable name="toField" select="concat(/root/toField,';')"/>
  24. <xsl:variable name="ccField" select="concat(/root/ccField,';')"/>
  25. <xsl:variable name="bccField" select="concat(/root/bccField,';')"/>
  26. <!-- build up a list of the newly added recipients -->
  27. <xsl:element name="addedRecipients">
  28. <xsl:for-each select="*[local-name()='addedRecipients']/*[local-name()='item']">
  29. <xsl:variable name="displayName" select="concat(*[local-name()='displayName'],';')"/>
  30. <xsl:variable name="emailTo" select="contains($toField,$displayName)"/>
  31. <xsl:variable name="emailCc" select="contains($ccField,$displayName)"/>
  32. <xsl:variable name="emailBcc" select="contains($bccField,$displayName)"/>
  33. <xsl:if test="$emailTo or $emailCc or $emailBcc">
  34. <xsl:element name="item">
  35. <xsl:copy-of select="*[local-name() != 'type']"/>
  36. <xsl:if test="$emailTo">
  37. <xsl:element name="type">to</xsl:element>
  38. </xsl:if>
  39. <xsl:if test="$emailCc">
  40. <xsl:element name="type">cc</xsl:element>
  41. </xsl:if>
  42. <xsl:if test="$emailBcc">
  43. <xsl:element name="type">bcc</xsl:element>
  44. </xsl:if>
  45. </xsl:element>
  46. </xsl:if>
  47. </xsl:for-each>
  48. </xsl:element>
  49. </xsl:template>
  50. <xsl:template match="text()" priority="0"/>
  51. </xsl:stylesheet>