﻿<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns='http://www.w3.org/TR/REC-html40'
  xmlns:TT="ABES_XSL_TOOLS"
  version="1.0"
  >

<xsl:output
  method="html"
  encoding="utf-8"
  version="1.0"
  indent="yes"
  omit-xml-declaration="yes"
 />
<xsl:param name="ETABLISSEMENT" />
<xsl:param name="ROLE" />
<xsl:param name="THESE_ID" />
<xsl:param name="DATE_VALIDATION" />

<xsl:template match="/">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>
   Validation Dépot
   : <xsl:value-of select="$ETABLISSEMENT" />
   : <xsl:value-of select="$ROLE" />
   : <xsl:value-of select="$THESE_ID" />
   : <xsl:value-of select="$DATE_VALIDATION" />
  </title>
  <script language="javascript" >

//
//  Javascript de gestion d'un bouton Afficher/Masquer
//

var ie4 = false;

if ( document.all )
  { ie4 = true;
  }

function
  getObject(id)
{ if (ie4)
    { return document.all[id]; }
   else
    { return document.getElementById(id); }
}

function
  toggle
    ( in_ID
    )
{
  var link=getObject( "link_"+ in_ID );
  var head=getObject( "head_"+ in_ID );
  var lText = link.innerHTML;
  var d = getObject( in_ID );
  //
  //
  if ( "+" == lText.substr( 0, 1 ) )
    { link.innerHTML = '&#8722; de détails';
      head.style.display = 'block';
      //d.style.visiblity= 'visible';//'collapse';
      //head.style.color='#000000';
      //head.style.fontWeight='300';
    }
   else
    { link.innerHTML = '+ de détails';
      head.style.display = 'none';
      //d.style.visiblity='hidden';
      //head.style.color='#ffffff';
      //head.style.fontWeight='900';
    }
}

</script>
  <style>
  li { font-size:10pt; }
  </style>
 </head>
 <body>



  <h4 style="color:orange;">Analyse du traitement</h4>
  <xsl:choose>
   <xsl:when test="0=count(//*[local-name()='failed-assert'])">
    <h5 style="color:green">Aucune erreur détectée</h5>
   </xsl:when>
   <xsl:otherwise>
    <ol>
    <xsl:for-each select="//*[local-name()='failed-assert']">
     <li>
      <xsl:call-template name="failed-assert" />
     </li>
    </xsl:for-each>
    </ol>
   </xsl:otherwise>
  </xsl:choose>
 </body>
</html>
</xsl:template>

<xsl:template name="failed-assert" >

 <xsl:variable name="ID" select="position()" />
 <xsl:variable name="texte" select="./*[local-name()='text']" />
 <p/>
 <ul>
  <li style="color:navy;" >
   <!-- b -->
    <xsl:call-template name="LAST" >
     <xsl:with-param name="in_String" select="$texte" />
     <xsl:with-param name="in_Separator" select="'.'"    />
    </xsl:call-template>
   <!-- /b -->
  </li>
  <li>
   <A
    title="Afficher/Masquer"
    id="link_{$ID}"
    href="javascript:toggle( '{$ID}' );"
    style
      ="font-size=100%
       ;font-weight=500
       ;text-decoration: none
       ;color:green
       ;"
    >+ de détails</A>

   <ul
    ID="head_{$ID}"
    border="1"
    style="display:none;border-collapse:collapse"
    >
    <li>
     <span style="color:red;" >active-pattern : </span><xsl:call-template name="active-pattern" />
    </li>
    <li>
     <span style="color:red;" >règle : </span><xsl:call-template name="fired-rule" />
    </li>
    <li>
     <span style="color:red;" >détails : </span><xsl:value-of select="$texte" />
    </li>
    <li>
     <span style="color:red;" >test : </span><xsl:value-of select="@test" />
    </li>
    <li>
     <span style="color:red;" >localisation : </span>
     <xsl:variable
      name="texte2"
      select="substring-after( substring-after( @location, 'xmlData' ), '/')"
      />
     <xsl:choose>
      <xsl:when test="string-length($texte2)=0" >
       <xsl:value-of select="@location" />
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="$texte2" />
      </xsl:otherwise>
     </xsl:choose>
    </li>
   </ul>
  </li>
 </ul>
</xsl:template>


<xsl:template name="active-pattern" >
 <!-- [local-name()='active-pattern' and last()]/@name -->
 <xsl:value-of
  select="preceding-sibling::node()[local-name()='active-pattern'][1]/@name"
  />
</xsl:template>

<xsl:template name="fired-rule" >
 <!-- [local-name()='active-pattern' and last()]/@name -->
 <xsl:value-of
  select="preceding-sibling::node()[local-name()='fired-rule'][1]/@context"
  />
</xsl:template>

<xsl:template name="LAST" >
 <xsl:param name="in_String" />
 <xsl:param name="in_Separator" />

 <xsl:variable name="part"
   select
     ="normalize-space
         ( substring-after
             ( normalize-space( $in_String )
             , $in_Separator
             )
         )
      "
  />

 <xsl:choose>
  <xsl:when test="0=string-length( $part )" >
   <xsl:value-of select="$in_String" />
  </xsl:when>
  <xsl:otherwise>
   <xsl:call-template name="LAST" >
    <xsl:with-param name="in_String" select="$part" />
    <xsl:with-param name="in_Separator" select="$in_Separator"    />
   </xsl:call-template>
  </xsl:otherwise>
 </xsl:choose>

</xsl:template>

</xsl:stylesheet>