<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:n="http://projets.admisource.gouv.fr/xemelios/namespaces#edmn"
    version="2.0" 
    exclude-result-prefixes="xsl n">
    
    <xsl:output method="xhtml" encoding="ISO-8859-15" indent="yes" include-content-type="yes"/>
    <xsl:decimal-format name="decformat" decimal-separator="," grouping-separator=" " digit="#" pattern-separator=";" NaN="NaN" minus-sign="-"/>
    
    <!-- Paramètres Web -->
    <xsl:param name="is.web">-1</xsl:param>
    <xsl:param name="context.path"/>
    
    <!-- Paramètres d'erreur -->
    <xsl:param name="error.message">nomessage</xsl:param>
        
    <xsl:template match="/n:Edmn/n:EtatEdmn/n:LigneEdmn">
        <html>
            <head>
                <title>Xemelios - Mandat national</title>
                <style type="text/css">
                    body {
                        font-family: Arial, Helvetica, sans-serif;
                        font-size: 14px;
                    }
                    span.lib {
                        font-weight: bold;
                        margin-right: 7px;
                    }
                    span.val {
                        font-style: italic;
                    }
                    div.emetteur {
                        top: 30px;
                        left: 0px;
                    }
                    div.chorus { border: #000000 dotted 1px; width: 80%;}
                    table.chorus { border-collapse: collapse; border: #000000 solid 2px;}
                    th.chorus { border: #000000 solid 2px;}
                    td.chorus { border: #000000 solid 1px;}
                </style>
                <script>
                    function hideDialog() {
                        var dialogBox = document.getElementById("dialogBox");
                        dialogBox.style.visibility = "hidden";
                    }
                    
                    function showDialog(content) {
                        var dialogBox = document.getElementById("dialogBox");
                        var dialogContent = document.getElementById("dialogContent");
                        dialogContent.innerHTML = content;
                        dialogBox.style.visibility = "visible";
                    }
                </script>
                <div id="dialogBox" style="visibility: hidden; position: absolute; left: 10px; top: 10px; width: 800px; height: 100px; border-style: solid; border-width: 1px; border-color: #00006A; background-color: white; z-index: 1000;">
                    <table border="0" width="100%">
                        <tr>
                            <td style="width: 100%; font-weight:bold;" id="dialogContent"></td>
                            <td valign="top" align="right">
                                <a href="javascript:hideDialog();"><img src="img/bt_fermer.gif" border="0"/></a>
                            </td>
                        </tr>
                    </table>
                </div>
            </head>
            <body>
                <xsl:if test="$error.message!='nomessage'">
                    <xsl:attribute name="onload">javascript:showDialog('<xsl:value-of select="$error.message"/>');</xsl:attribute>
                </xsl:if>
                <h1>Mandat National</h1>
                <div class="emetteur">
                    <p>
                        <span class="lib">Comptable:</span><span class="val"><xsl:value-of select="n:LibelleComptable/@V"/> (<xsl:value-of select="n:Comptable/@V"/>)</span><br/>
                        <span class="lib">Ministère:</span><span class="val"><xsl:value-of select="n:Ministere/@LibelleMinistere"/> (<xsl:value-of select="n:Ministere/@V"/>)</span><br/>
                        <span class="lib">Ordonnateur:</span><span class="val"><xsl:value-of select="n:LibelleOrdonnateur/@V"/> (<xsl:value-of select="n:Ordo/@V"/>)</span>
                    </p>
                </div>
                <div class="budget">
                    <p>
                        <span class="lib">Programme:</span><span class="val"><xsl:value-of select="n:LibelleProgramme/@V"/> (<xsl:value-of select="n:ChapBudg/@V"/>)</span><br/>
                        <span class="lib">Sous-action:</span><span class="val"><xsl:value-of select="n:LibelleAction/@V"/> (<xsl:value-of select="n:ArtBudgExec/@V"/>)</span><br/>
                        <span class="lib">Compte PCE:</span><span class="val"><xsl:value-of select="n:LibelleBudget/@V"/> (<xsl:value-of select="n:ParagBudgExec/@V"/>)</span>
                    </p>
                </div>
                <div class="general">
                    <p>
                        <span class="lib">Num Mandat:</span><span class="val"><xsl:value-of select="n:NumMandat/@V"/></span><br/>
                        <span class="lib">Date comptabilisation:</span><span class="val"><xsl:call-template name="format-date"><xsl:with-param name="date" select="n:DateCreation[1]/@V"/></xsl:call-template></span><br/>
                        <span class="lib">Date paiement:</span>
                        <xsl:if test="exists(n:DatePaiement)">
                            <span class="val"><xsl:call-template name="format-date"><xsl:with-param name="date" select="n:DatePaiement[1]/@V"/></xsl:call-template></span>
                        </xsl:if><br/>
                        <span class="lib">Année budgétaire:</span><span class="val"><xsl:value-of select="n:AnneeBudget/@V"/></span><br/>
                        <span class="lib">Type évènement:</span><span class="val"><xsl:call-template name="typeEvt"><xsl:with-param name="evt" select="n:TypeEvt/@V"/></xsl:call-template></span><br/>
                        <span class="lib">Compte spécial du trésor:</span><span class="val"><xsl:value-of select="n:CompteSpeTresor/@V"/></span><br/>
                        <span class="lib">Opération d'investissement:</span><span class="val"><xsl:value-of select="n:NumOpeInvest/@V"/></span><br/>
                        <span class="lib">Année engagement:</span><span class="val"><xsl:value-of select="n:AnneeEngag/@V"/></span><br/>
                        <span class="lib">Engagement:</span><span class="val"><xsl:value-of select="n:NumEngag/@V"/></span><br/>
                        <span class="lib">Montant (€):</span><span class="val"><xsl:call-template name="number"><xsl:with-param name="num" select="n:MtPJ/@V"/></xsl:call-template></span>
                    </p>
                </div>
                <div class="liasses">
                    <h3>Informations générales</h3>
                    <p>
                        <span class="lib"><xsl:choose>
                            <xsl:when test="n:NumLiasseDeb/@V = n:NumLiasseFin/@V">Liasse locale:</xsl:when>
                            <xsl:otherwise>Liasses locales:</xsl:otherwise>
                        </xsl:choose></span>
                        <span class="val"><xsl:choose>
                            <xsl:when test="n:NumLiasseDeb/@V = n:NumLiasseFin/@V"><xsl:value-of select="n:NumLiasseDeb/@V"/></xsl:when>
                            <xsl:otherwise><xsl:value-of select="n:NumLiasseDeb/@V"/>..<xsl:value-of select="n:NumLiasseFin/@V"/></xsl:otherwise>
                        </xsl:choose></span><br/>
                        <span class="lib"><xsl:choose>
                            <xsl:when test="n:NumLiasseDeb/@V = n:NumLiasseFin/@V">Liasse nationale:</xsl:when>
                            <xsl:otherwise>Liasses nationales:</xsl:otherwise>
                        </xsl:choose></span>
                        <span class="val"><xsl:choose>
                            <xsl:when test="n:NumLiasseDeb/@V = n:NumLiasseFin/@V"><xsl:value-of select="n:NumLiasseNationale/n:Liasse[1]/@national"/></xsl:when>
                            <xsl:otherwise><ul><xsl:for-each select="n:NumLiasseNationale/n:Liasse"><li><xsl:value-of select="./@national"/></li></xsl:for-each></ul></xsl:otherwise>
                        </xsl:choose></span>
                    </p>
                    <h3>Informations détaillées</h3>
                    <table style="border-collapse: collapse;">
                        <colgroup>
                            <col/>
                            <col/>
                            <col/>
                            <col/>
                            <col/>
                            <col/>
                            <col/>
                            <col/>
                            <col/>
                            <col/>
                            <col/>
                            <col/>
                            <col/>
                        </colgroup>
                        <thead>
                            <tr>
                                <th colspan="7" style="text-align: center; font-weight: bold; border: solid;">Code-Barre</th>
                                <th colspan="5" style="text-align: center; font-weight: bold; border: solid;">Etiquette</th>
                            </tr>
                            <tr>
                                <th style="border-style: solid solid solid solid;">Gestion</th>
                                <th style="border-style: none solid solid none;">Trimestre</th>
                                <th style="border-style: none solid solid none;">Comptable</th>
                                <th style="border-style: none solid solid none;">Imputation</th>
                                <th style="border-style: none solid solid none;">Ministère</th>
                                <th style="border-style: none solid solid none;">Cpte spé Trésor</th>
                                <th style="border-style: none solid solid none;">Num. local</th>
                                <th style="border-style: none solid solid solid;">Ministère</th>
                                <th style="border-style: none solid solid none;">Gestion</th>
                                <th style="border-style: none solid solid none;">Trimestre</th>
                                <th style="border-style: none solid solid none;">Cpte spé national</th>
                                <th style="border-style: none solid solid none;">Num. national</th>
                            </tr>
                        </thead>
                        <tbody>
                            <xsl:for-each select="n:NumLiasseNationale/n:Liasse">
                                <tr>
                                    <xsl:choose>
                                    <xsl:when test="position() = last()">
                                        <td style="border-left: solid; border-right: solid; border-bottom: solid;"><xsl:value-of select="./@anneeGest"/></td>
                                        <td style="border-right: solid; border-bottom: solid;"><xsl:value-of select="./@triGest"/></td>
                                        <td style="border-right: solid; border-bottom: solid;"><xsl:value-of select="../../n:Comptable/@V"/></td>
                                        <td style="border-right: solid; border-bottom: solid;"><xsl:value-of select="../../n:Imputation/@V"/></td>
                                        <td style="border-right: solid; border-bottom: solid;"><xsl:value-of select="../../n:Ministere/@V"/></td>
                                        <td style="border-right: solid; border-bottom: solid;"><xsl:value-of select="./@cpteSpeTres"/></td>
                                        <td style="border-right: solid; border-bottom: solid;"><xsl:value-of select="./@local"/></td>
                                        <td style="border-left: solid; border-right: solid; border-bottom: solid;"><xsl:value-of select="./@sectionBudg"/></td>
                                        <td style="border-right: solid; border-bottom: solid;"><xsl:value-of select="./@anneeTrsp"/></td>
                                        <td style="border-right: solid; border-bottom: solid;"><xsl:value-of select="./@triTrsp"/></td>
                                        <td style="border-right: solid; border-bottom: solid;"><xsl:value-of select="./@cpteSpeNat"/></td>
                                        <td style="border-right: solid; border-bottom: solid;"><xsl:value-of select="./@national"/></td>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <td style="border-left: solid; border-right: solid;"><xsl:value-of select="./@anneeGest"/></td>
                                        <td style="border-right: solid;"><xsl:value-of select="./@triGest"/></td>
                                        <td style="border-right: solid;"><xsl:value-of select="../../n:Comptable/@V"/></td>
                                        <td style="border-right: solid;"><xsl:value-of select="../../n:Imputation/@V"/></td>
                                        <td style="border-right: solid;"><xsl:value-of select="../../n:Ministere/@V"/></td>
                                        <td style="border-right: solid;"><xsl:value-of select="./@cpteSpeTres"/></td>
                                        <td style="border-right: solid;"><xsl:value-of select="./@local"/></td>
                                        <td style="border-left: solid; border-right: solid;"><xsl:value-of select="./@sectionBudg"/></td>
                                        <td style="border-right: solid;"><xsl:value-of select="./@anneeTrsp"/></td>
                                        <td style="border-right: solid;"><xsl:value-of select="./@triTrsp"/></td>
                                        <td style="border-right: solid;"><xsl:value-of select="./@cpteSpeNat"/></td>
                                        <td style="border-right: solid;"><xsl:value-of select="./@national"/></td>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </tr>
                            </xsl:for-each>
                        </tbody>
                    </table>
                </div>
                
                <xsl:if test="count(n:Depense) &gt; 0">
                    <br/>
                    <div class="chorus">
                        <xsl:for-each select="n:Depense">
                            <h3>Informations Suppl&#233;mentaires</h3>
                            <p>
                                <xsl:if test="string-length(@CodeEvt)"><span class="lib">CodeEvt : </span><span class="val"><xsl:value-of select="@CodeEvt"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@DesignType)"><span class="lib">DesignType : </span><span class="val"><xsl:value-of select="@DesignType"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@NumPieceFi)"><span class="lib">NumPieceFi : </span><span class="val"><xsl:value-of select="@NumPieceFi"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@Societe)"><span class="lib">Societe : </span><span class="val"><xsl:value-of select="@Societe"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@NomSociete)"><span class="lib">NomSociete : </span><span class="val"><xsl:value-of select="@NomSociete"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@Poste)"><span class="lib">Poste : </span><span class="val"><xsl:value-of select="@Poste"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@ExerciceCompta)"><span class="lib">ExerciceCompta : </span><span class="val"><xsl:value-of select="@ExerciceCompta"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@ReferenceFinanciere)"><span class="lib">ReferenceFinanciere : </span><span class="val"><xsl:value-of select="@ReferenceFinanciere"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@TxtEnteteFinancier)"><span class="lib">TxtEnteteFinancier : </span><span class="val"><xsl:value-of select="@TxtEnteteFinancier"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@TexteFinancier)"><span class="lib">TexteFinancier : </span><span class="val"><xsl:value-of select="@TexteFinancier"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@MinistereBudgetaire)"><span class="lib">MinistereBudgetaire : </span><span class="val"><xsl:value-of select="@MinistereBudgetaire"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@MinistereBudgetaireDesign)"><span class="lib">MinistereBudgetaireDesign : </span><span class="val"><xsl:value-of select="@MinistereBudgetaireDesign"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@DomaineActivite)"><span class="lib">DomaineActivite : </span><span class="val"><xsl:value-of select="@DomaineActivite"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@DomaineFonctionnel)"><span class="lib">DomaineFonctionnel  : </span><span class="val"><xsl:value-of select="@DomaineFonctionnel"/></span><br/><br/></xsl:if>
                                <xsl:if test="string-length(@DateComptable)"><span class="lib">DateComptable : </span><span class="val"><xsl:call-template name="iso-date"><xsl:with-param name="datebrute" select="@DateComptable"/></xsl:call-template></span><br/></xsl:if>
                                <xsl:if test="string-length(@DatePaiement)"><span class="lib">DatePaiement : </span><span class="val"><xsl:call-template name="iso-date"><xsl:with-param name="datebrute" select="@DatePaiement"/></xsl:call-template></span><br/></xsl:if>
                                <xsl:if test="string-length(@CentreFinancier)"><span class="lib">CentreFinancier : </span><span class="val"><xsl:value-of select="@CentreFinancier"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@DesignationFinancier)"><span class="lib">DesignationFinancier : </span><span class="val"><xsl:value-of select="@DesignationFinancier"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@CentreCout)"><span class="lib">CentreCout : </span><span class="val"><xsl:value-of select="@CentreCout"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@CentreCoutDesign)"><span class="lib">CentreCoutDesign : </span><span class="val"><xsl:value-of select="@CentreCoutDesign"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@TypeEJ)"><span class="lib">TypeEJ : </span><span class="val"><xsl:value-of select="@TypeEJ"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@TypeEJDesign)"><span class="lib">TypeEJDesign : </span><span class="val"><xsl:value-of select="@TypeEJDesign"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@NumEJ)"><span class="lib">NumEJ : </span><span class="val"><xsl:value-of select="@NumEJ"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@NumEJLong)"><span class="lib">NumEJLong : </span><span class="val"><xsl:value-of select="@NumEJLong"/></span><br/></xsl:if>
                                <xsl:if test="string-length(@DateEJ)"><span class="lib">DateEJ : </span><span class="val"><xsl:call-template name="iso-date"><xsl:with-param name="datebrute" select="@DateEJ"/></xsl:call-template></span><br/></xsl:if>
                                <xsl:if test="string-length(@TypeMt)"><span class="lib">TypeMt : </span><span class="val"><xsl:value-of select="@TypeMt"/></span><br/></xsl:if>
                                
                                <xsl:if test="string-length(@FournisseurNum) or string-length(@FournisseurNom) or string-length(@FournisseurSiret)">
                                    <span class="lib"><u>Fournisseur</u></span><br/>
                                    <span class="lib">Num&#233;ro : </span><span class="val"><xsl:value-of select="@FournisseurNum"/></span><span class="lib"> Nom : </span><span class="val"><xsl:value-of select="@FournisseurNom"/></span><span class="lib"> Siret : </span><span class="val"><xsl:value-of select="@FournisseurSiret"/></span><br/><br/>
                                </xsl:if>
                                <xsl:if test="string-length(@PayeurNum) or string-length(@PayeurNom) or string-length(@PayeurSiret)">
                                    <span class="lib"><u>Payeur</u></span><br/>
                                    <span class="lib">Num&#233;ro : </span><span class="val"><xsl:value-of select="@PayeurNum"/></span><span class="lib">Nom : </span><span class="val"><xsl:value-of select="@PayeurNom"/></span><span class="lib">Siret : </span><span class="val"><xsl:value-of select="@PayeurSiret"/></span><br/><br/>
                                </xsl:if>
                                <span class="lib">Rib : </span><span class="val"><xsl:value-of select="@RibPays"/>&#160;<xsl:value-of select="@RibBanc"/>&#160;<xsl:value-of select="@RibCompte"/>&#160;<xsl:value-of select="@RibCle"/></span><br/>
                                <br/>
                                <span class="lib"><u>Informations PCE</u></span><br/>
                                <br/>
                                <table class="chorus">                            
                                    <colgroup>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                    </colgroup>
                                    <thead>
                                        <tr>
                                            <th class="chorus">Type</th>
                                            <th class="chorus">Compte</th>
                                            <th class="chorus">Libelle</th>
                                            <th class="chorus">D&#233;bit / Cr&#233;dit</th>
                                            <th class="chorus">Compte Alphanum&#233;rique</th>
                                            <th class="chorus">Compte Palier LOLF</th>
                                            <th class="chorus">Compte Budg&#233;taire</th>
                                            <th class="chorus">Montant (€)</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td class="chorus"><xsl:value-of select="@TypePce"/></td>
                                            <td class="chorus"><xsl:value-of select="@ComptePCE"/></td>
                                            <td class="chorus"><xsl:value-of select="@LibellePCE"/></td>
                                            <td class="chorus"><xsl:value-of select="@DebitCreditPCE"/></td>
                                            <td class="chorus"><xsl:value-of select="@CompteAlpha"/></td>
                                            <td class="chorus"><xsl:value-of select="@ComptePalier"/></td>
                                            <td class="chorus"><xsl:value-of select="@CompteBudg"/></td>
                                            <td class="chorus"><xsl:value-of select="@MtPCE"/></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </p>
                            <xsl:if test="count(n:PJ) &gt; 0">
                                <u><h3>Pi&#232;ces justificatives</h3></u>                        
                                <table class="chorus">                            
                                    <colgroup>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                        <col/>
                                    </colgroup>
                                    <thead>
                                        <tr>
                                            <th class="chorus">&#160;</th>
                                            <th class="chorus">Soci&#233;t&#233;</th>
                                            <th class="chorus">Num&#233;ro Pi&#232;ce Financi&#232;re</th>
                                            <th class="chorus">Poste</th>
                                            <th class="chorus">Exercice Comptable</th>
                                            <th class="chorus">Num&#233;ro EJ</th>
                                            <th class="chorus">Type PJ</th>
                                            <th class="chorus">Cont. Repos.</th>
                                            <th class="chorus">Type Document</th>                                    
                                            <th class="chorus">Format</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <xsl:for-each select="n:PJ">
                                            <tr>
                                                <td class="chorus">
                                                    <!--xsl:element name="a">
                                                        <xsl:attribute name="href">
                                                            <xsl:text disable-output-escaping="yes">xemelios:/pjatlas?id=</xsl:text><xsl:value-of select="@IdPJ"/>
                                                        </xsl:attribute>
                                                        <xsl:value-of select="@IdPJ"/>
                                                        </xsl:element-->
                                                    <center>
                                                        <xsl:element name="a">
                                                            <xsl:attribute name="href"><xsl:if test="$is.web"><xsl:value-of select="$context.path"/>/</xsl:if>pjatlas.do?contRep=<xsl:value-of select="@ContRepos"/>&amp;docId=<xsl:value-of select="@IdPJ"/></xsl:attribute>
                                                            <xsl:attribute name="style">text-decoration: none;</xsl:attribute>
                                                            <center>
                                                                <xsl:choose>
                                                                    <xsl:when test="@TypeDoc='PDF'"><img src="xemelios:/resource?pdf.png" alt="Obtenir PJ" style="border: none;"/></xsl:when>
                                                                    <!--xsl:when test="@TypeDoc='XML'"></xsl:when-->
                                                                    <xsl:otherwise><img src="xemelios:/resource?pj.png" alt="Obtenir PJ" style="border: none;"/></xsl:otherwise>
                                                                </xsl:choose>
                                                            </center>
                                                        </xsl:element>
                                                    </center>
                                                </td>
                                                <td class="chorus"><xsl:value-of select="@Societe"/></td>
                                                <td class="chorus"><xsl:value-of select="@NumPieceFi"/></td>
                                                <td class="chorus"><xsl:value-of select="@Poste"/></td>
                                                <td class="chorus"><xsl:value-of select="@ExerciceCompta"/></td>
                                                <td class="chorus"><xsl:value-of select="@NumEJ"/></td>
                                                <td class="chorus"><xsl:value-of select="@TypePJ"/></td>
                                                <td class="chorus"><xsl:value-of select="@ContRepos"/></td>
                                                <td class="chorus"><xsl:value-of select="@TypeDoc"/></td>
                                                <td class="chorus"><xsl:value-of select="@Format"/></td>
                                            </tr>
                                        </xsl:for-each>
                                    </tbody>
                                </table>
                                <br/>
                            </xsl:if>
                        </xsl:for-each>
                    </div>
                </xsl:if>
            </body>
        </html>
        
    </xsl:template>
    
    <xsl:template name="format-date">
        <xsl:param name="date"/>
        <xsl:value-of select="substring($date,9)"/>/<xsl:value-of select="substring($date,6,2)"/>/<xsl:value-of select="substring($date,1,4)"/>
    </xsl:template>
    
    <xsl:template name="typeEvt">
        <xsl:param name="evt"/>
        <xsl:choose>
            <xsl:when test="$evt = '600'">Ordonnance de virement</xsl:when>
            <xsl:when test="$evt = '603'">DL ou mandat de régularisation</xsl:when>
            <xsl:when test="$evt = '605'">Ventilation budgétaire de la paye</xsl:when>
            <xsl:when test="$evt = '610'">DL ou mandat sur commande d'achat simple en DC, DL sur bon de com./ marché en DC, DL sur contrat d'achat en DC, DL direct en DC</xsl:when>
            <xsl:when test="$evt = '612'">Ordonnances de ré-imputation</xsl:when>
            <xsl:when test="$evt = '613'">Bordereau d'annulation (inclus les types 613, 618, 619 et 620)</xsl:when>
            <xsl:otherwise>Inconnu</xsl:otherwise>
        </xsl:choose> (<xsl:value-of select="$evt"/>)
    </xsl:template>
    
    <xsl:template name="number">
        <xsl:param name="num"/>
        <xsl:choose>
            <xsl:when test="string-length(string($num)) = 0"/>
            <xsl:when test="number($num) = 0">
                <xsl:value-of select="format-number(0,'# ###,00;-# ###,00','decformat')"/>
            </xsl:when>
            <xsl:when test="string(number($num)) = 'NaN'"/>
            <xsl:otherwise>
                <xsl:value-of select="format-number($num,'# ###,00;-# ###,00','decformat')"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    
    <xsl:template name="iso-date">
        <xsl:param name="datebrute"/>
        <xsl:choose>
            <xsl:when test="string-length($datebrute)>0 and not(contains($datebrute,'..'))">        
                <xsl:value-of select="substring($datebrute, 9, 2)"/>
                <xsl:text>/</xsl:text>
                <xsl:value-of select="substring($datebrute,6,2)"/>
                <xsl:text>/</xsl:text>
                <xsl:value-of select="substring($datebrute, 1, 4)"/>
            </xsl:when>
            <xsl:when test="string-length($datebrute)>0 and contains($datebrute,'..')">
                <xsl:value-of select="$datebrute"/>
            </xsl:when>
            <xsl:otherwise>-</xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
