calculate_history_duration.xslt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cogadmin
  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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  9. xmlns:cogadminext="xalan://com.cognos.admin.xts.ext.XTSExt"
  10. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  11. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  12. <xsl:template match="*">
  13. <xsl:copy>
  14. <xsl:copy-of select="@*"/>
  15. <xsl:apply-templates/>
  16. </xsl:copy>
  17. </xsl:template>
  18. <xsl:template match="/activityHistory/schedule">
  19. <xsl:for-each select="./path">
  20. <xsl:variable name="currentPath" select="."/>
  21. <xsl:variable name="contentLocale" select="/activityHistory/contentLocale"/>
  22. <xsl:variable name="histories" select="/activityHistory/cm:queryResponse/cm:queryReply/cm:history[cm:parent/*/cm:searchPath = $currentPath]"/>
  23. <xsl:variable name="calculatedDuration" >
  24. <xsl:if test="count($histories) > 0">
  25. <xsl:variable name="startDate" select="$histories[1]/cm:actualExecutionTime"/>
  26. <xsl:variable name="endDate" select="$histories[1]/cm:actualCompletionTime"/>
  27. <!--
  28. Format the date difference;
  29. The number 2 represents the style and corresponds to a long format (see the XTSExt.java class for more details)
  30. -->
  31. <xsl:value-of select="cogadminext:formatDateDifference($startDate,$endDate,$contentLocale,number('2'))"/>
  32. </xsl:if>
  33. </xsl:variable>
  34. <schedule>
  35. <path><xsl:value-of select="$currentPath"/></path>
  36. <xsl:choose>
  37. <xsl:when test="$calculatedDuration != ''">
  38. <lastExecutionTime><xsl:value-of select="$calculatedDuration"/></lastExecutionTime>
  39. </xsl:when>
  40. <xsl:otherwise>
  41. <lastExecutionTime><xsl:value-of select="/activityHistory/noHistoryForLastExcutionTime"/></lastExecutionTime>
  42. </xsl:otherwise>
  43. </xsl:choose>
  44. </schedule>
  45. </xsl:for-each>
  46. </xsl:template>
  47. </xsl:stylesheet>