gen-standard-list.xslt 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/" exclude-result-prefixes="xsl xts">
  14. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  15. <xsl:key name="recipient-to" match="/root/*[local-name()='defaultOptions']/*[local-name()='to']/*[local-name()='searchPath']" use="."/>
  16. <xsl:key name="recipient-cc" match="/root/*[local-name()='defaultOptions']/*[local-name()='cc']/*[local-name()='searchPath']" use="."/>
  17. <xsl:key name="recipient-bcc" match="/root/*[local-name()='defaultOptions']/*[local-name()='bcc']/*[local-name()='searchPath']" use="."/>
  18. <xsl:template match="/root" priority="2">
  19. <xsl:choose>
  20. <!-- Special case for attachments
  21. When the report task aren't saved, we get a GUID from Event studio as the searchPath. We can't use those
  22. GUIDS to query cm, so we must loop through the options blob and merge the cm response with the information
  23. passed in to get all the information needed to display the attachments in the UI
  24. -->
  25. <xsl:when test="/root/action = 'attachments'">
  26. <!-- loop through the attachment options -->
  27. <xsl:for-each select="/root/*[local-name()='defaultOptions']/*[local-name()='attachments' or local-name()='eventOutput']/*">
  28. <xsl:variable name="searchPath" select="*[local-name()='searchPath']"/>
  29. <item>
  30. <xsl:variable name="defaultName">
  31. <xsl:choose>
  32. <xsl:when test="starts-with($searchPath, 'AgentTask-')">
  33. <xsl:value-of select="/root/*[local-name()='attachParam']/*[./*[local-name()='searchPath']=$searchPath]/*[local-name()='defaultName']"/>
  34. </xsl:when>
  35. <xsl:otherwise>
  36. <xsl:value-of select="/root/*[local-name()='queryResponse']/*/*[./*[local-name()='searchPath']=$searchPath]/*[local-name()='defaultName']"/>
  37. </xsl:otherwise>
  38. </xsl:choose>
  39. </xsl:variable>
  40. <xsl:choose>
  41. <xsl:when test="local-name()='eventOutput'">
  42. <searchPath>
  43. <xsl:value-of select="$searchPath"/>
  44. </searchPath>
  45. <attachmentName>
  46. <xts:string id="IDS_EMAIL_OPTIONS_EVENT_OUTPUT"/>
  47. </attachmentName>
  48. <defaultName>
  49. <xsl:value-of select="$defaultName"/>
  50. </defaultName>
  51. <format/>
  52. <locale/>
  53. </xsl:when>
  54. <xsl:otherwise>
  55. <searchPath>
  56. <xsl:value-of select="$searchPath"/>
  57. </searchPath>
  58. <attachmentName>
  59. <xsl:choose>
  60. <xsl:when test="string-length($defaultName) > 13">
  61. <xsl:variable name="ellipsis">
  62. <xts:string id="IDS_LIST_ELLIPSIS"/>
  63. </xsl:variable>
  64. <xsl:value-of select="concat(substring($defaultName,1,13),$ellipsis)"/>
  65. </xsl:when>
  66. <xsl:otherwise>
  67. <xsl:value-of select="$defaultName"/>
  68. </xsl:otherwise>
  69. </xsl:choose>
  70. </attachmentName>
  71. <defaultName>
  72. <xsl:value-of select="$defaultName"/>
  73. </defaultName>
  74. <format>
  75. <xsl:value-of select="*[local-name()='format']"/>
  76. </format>
  77. <locale>
  78. <xsl:value-of select="*[local-name()='locale']"/>
  79. </locale>
  80. </xsl:otherwise>
  81. </xsl:choose>
  82. </item>
  83. </xsl:for-each>
  84. </xsl:when>
  85. <xsl:otherwise>
  86. <xsl:for-each select="*[local-name()='queryResponse']/*[local-name()='queryReply']">
  87. <xsl:variable name="searchPath" select="*/*[local-name()='searchPath']"/>
  88. <xsl:variable name="position" select="position()"/>
  89. <xsl:choose>
  90. <!-- build the links list -->
  91. <xsl:when test="/root/action = 'links'">
  92. <item>
  93. <searchPath>
  94. <xsl:value-of select="$searchPath"/>
  95. </searchPath>
  96. <objectClass>
  97. <xsl:value-of select="*/*[local-name()='objectClass']"/>
  98. </objectClass>
  99. <displayName>
  100. <xsl:value-of select="*/*[local-name()='defaultName']"/>
  101. </displayName>
  102. </item>
  103. </xsl:when>
  104. <!-- build the recipients list -->
  105. <xsl:otherwise>
  106. <!-- only add the entry if we got something back from CM -->
  107. <xsl:if test="$searchPath != ''">
  108. <!-- To recipient -->
  109. <xsl:if test="key('recipient-to',$searchPath)">
  110. <xsl:call-template name="buildItem">
  111. <xsl:with-param name="searchPath" select="$searchPath"/>
  112. <xsl:with-param name="query" select="*"/>
  113. <xsl:with-param name="type">
  114. <xsl:text>to</xsl:text>
  115. </xsl:with-param>
  116. </xsl:call-template>
  117. </xsl:if>
  118. <!-- CC recipient -->
  119. <xsl:if test="key('recipient-cc',$searchPath)">
  120. <xsl:call-template name="buildItem">
  121. <xsl:with-param name="searchPath" select="$searchPath"/>
  122. <xsl:with-param name="query" select="*"/>
  123. <xsl:with-param name="type">
  124. <xsl:text>cc</xsl:text>
  125. </xsl:with-param>
  126. </xsl:call-template>
  127. </xsl:if>
  128. <!-- BCC recipient -->
  129. <xsl:if test="key('recipient-bcc',$searchPath)">
  130. <xsl:call-template name="buildItem">
  131. <xsl:with-param name="searchPath" select="$searchPath"/>
  132. <xsl:with-param name="query" select="*"/>
  133. <xsl:with-param name="type">
  134. <xsl:text>bcc</xsl:text>
  135. </xsl:with-param>
  136. </xsl:call-template>
  137. </xsl:if>
  138. </xsl:if>
  139. </xsl:otherwise>
  140. </xsl:choose>
  141. </xsl:for-each>
  142. </xsl:otherwise>
  143. </xsl:choose>
  144. </xsl:template>
  145. <xsl:template name="buildItem">
  146. <xsl:param name="searchPath"/>
  147. <xsl:param name="query"/>
  148. <xsl:param name="type"/>
  149. <item>
  150. <searchPath>
  151. <xsl:value-of select="$searchPath"/>
  152. </searchPath>
  153. <userName>
  154. <xsl:value-of select="$query/*[local-name()='userName']"/>
  155. </userName>
  156. <defaultName>
  157. <xsl:value-of select="$query/*[local-name()='defaultName']"/>
  158. </defaultName>
  159. <objectClass>
  160. <xsl:value-of select="$query/*[local-name()='objectClass']"/>
  161. </objectClass>
  162. <xsl:choose>
  163. <xsl:when test="$query/*[local-name()='objectClass'] = 'account'">
  164. <type>
  165. <xsl:value-of select="$type"/>
  166. </type>
  167. </xsl:when>
  168. <xsl:otherwise>
  169. <type>
  170. <xsl:value-of select="concat($type,'Group')"/>
  171. </type>
  172. </xsl:otherwise>
  173. </xsl:choose>
  174. </item>
  175. </xsl:template>
  176. <xsl:template match="text()" priority="0"/>
  177. </xsl:stylesheet>