<?xml version="1.0" encoding="utf-8" ?> 
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:param name="cutofftime">30</xsl:param>

  <xsl:output method="html"/>

  <!-- ******************************************************************* -->
  <xsl:template match='/'>
    <head>
      <title>JSPM Analysis</title>
<STYLE>
.head { font-family:Arial;  font-size:14pt; font-weight:bold; }
.foot { font-family:Arial;  font-size:10pt; }
a:link { color:#000099; text-decoration:none;  }
a:visited { color:#000099; text-decoration:none;  }

body { margin-left:20px;  margin-right:20px;  margin-top:20px;  margin-bottom:20px; background-color:#ffffff;}
table.main {background-color:#999999;}
td.hhd { font-size:12pt; font-weight:bold; font-weight:bold; background-color:#dddddd; }
td.hhc { font-size:10pt; font-weight:bold; font-weight:bold; background-color:#dddddd; }
td.hhr { font-size:10pt; font-weight:bold; background-color:#dddddd; min-width:100pt;}

td.hac { font-size:10pt; background-color:#ddddee; }
td.hab { font-size:10pt; background-color:#ddddee; font-weight:bold;}
td.ha { font-size:10pt; background-color:#ddddee; min-width:100pt;}

td.hbc { font-size:10pt; background-color:#ddeedd; }
td.hbb { font-size:10pt; background-color:#ddeedd; font-weight:bold;}
td.hb { font-size:10pt; background-color:#ddeedd; min-width:100pt;}

td.hcb  { font-size:10pt; font-weight:bold; background-color:#f7f7d0; min-width:100pt;}
td.hc  { font-size:10pt; background-color:#f7f7d0; min-width:100pt;}
td.e   { font-size:10pt; min-width:100pt;}
td.le   { font-size:10pt; min-width:200pt;}

td.hdb  { font-size:10pt; font-weight:bold; background-color:#eedddd; min-width:100pt;}
td.hhh { font-size:14pt; font-weight:bold; background-color:#cccccc;}
td.fff { font-size:8pt; font-weight:bold; background-color:#cccccc;}

td.phm { font-size:12pt; font-weight:bold; background-color:#cccccc;}

td.php { font-size:10pt; font-weight:bold; background-color:#dddddd;}
td.ph  { font-size:10pt; font-weight:bold; background-color:#dddddd;}
td.phr { font-size:10pt; font-weight:bold; background-color:#dddddd;}

td.pap { font-size:10pt; font-weight:bold; background-color:#eeeeff;}
td.pa  { font-size:10pt; background-color:#eeeeff; min-width:100pt;}
td.par { font-size:10pt; background-color:#eeeeff; min-width:200pt;}
td.pab { background-color:#eeeeff; font-weight: bold;}

td.pbp { font-size:10pt; font-weight:bold; background-color:#eeffee;}
td.pb  { font-size:10pt; background-color:#eeffee; min-width:100pt;}
td.pbr { font-size:10pt; background-color:#eeffee; min-width:200pt;}
td.pbl { background-color:#eeffee; min-width:200pt;}

td.ebbx { font-family:Courier; font-size:10pt; font-weight:bold; background-color:#ffeeee; max-width:100pt;}
td.ebb { font-size:10pt; font-weight:bold; background-color:#ffeeee; max-width:100pt;}
td.ebb { font-size:10pt; font-weight:bold; background-color:#ffeeee; max-width:100pt;}
td.ebt { font-size:10pt; background-color:#ffeeee; font-weight: normal; }

td.eh { font-size:12pt; font-weight:bold; background-color:#cccccc;}

td.ep { font-size:10pt; font-weight:bold; background-color:#ffdddd;}
td.et { font-size:10pt; font-weight:bold; background-color:#ffffff;}

td.tbl_cell	{	background-color:white;}
td.tbl_bold_cell {	background-color:white;	font-weight: bold;}
td.tbl_cell_brown {	background-color:white;	font-weight: normal; color: brown;}
td.tbl_cell_error	{	background-color:white;	font-weight: normal; font-family:"Lucida Sans Typewriter"}

.etag { font-family:monospace; font-size:larger; border:1px solid; }
.allbutton { border:1px solid; }

</STYLE>
<script type="text/javascript">//<![CDATA[
//  Toggle single element
function toggle(element)
{
  var item = element.firstChild;
  setElement(element, (item.data == "+") ? "-" : "+", 1);
}

function toggleall(element, type)
{
  if(element.tagName == "SPAN") {
    var clattr = element.attributes["class"];
    if(clattr && clattr.nodeValue == "etag")
      setElement(element, type, 0);
  }

  var sub;
  for(sub = element.firstChild ; sub ; sub = sub.nextSibling)
    toggleall(sub, type);
}

//  'element' should point to the "SPAN" node with class "etag"
function setElement(element, type, dosub)
{
  var sub = element.firstChild;
  if(!sub) return;

  if(!type) type = sub.data;

  var newdisp = (type == "+") ? "none" : "";
  sub.data = type;

  //  Go to "tr" element and change display of all following "tr" until
  //   element with same class is found (== next header)
  element = element.parentNode; //  go to "TD" element
  var myclass = element.attributes["class"];
  if(!myclass) return;

  myclass = myclass.nodeValue;
  element = element.parentNode; //  go to "TR" element

  var next;
  for(next = element.nextSibling ; next ; next = next.nextSibling) {
    sub = next.firstChild;
    if(!sub) continue; //  skip text nodes

    for( ; sub ; sub = sub.nextSibling) {
      if(sub.tagName == "TD")
        break;
    }

    if(!sub || sub.attributes["class"].nodeValue == myclass)
      break;

    next.style.display = newdisp;
  }

  //  Fix all subelements on reopen
  if(dosub != 0 && newdisp == "") {
    for(next = element.nextSibling ; next ; next = next.nextSibling)
      toggleall(next, "");
  }
}
//]]></script>
    </head>

    <body>
      <table border="0" cellpadding="1" rules="none" width="98%">
        <tr> <td colspan="4" class="hhh"><xsl:value-of select="troubleticket/analysis/title"/></td> </tr>

        <xsl:call-template name="show-title" />
        <xsl:call-template name="show-system"/>
        <xsl:call-template name="show-jspm"/>
        <xsl:call-template name="show-upgtimes"/>
        <!-- Source Release Tools -->
        <!-- Destination Release Tools -->
      </table>

      <a name="components"/>
      <table border="0" cellpadding="1" rules="none" width="98%">
      <tr> <td colspan="5" class="phm"><xsl:call-template name="expandplus"/><xsl:call-template name="NBSPC"/>Component Versions</td></tr>
        <xsl:call-template name="show-main-components"/>
      </table>

      <a name="steplistpre_start"/>
      <table rules="none" border="0" cellpadding="1" cellspacing="1" width="98%">
        <tr>
          <td colspan="5" class="phm"><xsl:call-template name="expandplus"/><xsl:call-template name="NBSPC"/>Start (displays only items with runtime higher than <xsl:value-of select="$cutofftime"/>s or with dialogs) or with aborted steps</td>
        </tr>
        <xsl:call-template name="show-steps">
          <xsl:with-param name="group" select="'Start'"/>
          <xsl:with-param name="cutofftime2" select="$cutofftime"/>
        </xsl:call-template>
      </table>

      <a name="steplistpre_process"/>
      <table rules="none" border="0" cellpadding="1" cellspacing="1" width="98%">
        <tr>
          <td colspan="5" class="phm"><xsl:call-template name="expandplus"/><xsl:call-template name="NBSPC"/>Process (displays only items with runtime higher than <xsl:value-of select="$cutofftime"/>s) or with aborted steps</td>
        </tr>
        <xsl:call-template name="show-steps">
          <xsl:with-param name="group" select="'Process'"/>
          <xsl:with-param name="cutofftime2" select="$cutofftime"/>
        </xsl:call-template>
      </table>

      <a name="deployments"/>
      <table rules="none" border="0" cellpadding="1" cellspacing="1" width="98%">
        <tr>
          <td colspan="5" class="phm"><xsl:call-template name="expandplus"/><xsl:call-template name="NBSPC"/>Deployments (displays only items with runtime higher than <xsl:value-of select="$cutofftime"/>s) or with aborted components</td>
        </tr>
        <xsl:call-template name="show-deployments">
          <xsl:with-param name="cutofftime2" select="$cutofftime"/>
        </xsl:call-template>
      </table>

      <a name="restarts"/>
      <table rules="none" border="0" cellpadding="1" cellspacing="1" width="98%">
        <tr>
          <td colspan="5" class="phm"><xsl:call-template name="expandplus"/><xsl:call-template name="NBSPC"/>System Restarts (displays only items with runtime higher than <xsl:value-of select="$cutofftime"/>s)</td>
        </tr>
        <xsl:call-template name="show-restarts">
          <xsl:with-param name="cutofftime2" select="$cutofftime"/>
        </xsl:call-template>
      </table>
      
      <a name="log-analysis"/>
      <table rules="none" border="0" cellpadding="1" cellspacing="1" width="98%">
		    <tr>
		      <td colspan="3" class="phm">JSPM Log Analysis</td>
		    </tr> 
		    <tr>       
        	<xsl:call-template name="show-log-analysis"/>
        </tr> 
      </table>
     
      <a name="jspm-logs"/>
      <table rules="none" border="0" cellpadding="1" cellspacing="1" width="98%">
		    <tr>
		      <td class="phm">JSPM Logs Archive Location</td>
		    </tr> 
		    <tr>       
        	<xsl:call-template name="show-logs-archive"/>
        </tr> 
      </table> 
      
      <a name="csn-info"/>
      <table rules="none" border="0" cellpadding="1" cellspacing="1" width="98%">
		    <tr>
		      <td class="phm">CSN needed information</td>
		    </tr> 
		    <tr>       
        	<xsl:call-template name="show-csn-info"/>
        </tr> 
      </table>       
      
      
    </body>
  </xsl:template>

  <!-- ******************************************************************* -->
  <xsl:template name="show-title">
    <xsl:variable name="section" select="troubleticket/analysis/configuration[@group='System']" />
    <tr>
      <td class="hab">
        <span class="allbutton" onclick="toggleall(document, '-')"><xsl:call-template name="NBSPC"/>Open All</span>
        <xsl:call-template name="NBSPC"/>
        <xsl:call-template name="NBSPC"/>
        <span class="allbutton" onclick="toggleall(document, '+')">Close All</span>
      </td>
      <td class="hab"><a href="#configuration">&gt;&gt;Configuration</a></td>
      <td class="hab"><a href="#components">&gt;&gt;Components</a></td>
      <td class="hab"><a href="#steplistpre_start">&gt;&gt;Start Steps</a></td>
    </tr>
    
    <tr> <td colspan="4" class="e"></td> </tr>
    
    <tr>
      <td class="hab"><a href="#steplistpre_process">&gt;&gt;Process Steps</a></td>
      <td class="hab"><a href="#deployments">&gt;&gt;Deployments</a></td>
      <td class="hab"><a href="#restarts">&gt;&gt;Restarts</a></td>
      <td class="hab"></td>
    </tr>
    
    <tr> <td colspan="4" class="e"></td> </tr>
  </xsl:template>

  <!-- ******************************************************************* -->
  <xsl:template name="show-system" >
    <xsl:variable name="section" select="troubleticket/analysis/configuration[@group='System']" />
    <xsl:variable name="nProdClients">
      <xsl:choose>
        <xsl:when test="number($section/property[@name='NrProdClients']) = 0">?</xsl:when>
        <xsl:otherwise><xsl:value-of select="$section/property[@name='NrProdClients']"/></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <tr>
      <td colspan="4" class="hhd"><xsl:call-template name="mkjstag"/><xsl:call-template name="NBSPC"/>System</td>
    </tr>

    <tr>
      <td class="hcb">SID</td>
      <td class="hc"><xsl:value-of select="troubleticket/analysis/@SID" /></td>
      <td class="hcb">OS</td>
      <td class="hc"><xsl:value-of select="$section/property[@name='OSTribe']" /></td>
    </tr>
    <tr>
      <td class="hcb">DB System</td>
      <td class="hc"><xsl:value-of select="$section/property[@name='DBType']" /></td>
      <td class="hcb">OS Version</td>
      <td class="hc"><xsl:value-of select="$section/property[@name='OSVersion']" /></td>
    </tr>
    <tr>
      <td class="hcb">DB Version</td>
      <td class="hc"><xsl:value-of select="$section/property[@name='DBVersion']" /></td>
      <td class="hcb">Host</td>
      <td class="hc"><xsl:value-of select="$section/property[@name='SAPHost']" /></td>
    </tr>
    <tr>
      <td colspan="4" class="e"></td>
    </tr>
  </xsl:template>
  
  <!-- ******************************************************************* -->
  <xsl:template name="show-jspm" >
    <xsl:variable name="section" select="troubleticket/analysis/configuration[@group='JspmConfig']" />

    <tr>
      <td colspan="4" class="hhd"><xsl:call-template name="mkjstag"/><xsl:call-template name="NBSPC"/>JSPM Params</td>
    </tr>

    <tr>
      <td class="hcb">J2EE engine deployment mode</td>
      <td class="hc"><xsl:value-of select="$section/property[@name='DeploymentMode']" /></td>      
      <td class="hcb">Patches included in stack</td>
      <td class="hc"><xsl:value-of select="$section/property[@name='PatchesInStack']" /></td>
    </tr>

  </xsl:template> 

  <!-- ******************************************************************* -->
  <xsl:template name="show-upgtimes" >
    <xsl:variable name="section" select="troubleticket/analysis/configuration[@group='Times']" />
    <tr> <td colspan="4" class="hhd"><xsl:call-template name="mkjstag"/><xsl:call-template name="NBSPC"/>Patch Times</td> </tr>

    <tr>
      <td class="hcb">Start Date</td>
      <td class="hc">
        <xsl:call-template name="format-date">
          <xsl:with-param name="D" select="troubleticket/analysis/@startdate" />
        </xsl:call-template>
      </td>
      <td class="hcb">End Date</td>
      <td class="hc">
        <xsl:call-template name="format-date">
          <xsl:with-param name="D" select="troubleticket/analysis/@enddate" />
        </xsl:call-template>
      </td>
    </tr>
    <tr>
      <td class="hcb">Downtime</td>
      <td class="hc">
        <xsl:call-template name="seconds-to-time">
          <xsl:with-param name="seconds" select="$section/property[@name='MinDownTime']" />
        </xsl:call-template>
      </td>
      <td class="hcb">JSPM Runtime</td>
      <td class="hc">
        <xsl:call-template name="seconds-to-time">
          <xsl:with-param name="seconds" select="$section/property[@name='RunTime']" />
        </xsl:call-template>
      </td>
    </tr>
    <tr>
      <td colspan="4" class="e"></td>
    </tr>
  </xsl:template>

  <!-- ******************************************************************* -->

  <xsl:template name="show-main-components" >
    <xsl:variable name="Source" select="troubleticket/analysis/configuration[@group='Versions']/configuration[@group='Components']/configuration[@group='Source']" />
    <xsl:variable name="Destin" select="troubleticket/analysis/configuration[@group='Versions']/configuration[@group='Components']/configuration[@group='Destination']" />

    <tr style="display: none">
      <td class="hhc">Main Component</td>
      <td class="hhr" colspan="2" width="30%">Source</td>
      <td class="hhr" colspan="2" width="30%">Destination</td>
    </tr>
    <tr style="display: none">
      <td class="hhc"></td>
      <td class="hhr">Release</td>
      <td class="hhr">SP, Patch</td>
      <td class="hhr">Release</td>
      <td class="hhr">SP, Patch</td>
    </tr>

    <xsl:for-each select="$Source/version">
      <xsl:if test="$Destin/version[@name=current()/@name]/@name = ''">
        <xsl:call-template name="show-one-comp">
          <xsl:with-param name="srccomp" select="$Source/version[@name=current()/@name]" />
          <xsl:with-param name="dstcomp" select="$Destin/version[@name=current()/@name]" />
        </xsl:call-template>
      </xsl:if>
    </xsl:for-each>

    <xsl:for-each select="$Destin/version">
      <xsl:call-template name="show-one-comp">
        <xsl:with-param name="srccomp" select="$Source/version[@name=current()/@name]" />
        <xsl:with-param name="dstcomp" select="$Destin/version[@name=current()/@name]" />
      </xsl:call-template>
    </xsl:for-each>
  </xsl:template>

  <!-- ******************************************************************* -->
  <xsl:template name="show-one-comp">
    <xsl:param name="srccomp"/>
    <xsl:param name="dstcomp"/>

    <xsl:if test="$srccomp/@type = 'SC' or $dstcomp/@type = 'SC'">
      <tr style="display: none">
        <td class="hhc">
          <xsl:choose>
            <xsl:when test="$srccomp/@name != ''">
              <xsl:value-of select="$srccomp/@name"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$dstcomp/@name"/>
            </xsl:otherwise>
          </xsl:choose>
        </td>
        <td class="ha"><xsl:value-of select="$srccomp/@release"/></td>
        <td class="ha">
          <xsl:call-template name="format-PL"><xsl:with-param name="PL" select="$srccomp/text()" /></xsl:call-template>
        </td>
        <td class="hb"><xsl:value-of select="$dstcomp/@release"/></td>
        <td class="hb">
          <xsl:call-template name="format-PL"><xsl:with-param name="PL" select="$dstcomp/text()" /></xsl:call-template>
        </td>
      </tr>
    </xsl:if>
  </xsl:template>

  <!-- ******************************************************************* -->
  <xsl:template name="show-steps">
    <xsl:param name="group"/>
    <xsl:param name="cutofftime2"/>
    <xsl:variable name="section" select="troubleticket/analysis/steps[@group=$group]" />
    <tr style="display: none">
      <td class="php">Step</td>
      <td class="ph" width="10%">Runtime</td>
      <td class="ph" width="10%">Runs</td>
      <td class="ph" width="10%">Aborts</td>
    </tr>
    <xsl:for-each select="$section">
      <xsl:for-each select="./step">
        <xsl:if test="number(@time) >= $cutofftime2 or @failed > 0">
          <tr style="display: none">
            <xsl:variable name="class_prefix">
              <xsl:if test="position () mod 2 = 0">pa</xsl:if>
              <xsl:if test="position () mod 2 = 1">pb</xsl:if>
            </xsl:variable>

            <xsl:variable name="phase_name">
              <xsl:call-template name="format-phasename"><xsl:with-param name="name" select="@name" /></xsl:call-template>
            </xsl:variable>

            <td class="{concat($class_prefix, 'p')}">
              <xsl:choose>
                <xsl:when test="@dialogs = 'yes'">
                  <a href="#phase_{$phase_name}">
                    <xsl:value-of select="$phase_name"/>
                  </a>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="$phase_name"/>
                </xsl:otherwise>
              </xsl:choose>
            </td>
            <td class="{$class_prefix}">
              <xsl:call-template name="seconds-to-time"><xsl:with-param name="seconds" select="@time" /></xsl:call-template>
              <xsl:if test="@dialogs = 'yes'">+ dialogs</xsl:if>
            </td>
            <td class="{$class_prefix}"><xsl:value-of select="@runs" /></td>
            <td class="{$class_prefix}"><xsl:value-of select="@failed" /></td>
          </tr>
        </xsl:if>
      </xsl:for-each>
    </xsl:for-each>
  </xsl:template>

  <!-- ******************************************************************* -->
  <xsl:template name="show-deployments">
    <xsl:param name="cutofftime2"/>
    <xsl:variable name="section" select="troubleticket/analysis/executions[@type='DEPLOYMENTS']/execution" />
    <tr style="display: none">
      <td class="php">Component</td>
      <td class="ph" width="10%">Runtime</td>
      <td class="ph" width="10%">Runs per DC</td>
      <td class="ph" width="10%">Aborts</td>
    </tr>
    <xsl:for-each select="$section">
      <xsl:if test="number(@time) >= $cutofftime2 or @aborts > 0">
        <tr style="display: none">
          <xsl:variable name="class_prefix">
            <xsl:if test="position () mod 2 = 0">pa</xsl:if>
            <xsl:if test="position () mod 2 = 1">pb</xsl:if>
          </xsl:variable>

          <xsl:variable name="exec_name">
            <xsl:choose>
              <xsl:when test="@name != ''">
                <xsl:value-of select="@name"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="@component"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>

          <td class="{concat($class_prefix, 'p')}">
            <xsl:value-of select="$exec_name"/>
          </td>
          <td class="{$class_prefix}">
            <xsl:call-template name="seconds-to-time"><xsl:with-param name="seconds" select="@time" /></xsl:call-template>
          </td>
          <td class="{$class_prefix}"><xsl:value-of select="@runs" /></td>
          <td class="{$class_prefix}"><xsl:value-of select="@aborts" /></td>
        </tr>
      </xsl:if>
    </xsl:for-each>
  </xsl:template>

  <!-- ******************************************************************* -->
  <xsl:template name="show-restarts">
    <xsl:param name="cutofftime2"/>
    <xsl:variable name="section" select="troubleticket/analysis/executions[@type='RESTARTS']/execution" />
    <tr style="display: none">
      <td class="php">System starts/shutdowns/restarts</td>
      <td class="ph" width="10%">Runtime</td>
      <td class="ph" width="10%">Runs</td>
      <td class="ph" width="10%"></td>
    </tr>
    <xsl:for-each select="$section">
      <xsl:if test="number(@time) >= $cutofftime2">
        <tr style="display: none">
          <xsl:variable name="class_prefix">
            <xsl:if test="position () mod 2 = 0">pa</xsl:if>
            <xsl:if test="position () mod 2 = 1">pb</xsl:if>
          </xsl:variable>

          <xsl:variable name="exec_type">
            <xsl:choose>
              <xsl:when test="@type = 'start'">System start</xsl:when>
              <xsl:when test="@type = 'stop'">System shutdown</xsl:when>
              <xsl:when test="@type = 'restart'">System restart</xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="@type"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>

          <xsl:variable name="exec_causedBy"><xsl:value-of select="@initiatedBy"/></xsl:variable>

          <td class="{concat($class_prefix, 'p')}">
            <xsl:value-of select="$exec_type"/><xsl:call-template name="NBSPC"/>has been initiated by<xsl:call-template name="NBSPC"/><xsl:value-of select="$exec_causedBy"/>
          </td>
          <td class="{$class_prefix}">
            <xsl:call-template name="seconds-to-time"><xsl:with-param name="seconds" select="@time" /></xsl:call-template>
          </td>
          <td class="{$class_prefix}"><xsl:value-of select="@runs" /></td>
          <td class="e"></td>
        </tr>
      </xsl:if>
    </xsl:for-each>
  </xsl:template>
  
  <!-- ******************************************************************* -->
  <xsl:template name="show-log-analysis">
	<xsl:if test="(string-length(troubleticket/errorsolution/info) &gt; 20) or (string-length(troubleticket/errorsolution/error) &gt; 20) or (string-length(troubleticket/errorsolution/warning) &gt; 20)">	
			<table rules="none" border="0" cellpadding="1" cellspacing="1" width="98%" class="main">
				<xsl:if test="string-length(troubleticket/errorsolution/info) &gt; 20">
					<tr style="background-color: #42A0FF">
						<td><b>Information</b></td>
					</tr>
					<xsl:value-of select="troubleticket/errorsolution/info" disable-output-escaping="yes"/>
				</xsl:if>
				<xsl:if test="string-length(troubleticket/errorsolution/error) &gt; 20">
					<tr style="background-color: #FF0033">
						<td><b>Errors</b></td>
					</tr>
					<xsl:value-of select="troubleticket/errorsolution/error" disable-output-escaping="yes"/>
				</xsl:if>
				<xsl:if test="string-length(errorsolution/warning) &gt; 20">
					<tr style="background-color: #FFD042">
						<td><b>Warnings</b></td>
					</tr>
					<xsl:value-of select="troubleticket/errorsolution/warning" disable-output-escaping="yes"/>
				</xsl:if>
				<tr style="background-color: #FE9481">
					<td><b>Disclaimer</b></td>
				</tr>
				<tr>		
					<td class="tbl_cell"><![CDATA[Please consider the information included in this report as a machine generated analisys. 
						Therefore we would like to warn you - explanations and solutions proposed might not be exactly accurate/applicable to the current situation.]]></td>
				</tr>
			</table>
	</xsl:if>
  </xsl:template>
  
  <!-- ******************************************************************* -->
  <xsl:template name="show-logs-archive">
	<xsl:if test="(string-length(troubleticket/errorsolution/jspmlogs) &gt; 4)">	
			<tr>
				<td class="pbl"><xsl:value-of select="troubleticket/errorsolution/jspmlogs" disable-output-escaping="yes"/></td>
			</tr>						
	</xsl:if>
  </xsl:template>
  
  <!-- ******************************************************************* -->
  <xsl:template name="show-csn-info">
	  <xsl:variable name="section" select="troubleticket/analysis/configuration[@group='System']" />
  		<tr>
			<td class="pbl">If the suggested troubleshooting information did not help please create OSS Message in <b>BC-UPG-OCS-SPJ</b> component with the following format:</td>
		</tr>
		<tr>
			<td class="pab">			
					<br/>Type of updated AS Java system (<i>Composition Environment, ERP ...</i>):                                             
					<br/>Operating System Type and version: <xsl:value-of select="$section/property[@name='OSTribe']" /> with version <xsl:value-of select="$section/property[@name='OSVersion']" />                           
					<br/>Database type and version: <xsl:value-of select="$section/property[@name='DBType']" /> with version  <xsl:value-of select="$section/property[@name='DBVersion']" />         
					<br/>Source Support Package:   
					<br/>Target Support Package:    
					<br/>
					<br/>
					<br/>Please describe what procedure have used, what you have done before and after the error occured.
					<br/>
					<br/>
					<xsl:choose>
						<xsl:when test="(string-length(troubleticket/errorsolution/jspmlogs) &gt; 4)">
							Also attach to the message log and trace archive: <xsl:value-of select="troubleticket/errorsolution/jspmlogs" disable-output-escaping="yes"/>
						</xsl:when>
						<xsl:otherwise><![CDATA[
							Also attach to the message latest log and trace folders:
							"/usr/sap/<SID>/<instance#>/j2ee/JSPM/log/<time_stamp>" and  "/usr/sap/<SID>/<instance#>/j2ee/JSPM/trc"]]>
						</xsl:otherwise>
					</xsl:choose>
				</td>
			</tr>
  		<tr>
				<td class="pbl">
					To speed up the support process, consider opening a connection on an OS level.
					<br/>For more information about OSS message format please check <a href="http://service.sap.com/~form/handler?_APP=01100107900000000342&amp;_EVENT=DISPL_TXT&amp;_NNUM=1023155">SAP Note 1023155</a>.
				</td>
			</tr>						
  </xsl:template>  

  <!-- ******************************************************************* -->
  <!-- ************************ helper templates ************************* -->
  <!-- ******************************************************************* -->
  <xsl:template name="format-date">
    <xsl:param name="D"/>
    <!-- quick and dirty formatting
         20050405115050 = 2005/04/05 11:50:50
    -->
    <xsl:value-of select="concat (substring($D, 1, 4), '/', substring($D, 5, 2), '/', substring($D, 7, 2), ' ', substring($D, 9, 2), ':', substring($D, 11, 2), ':', substring($D, 13, 2))" />
  </xsl:template>

  <!-- ******************************************************************* -->
  <xsl:template name="seconds-to-time">
    <xsl:param name="seconds"/>
    <xsl:choose>
      <xsl:when test="'$seconds' = ''">
        <xsl:value-of select="'-'" />
      </xsl:when>
      <xsl:otherwise>
        <!-- (jo) Sequence matters!  -->
        <xsl:variable name="minu">
          <xsl:value-of select="floor(number($seconds) div 60)" />
        </xsl:variable>
        <xsl:variable name="second">
          <xsl:value-of select="format-number(floor(number($seconds) - 60 * $minu), '00')" />
        </xsl:variable>
        <xsl:variable name="hours">
          <xsl:value-of select="floor($minu div 60)" />
        </xsl:variable>
        <xsl:variable name="minutes">
          <xsl:value-of select="format-number(floor($minu - 60 * $hours), '00')" />
        </xsl:variable>
        <xsl:value-of select="concat ($hours, ':', $minutes, ':', $second)" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!-- ******************************************************************* -->
  <xsl:template name="format-PL">
    <xsl:param name="PL"/>
    <!--
       "0" = 0000
       "0000000000" = 0000
       "" = -
    -->
    <xsl:choose>
      <xsl:when test="$PL=''"><xsl:value-of select="'-'" /></xsl:when>
      <xsl:when test="number($PL)=0"><xsl:value-of select="'0000'" /></xsl:when>
      <xsl:otherwise><xsl:value-of select="$PL" /></xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!-- ******************************************************************* -->
  <!-- (jo)  -->
  <xsl:template name="format-phasename">
    <xsl:param name="name"/>

    <xsl:variable name="name2">
      <xsl:choose>
        <xsl:when test="substring($name, 1, 6) = 'Phase.'"> <xsl:value-of select="substring($name, 7)"/> </xsl:when>
        <xsl:otherwise> <xsl:value-of select="$name"/> </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:variable name="name3">
      <xsl:choose>
        <xsl:when test="substring($name2, 1, 8) = 'Prepare/'"> <xsl:value-of select="substring($name2, 9)"/> </xsl:when>
        <xsl:when test="substring($name2, 1, 8) = 'Upgrade/'"> <xsl:value-of select="substring($name2, 9)"/> </xsl:when>
        <xsl:otherwise> <xsl:value-of select="$name2"/> </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:value-of select="$name3" />
  </xsl:template>
  
  <!-- ******************************************************************* -->
  <xsl:template name="NBSPC">
    <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
  </xsl:template>
  
  <!-- ******************************************************************* -->
  <xsl:template name="mkjstag">
    <span class="etag" onclick="toggle(this)">-</span>
  </xsl:template>
  
  <!-- ******************************************************************* -->
  <xsl:template name="expandplus">
    <span class="etag" onclick="toggle(this)">+</span>
  </xsl:template>
</xsl:stylesheet>
