move_recipients.xslt 2.1 KB

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