gen-standard-list.xslt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. <!--
  13. Transform used to change a CM response into the same structure returned by add recipients.
  14. Usefull since it allow us to use the same transforms to update the to, cc and bcc fields and also
  15. to update the email recipients blob.
  16. -->
  17. <xsl:stylesheet version="1.0"
  18. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  19. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  20. exclude-result-prefixes="xsl xts">
  21. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  22. <xsl:key name="recipient-to" match="/root/*[local-name()='defaultOptions']/*[local-name()='to']/*[local-name()='searchPath']" use="."/>
  23. <xsl:key name="recipient-cc" match="/root/*[local-name()='defaultOptions']/*[local-name()='cc']/*[local-name()='searchPath']" use="."/>
  24. <xsl:key name="recipient-bcc" match="/root/*[local-name()='defaultOptions']/*[local-name()='bcc']/*[local-name()='searchPath']" use="."/>
  25. <xsl:template match="/root" priority="2">
  26. <xsl:choose>
  27. <!-- Special case for attachments
  28. When the report task aren't saved, we get a GUID from Event studio as the searchPath. We can't use those
  29. GUIDS to query cm, so we must loop through the options blob and merge the cm response with the information
  30. passed in to get all the information needed to display the attachments in the UI
  31. -->
  32. <xsl:when test="/root/action = 'attachments'">
  33. <!-- loop through the attachment options -->
  34. <xsl:for-each select="/root/*[local-name()='defaultOptions']/*[local-name()='attachments' or local-name()='eventOutput']/*">
  35. <xsl:variable name="searchPath" select="*[local-name()='searchPath']"/>
  36. <item>
  37. <xsl:variable name="defaultName">
  38. <xsl:choose>
  39. <xsl:when test="starts-with($searchPath, 'AgentTask-')">
  40. <xsl:value-of select="/root/*[local-name()='attachParam']/*[./*[local-name()='searchPath']=$searchPath]/*[local-name()='defaultName']"/>
  41. </xsl:when>
  42. <xsl:otherwise>
  43. <xsl:value-of select="/root/*[local-name()='queryResponse']/*/*[./*[local-name()='searchPath']=$searchPath]/*[local-name()='defaultName']"/>
  44. </xsl:otherwise>
  45. </xsl:choose>
  46. </xsl:variable>
  47. <xsl:choose>
  48. <xsl:when test="local-name()='eventOutput'">
  49. <searchPath>
  50. <xsl:value-of select="$searchPath"/>
  51. </searchPath>
  52. <attachmentName>
  53. <xts:string id="IDS_EMAIL_OPTIONS_EVENT_OUTPUT"/>
  54. </attachmentName>
  55. <defaultName><xsl:value-of select="$defaultName"/></defaultName>
  56. <format/>
  57. <locale/>
  58. </xsl:when>
  59. <xsl:otherwise>
  60. <searchPath><xsl:value-of select="$searchPath"/></searchPath>
  61. <attachmentName>
  62. <xsl:choose>
  63. <xsl:when test="string-length($defaultName) > 13">
  64. <xsl:variable name="ellipsis"><xts:string id="IDS_LIST_ELLIPSIS"/></xsl:variable>
  65. <xsl:value-of select="concat(substring($defaultName,1,13),$ellipsis)"/>
  66. </xsl:when>
  67. <xsl:otherwise>
  68. <xsl:value-of select="$defaultName"/>
  69. </xsl:otherwise>
  70. </xsl:choose>
  71. </attachmentName>
  72. <defaultName><xsl:value-of select="$defaultName"/></defaultName>
  73. <format><xsl:value-of select="*[local-name()='format']"/></format>
  74. <locale><xsl:value-of select="*[local-name()='locale']"/></locale>
  75. </xsl:otherwise>
  76. </xsl:choose>
  77. </item>
  78. </xsl:for-each>
  79. </xsl:when>
  80. <xsl:otherwise>
  81. <xsl:for-each select="*[local-name()='queryResponse']/*[local-name()='queryReply']">
  82. <xsl:variable name="searchPath" select="*/*[local-name()='searchPath']"/>
  83. <xsl:variable name="position" select="position()"/>
  84. <xsl:choose>
  85. <!-- build the links list -->
  86. <xsl:when test="/root/action = 'links'">
  87. <item>
  88. <searchPath><xsl:value-of select="$searchPath"/></searchPath>
  89. <objectClass><xsl:value-of select="*/*[local-name()='objectClass']"/></objectClass>
  90. <displayName><xsl:value-of select="*/*[local-name()='defaultName']"/></displayName>
  91. </item>
  92. </xsl:when>
  93. <!-- build the recipients list -->
  94. <xsl:otherwise>
  95. <!-- only add the entry if we got something back from CM -->
  96. <xsl:if test="$searchPath != ''">
  97. <item>
  98. <searchPath><xsl:value-of select="$searchPath"/></searchPath>
  99. <userName><xsl:value-of select="*/*[local-name()='userName']"/></userName>
  100. <defaultName><xsl:value-of select="*/*[local-name()='defaultName']"/></defaultName>
  101. <xsl:if test="key('recipient-to',$searchPath)">
  102. <type>to</type>
  103. </xsl:if>
  104. <xsl:if test="key('recipient-cc',$searchPath)">
  105. <type>cc</type>
  106. </xsl:if>
  107. <xsl:if test="key('recipient-bcc',$searchPath)">
  108. <type>bcc</type>
  109. </xsl:if>
  110. </item>
  111. </xsl:if>
  112. </xsl:otherwise>
  113. </xsl:choose>
  114. </xsl:for-each>
  115. </xsl:otherwise>
  116. </xsl:choose>
  117. </xsl:template>
  118. <xsl:template match="text()" priority="0"/>
  119. </xsl:stylesheet>