<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:camt="urn:iso:std:iso:20022:tech:xsd:camt.086.001.01"
	exclude-result-prefixes="camt" xmlns:xalan="http://xml.apache.org/xalan">
	<xsl:output method="html" />
	<xsl:template match="/">
		<html>
      <head>
         <link rel="stylesheet" type="text/css" href="camt086.css" />
      </head>
      <body>
        <img src="Bild1.png" alt="Bild1.png" style="left: 0pt; top: 0pt; height: 150pt; width: 880pt" />
        <img src="Bild2.png" alt="Bild2.png" style="position:absolute; left: 450pt; top: 90pt; height: 55pt; width: 400pt" />

        <xsl:apply-templates select="camt:Document" />
			</body>
		</html>
	</xsl:template>

	<xsl:template match="camt:Document">
		<xsl:apply-templates select="camt:BkSvcsBllgStmt" />
	</xsl:template>

	<xsl:template match="camt:BkSvcsBllgStmt">
		<xsl:apply-templates select="camt:BllgStmtGrp" />
	</xsl:template>

	<xsl:template match="camt:BllgStmtGrp">
	   <h1 class="h1">Bankspesen- und -gebührenabrechnung</h1>
      <xsl:apply-templates select="camt:Rcvr" />
      <xsl:apply-templates select="camt:Sndr" />  
      <xsl:apply-templates select="camt:BllgStmt" /> 
	</xsl:template>

  <xsl:template match="camt:Rcvr">
      <p> 
         <span class="client1">
            <xsl:apply-templates select="camt:Nm" />
         </span>
         <span class="client1" style="position: relative; left:200px;">
            Kundennr.:
			<xsl:value-of select="substring(camt:Id/camt:OrgId/camt:Othr/camt:Id,0,5)" />.<xsl:value-of select="substring(camt:Id/camt:OrgId/camt:Othr/camt:Id,5,8)" />
         </span>
      </p> 
     <xsl:apply-templates select="camt:PstlAdr" />
  </xsl:template>
  <xsl:template match="camt:PstlAdr/camt:AdrLine">
     <span class="client2">
        <xsl:value-of select="." />
        <br /> 
     </span>
  </xsl:template>

  <xsl:template match="camt:Sndr">
       <span class="text1" style="position: absolute; left:900px; top:370px;">
          <xsl:apply-templates select="camt:Nm" />
       </span><br />
       <span class="text4" style="position: absolute; left:900px; top:420px;">
          <xsl:apply-templates select="camt:PstlAdr/camt:StrtNm" />
       </span><br />
       <span class="text4" style="position: absolute; left:900px; top: 440px;">
          <xsl:apply-templates select="camt:PstlAdr/camt:PstCd" />
       </span>
       <span class="text4" style="position: absolute; left:960px; top: 440px;">
          <xsl:apply-templates select="camt:PstlAdr/camt:TwnNm" />
       </span><br />
       <span class="text4" style="position: relative; left:900px; top:470px;">
          <xsl:apply-templates select="camt:Id/camt:FIId/camt:BICID" /><br />
       </span>
   </xsl:template>

      <xsl:template match="camt:BllgStmt">
      <p>
			<xsl:if test="camt:Svc">
            <table class="table1" style="border: none;">
               <tr>
                  <td class="datacell5" width="890px" />
                  <td class="datacell5" width="300px">
                     Ihr(e) BetreuerIn:<br />
                  </td>
               </tr>
               <tr>
                  <td class="datacell5" />
                  <td class="datacell5">
                     <xsl:apply-templates select="camt:AcctChrtcs/camt:AcctSvcrCtct/camt:Nm" /><br />
                  </td>
               </tr>
               <tr>
                  <td class="datacell5">
                     Gebührenabrechnung vom 
                     <xsl:apply-templates select="camt:FrToDt/camt:FrDt" />
                     bis 
                     <xsl:apply-templates select="camt:FrToDt/camt:ToDt" />
                  </td>
                  <td class="datacell5">
                     <xsl:apply-templates select="camt:AcctChrtcs/camt:AcctSvcrCtct/camt:PhneNb" /><br />
                  </td>
               </tr>
               <tr>
                  <td class="datacell5">
                     Konto:&#xA0;&#xA0;&#xA0;
						<xsl:value-of select="substring(camt:StmtId,0,5)"/>
						&#xA0;
						<xsl:value-of select="substring(camt:StmtId,5,4)"/>
						&#xA0;
						<xsl:value-of select="substring(camt:StmtId,9,4)"/>
						&#xA0;
						<xsl:value-of select="substring(camt:StmtId,13,4)"/>
						&#xA0;
						<xsl:value-of select="substring(camt:StmtId,17,4)"/>
                  </td>
                  <td class="datacell5">
                     <xsl:apply-templates select="camt:AcctChrtcs/camt:AcctSvcrCtct/camt:EmailAdr" /><br />
                  </td>
               </tr>
            </table>
            <table class="table1" cellspacing="0">
					<tr class="header1">
						<th class="hcell1" width="450">Gebührenart</th>
						<th class="hcell1" width="170">Bank Spesencode</th>
						<th class="hcell1" width="110">AFP-Spesencode</th>
						<th class="hcell1" width="85">Anzahl</th>
						<th class="hcell1" width="100">Preis/Einheit</th>
						<th class="hcell1" width="105">Fixgebühr</th>
						<th class="hcell1" width="105">Verrechnungs-betrag</th>
					</tr>
					<xsl:apply-templates select="camt:Svc" />
					<tr class="datarow2">
            <td class="datacell1">
							<xsl:text disable-output-escaping="yes">SUMME</xsl:text>
						</td>
            <td class="datacell1">
              <xsl:text disable-output-escaping="yes"> </xsl:text>
						</td>
            <td class="datacell1">
							<xsl:text disable-output-escaping="yes"> </xsl:text>
						</td>
            <td class="datacell1" align="right">
              <xsl:text disable-output-escaping="yes"> </xsl:text>
						</td>
            <td class="datacell1">
							<xsl:text disable-output-escaping="yes"> </xsl:text>
						</td>
            <td class="datacell1">
							<xsl:text disable-output-escaping="yes"> </xsl:text>
						</td>
            <td class="datacell2">
							<xsl:value-of
								select="format-number(sum(descendant::camt:OrgnlChrgPric/camt:Amt),'0.00')" />
						</td>
					</tr>
				</table>
				<br />
				<br />
			</xsl:if>
		</p>
	</xsl:template>

  <xsl:template match="camt:Svc">
		<tr>
			<td class="datacell1">
				<xsl:value-of select="camt:SvcDtl/camt:BkSvc/camt:Desc" />
			</td>
      <td class="datacell1">
				<xsl:value-of select="camt:SvcDtl/camt:BkSvc/camt:Id" />
			</td>
      <td class="datacell1">
				<xsl:value-of select="camt:SvcDtl/camt:BkSvc/camt:CmonCd/camt:Id" />
			</td>
      <td class="datacell2">
				<xsl:value-of select="camt:SvcDtl/camt:Vol" />
			</td>
      <td class="datacell2">
				<xsl:value-of select="camt:Pric/camt:UnitPric/camt:Amt" />
			</td>
      <td class="datacell2">
        <xsl:if
					 test="(not(camt:PmtMtd ='FREE') and not(camt:PmtMtd ='INVS') and not(camt:PmtMtd ='PVCH') and not(camt:PmtMtd ='WVED'))">
           <xsl:value-of select="camt:OrgnlChrgPric/camt:Amt" />
        </xsl:if>
			</td>
      <td class="datacell2">
				<xsl:value-of select="camt:OrgnlChrgPric/camt:Amt" />
			</td>
		</tr>
	</xsl:template>
</xsl:stylesheet>