add-unknown-entries.xslt 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. <!--
  9. Transform used to change a CM response into the same structure returned by add recipients.
  10. Usefull since it allow us to use the same transforms to update the to, cc and bcc fields and also
  11. to update the email recipients blob.
  12. -->
  13. <xsl:stylesheet version="1.0"
  14. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  15. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  16. exclude-result-prefixes="xsl xts">
  17. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  18. <xsl:key name="recipient-to" match="/root/*[local-name()='defaultOptions']/*[local-name()='to']/*[local-name()='searchPath']" use="."/>
  19. <xsl:key name="recipient-cc" match="/root/*[local-name()='defaultOptions']/*[local-name()='cc']/*[local-name()='searchPath']" use="."/>
  20. <xsl:key name="recipient-bcc" match="/root/*[local-name()='defaultOptions']/*[local-name()='bcc']/*[local-name()='searchPath']" use="."/>
  21. <xsl:key name="recipients" match="/root/*[local-name()='defaultOptions']/*[local-name()='to' or local-name()='cc' or local-name()='bcc']/*[local-name()='searchPath']" use="."/>
  22. <xsl:template match="/root" priority="1">
  23. <xsl:copy-of select="/root/item"/>
  24. <!-- get the list of unique recipients -->
  25. <xsl:variable name="unique-recipients" select="/root/*[local-name()='defaultOptions']/*[local-name()='to' or local-name()='cc' or local-name()='bcc']/*[generate-id(.) = generate-id(key('recipients',.))]"/>
  26. <!-- if we found a recipient who isn't in our selected entries list then add him as unknown -->
  27. <xsl:for-each select="$unique-recipients[not(. = /root/item/searchPath)]">
  28. <xsl:variable name="searchPath" select="."/>
  29. <item>
  30. <searchPath><xsl:value-of select="$searchPath"/></searchPath>
  31. <userName/>
  32. <defaultName><xts:string id="IDS_OTHERRUN_EMAIL_UNKNOWN_RECIPIENT_WITH_COUNT"><xts:param name="count"><xsl:value-of select="position()"/></xts:param></xts:string></defaultName>
  33. <xsl:if test="key('recipient-to',$searchPath)">
  34. <type>to</type>
  35. </xsl:if>
  36. <xsl:if test="key('recipient-cc',$searchPath)">
  37. <type>cc</type>
  38. </xsl:if>
  39. <xsl:if test="key('recipient-bcc',$searchPath)">
  40. <type>bcc</type>
  41. </xsl:if>
  42. <!-- add an unkown flag. Needed to rebuild the recipients list if the user decides to
  43. remove all the unknown recipients -->
  44. <unknown>true</unknown>
  45. </item>
  46. </xsl:for-each>
  47. </xsl:template>
  48. <xsl:template match="text()" priority="0"/>
  49. </xsl:stylesheet>