manageTaskName.xslt 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: AGS
  5. (C) Copyright IBM Corp. 2005, 2008
  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" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" exclude-result-prefixes="xts xsl xtsext pf">
  9. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  10. <!-- include the serialization code -->
  11. <pf:serialize-xml/>
  12. <pf:variables/>
  13. <xsl:template match="/">
  14. <xsl:variable name="sq">"'</xsl:variable>
  15. <xsl:variable name="prevTabID" select="/root/env/param[@name='prevTabID']"/>
  16. <xsl:variable name="prevTabName">
  17. <xsl:choose>
  18. <xsl:when test="/root/agent_definition/items/item[id=$prevTabID]/type='message' and string-length(/root/env/param[@name='taskName'])=0">
  19. <xsl:text><xts:string id="AGS_EMAIL_WTASK"/></xsl:text>
  20. </xsl:when>
  21. <xsl:otherwise><xsl:value-of select="/root/env/param[@name='taskName']"/></xsl:otherwise>
  22. </xsl:choose>
  23. </xsl:variable>
  24. <xts:sequence>
  25. <!-- if this name exist before, we put a seq. number at the end -->
  26. <xsl:choose>
  27. <!-- don't include yourself in the count - so remove the item which has the same TabID -->
  28. <xsl:when test="count(/root/agent_definition/items/item[not(id = $prevTabID) and name=$prevTabName])>0">
  29. <xsl:variable name="task_name">
  30. <xsl:call-template name="buildTaskName">
  31. <!-- should this be localized - it's going to show up in the UI -->
  32. <xsl:with-param name="prevTabID" select="$prevTabID"/>
  33. <xsl:with-param name="baseName" select="$prevTabName"/>
  34. <xsl:with-param name="suffix" select="'0'"/>
  35. </xsl:call-template>
  36. </xsl:variable>
  37. <xts:replace select="/root/env/param[@name='taskName']">
  38. <param name="taskName"><xsl:value-of select="$task_name"/></param>
  39. </xts:replace>
  40. </xsl:when>
  41. <xsl:otherwise>
  42. <xts:replace select="/root/env/param[@name='taskName']">
  43. <param name="taskName"><xsl:value-of select="$prevTabName"/></param>
  44. </xts:replace>
  45. </xsl:otherwise>
  46. </xsl:choose>
  47. </xts:sequence>
  48. </xsl:template>
  49. <!-- mini template to generate a unique task name -->
  50. <xsl:template name="buildTaskName">
  51. <xsl:param name="prevTabID"/>
  52. <xsl:param name="baseName"/>
  53. <xsl:param name="suffix"/>
  54. <!-- build the task name we want -->
  55. <xsl:variable name="taskName">
  56. <xsl:value-of select="normalize-space($baseName)"/>
  57. <xsl:if test="number($suffix) != 0">
  58. <!-- append the suffix -->
  59. <xsl:value-of select="$suffix"/>
  60. </xsl:if>
  61. </xsl:variable>
  62. <xsl:choose>
  63. <!-- again - have to ignore it's current state from the comparison -->
  64. <xsl:when test="/root/agent_definition/items/item[not(id = $prevTabID) and name=$taskName]">
  65. <xsl:call-template name="buildTaskName">
  66. <xsl:with-param name="prevTabID" select="$prevTabID"/>
  67. <xsl:with-param name="baseName" select="normalize-space($baseName)"/>
  68. <xsl:with-param name="suffix" select="string(number($suffix)+1)"/>
  69. </xsl:call-template>
  70. </xsl:when>
  71. <xsl:otherwise>
  72. <xsl:value-of select="$taskName"/>
  73. </xsl:otherwise>
  74. </xsl:choose>
  75. </xsl:template>
  76. </xsl:stylesheet>