<?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>
			<body>

				<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">
		<br/>
		<br/>
		<xsl:apply-templates select="camt:Sndr" />
		<h2>Bankspesen- und -gebührenabrechnung</h2>
		<h3>Kundendaten</h3>
		<xsl:apply-templates select="camt:Rcvr" />
		<xsl:apply-templates select="camt:BllgStmt" />
	</xsl:template>

	<xsl:template match="camt:Rcvr">
		<xsl:apply-templates select="camt:Nm" />
		<br />
		<xsl:apply-templates select="camt:PstlAdr" />
	</xsl:template>

	<xsl:template match="camt:PstlAdr">
		<xsl:apply-templates select="camt:AdrLine" />
	</xsl:template>

	<xsl:template match="camt:AdrLine">
		<xsl:value-of select="." />
		<br />
	</xsl:template>

	<xsl:template match="camt:Sndr">
		<xsl:apply-templates select="camt:Nm" />
		<br />
		<xsl:apply-templates select="camt:StrtNm" />
		<br />
		<xsl:apply-templates select="camt:PstCd" />
		<br />
		<xsl:apply-templates select="camt:TwnNm" />
		<br />
	</xsl:template>

	<xsl:template match="camt:Nm">
		<xsl:value-of select="." />
	</xsl:template>

	<xsl:template match="camt:StrtNm">
		<xsl:value-of select="." />
	</xsl:template>

	<xsl:template match="camt:PstCd">
		<xsl:value-of select="." />
	</xsl:template>

	<xsl:template match="camt:TwnNm">
		<xsl:value-of select="." />
	</xsl:template>

	<xsl:template match="camt:BllgStmt">
		<p>
			<xsl:if test="camt:Svc">
				<xsl:apply-templates select="camt:FrToDt" />
				<xsl:apply-templates select="camt:StmtId" />

				<table border="2">
					<tr bgcolor="#c4212e">
						<th width="400">Gebührenart</th>
						<th width="160">Bank Serv.ID</th>
						<th width="100">AFPGBL</th>
						<th width="85">Anzahl</th>
						<th width="100">Preis/Einheit</th>
						<th width="90">Fixgebühr</th>
						<th width="85">Summe</th>
						<th width="110">Gesamtsumme</th>
					</tr>
					<xsl:apply-templates select="camt:Svc" />
					<tr>
						<td>
							<xsl:text disable-output-escaping="yes">SUMME</xsl:text>
						</td>
						<td>
							<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
						</td>
						<td>
							<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
						</td>
						<td align="right">
							<xsl:value-of select="sum(descendant::camt:SvcDtl/camt:Vol)" />
						</td>
						<td>
							<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
						</td>
						<td>
							<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
						</td>
						<td align="right">
							<xsl:value-of
								select="format-number(sum(descendant::camt:OrgnlChrgPric/camt:Amt),'0.00')" />
						</td>
						<td align="right">
							<xsl:value-of
								select="format-number(sum(descendant::camt:OrgnlChrgPric[../camt:PmtMtd!='INVS' and ../camt:PmtMtd!='FREE' and ../camt:PmtMtd!='PVCH' and ../camt:PmtMtd!='WVED']/camt:Amt),'0.00')"/> 
						</td>
					</tr>
				</table>
				<br />
				<br />
			</xsl:if>
		</p>
	</xsl:template>

	<xsl:template match="camt:FrToDt">

		<xsl:apply-templates select="camt:FrDt" />
		<xsl:apply-templates select="camt:ToDt" />

	</xsl:template>

	<xsl:template match="camt:FrDt">
		Gebührenabrechnung für
		<xsl:value-of select="." />
	</xsl:template>

	<xsl:template match="camt:ToDt">
		bis
		<xsl:value-of select="." />
		<br />
		<br />
	</xsl:template>

	<xsl:template match="camt:StmtId">
		Konto:
		<xsl:value-of select="." />
		<br />
		<br />
	</xsl:template>

	<xsl:template match="camt:Svc">
		<tr>
			<td>
				<xsl:value-of select="camt:SvcDtl/camt:BkSvc/camt:Desc" />
			</td>
			<td>
				<xsl:value-of select="camt:SvcDtl/camt:BkSvc/camt:Id" />
			</td>
			<td>
				<xsl:value-of select="camt:SvcDtl/camt:BkSvc/camt:CmonCd/camt:Id" />
			</td>
			<td align="right">
				<xsl:value-of select="camt:SvcDtl/camt:Vol" />
			</td>
			<td align="right">
				<xsl:value-of select="camt:Pric/camt:UnitPric/camt:Amt" />
			</td>
			<td align="right">
				<xsl:value-of select="camt:OrgnlChrgPric/camt:Amt" />
			</td>
			<td align="right">
				<xsl:value-of select="camt:OrgnlChrgPric/camt:Amt" />
			</td>
			<td align="right">
				<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>
		</tr>
	</xsl:template>
</xsl:stylesheet>