<?xml version="1.0"?>
<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/TR/xhtml1/strict" version="1.0">

<xsl:output method="html" 
  version="1.0" 
  encoding="UTF-8" 
  indent="yes"
  doctype-public="-//W3C//DTD HTML 4.01//EN"
  doctype-system="http://www.w3.org/TR/html4/strict.dtd"/>
<!--  store the intended OUT structure-->
<xsl:variable name="sp"       select="' '"/>
<xsl:variable name="ts"       select="'time'"/>
<xsl:variable name="msgid"    select="'msgid'"/>
<xsl:variable name="e1"       select="'COMServiceReply'"/>
<xsl:variable name="e6"       select="'list'"/>
<xsl:variable name="e7"       select="'ErrText'"/>
<xsl:variable name="e9"       select="'Status'"/>
<xsl:variable name="e13"      select="'scwb_id'"/>
<xsl:variable name="e14"      select="'snhz_id'"/>
<!--
com.sanchez.services.appflow.ScProcCreateCustomers
-->
<!-- save 3rd PI  from input NODE-->

<xsl:template match="/">

    <html>

      <!--
        This is the page header, we want a title from this document title
        the <meta> copyright statement and all authors in "meta" headers.
      -->
      <head>
        <title>Sanchez Response Message List
        </title>
        <!--<link rel="stylesheet" type="text/css" href="style.css"/>
        <link rel="shortcut icon" href="images/tomcat.ico"/> -->
      </head>

      <!--
        This describes the layout of the page
      -->
      <body bgcolor="#ffffff" text="#000000" alink="#666666" vlink="#333333" link="#666666">
        <a name="TOP"/>
        <h3>Message Exchange List</h3>
<TABLE  BORDER="1" BGCOLOR="#FFFFAE" CELLSPACING="1" CELLPADDING="1" WIDTH="100%">
   <TR><TH cellhalign="left">Logstream Timestamp </TH> 
     <TH cellhalign="LEFT">Message Id </TH>
   <TH cellhalign="LEFT">Customer Id </TH>
   <TH cellhalign="LEFT">External Id </TH>
   </TR>
    <xsl:for-each select="list/COMServiceReply">

    <TR>
    <TD>
               <A HREF="XMLTrnsDetl?log_timestamp={@logts}">
    <xsl:value-of select="(concat((substring(@logts,1,10)), &apos; &apos;, (substring(@logts,12,12))))"/>
                   </A>       
    </TD>
    <TD>

          <xsl:value-of select="@msgid"/>

    </TD>

    <TD>
          <xsl:value-of select="(substring(@msgid,1,9))"/>
    </TD>
        <xsl:apply-templates /> 
    </TR>
    </xsl:for-each>
</TABLE>
      </body>
    </html>
</xsl:template>


<!-- context=" list/COMServiceReply " -->
<!-- select the parentOf "Status" node -->
<xsl:template match="ReplyValue/Hashtable/item[position()=last()]/value/ReplyValue/ResultSet">
 <!-- <xsl:element name = "{$e9}" >
    <xsl:value-of select="."/>
 </xsl:element> -->
   <xsl:apply-templates /> 
</xsl:template>

<!-- context=" list/COMServiceReply " -->
<!-- select the parentOf "Status" node -->
<xsl:template match="ReplyValue/ResultSet">
<!--   <xsl:element name = "{$e9}" >  
    <xsl:value-of select="."/>
</xsl:element> -->
  <xsl:apply-templates />
</xsl:template>

<!-- Context : COMServiceReply/ReplyValue/ResultSet> OR: -->
<!-- Context : COMServiceReply/ReplyValue/Hashtable/item[]/value/ReplyValue/ResultSet-->
<xsl:template match="Status">
 
  <xsl:if test="string(.)='-6'">
    <td><FONT COLOR="#ff0000">
        <xsl:value-of select="."/>
    </FONT></td>
  </xsl:if>  
</xsl:template>

<!-- bypass text otherwise defaulted to "out"-->
<xsl:template match="text()|@*"/>

<!-- context=" COMServiceReply/ReplyValue/Hashtable/item[]/value/ReplyValue -->
<!-- beats me how you got this context in the recursion. It works...-->
<xsl:template match="ResultSet/Row/Column[position()=1]">
  <td>
    <xsl:value-of select="."/>
  </td>
  </xsl:template>
</xsl:stylesheet>

