<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:receipt="http://www.e-dec.ch/xml/schema/edecReceiptResponse/v1">
        
    <xsl:template match="/">
        <xsl:apply-templates select="//receipt:receiptRequestResponse/receipt:taxationDecisionExport"/>
		 <xsl:apply-templates select="//receipt:receiptRequestResponse/receipt:receiptList"/>
    </xsl:template>
    <xsl:template match="receipt:receiptRequestResponse/receipt:taxationDecisionExport" name="taxationDecisionExport">
    <xsl:variable name="correctionCode" select="receipt:correctionCode"/>
    <xsl:variable name="acceptanceDate" select="receipt:acceptanceDate"/>
    <xsl:variable name="acceptanceTime" select="receipt:acceptanceTime"/>

    <xsl:variable name="documentDate" select="receipt:documentInformation/receipt:documentDate"/>
    <xsl:variable name="documentTime" select="receipt:documentInformation/receipt:documentTime"/>
	<xsl:variable name="documentNumber" select="receipt:documentInformation/receipt:documentNumber"/>
        <html>
            <head>
<script
language="javascript">
<![CDATA[  
//found with a whole bunch of useful stuff at:
//freebarcodefonts.dobsonsw.com
function getBarcode(rawData) { var offset = 32; var highAscii = 18; var
newCodeString = new Array(rawData.length + 3); newCodeString[0] =
offset + highAscii + 104; var total = 104; for(var stringCounter = 0 ;
stringCounter < rawData.length ; stringCounter++) { var
character =
rawData.substr(stringCounter, 1); var ASCIIValue =
character.charCodeAt(0); var checkDigit = ((ASCIIValue - offset) *
(stringCounter + 1)); total += checkDigit; newCodeString[stringCounter
+ 1] = ASCIIValue; } var check = total % 103; var holder = 0; if(check
+ offset >= 127) { holder = check + offset + highAscii; } else {
holder = check + offset; } newCodeString[newCodeString.length - 2] =
holder; holder = 106 + offset + highAscii;
newCodeString[newCodeString.length - 1] = holder; for(var rCounter = 0
; rCounter < newCodeString.length ; rCounter++) {
if(newCodeString[rCounter] == 32) { newCodeString[rCounter] = 128; } }
return getBarcodeText(newCodeString);
}
function getBarcodeText(codeString) { 
var returnVal = "<p align=\"left\" style=\"font-size:16.0pt;mso-bidi-font-size:16.0pt;font-family:Code128bWinLarge\">";
for(var counter = 0 ; counter < codeString.length ; counter++) {
var intValue = codeString[counter]; returnVal += "&#" + parseInt(intValue); } returnVal += "</P>"; 
return returnVal;
}
 ]]>
</script> 

                <title>Veranlagungsverfügung</title>
                <style type="text/css">

				   <xsl:text>
					.title {font-family:Arial, Helvetica, sans-serif; font-size: 20px; font-style:bold}
					.subtitle {font-family:Arial, Helvetica, sans-serif; font-size: 38px; font-style:bold; color:red}
					.label {font-family:Arial, Helvetica, sans-serif;font-size: 12px; font-style:italic}
					.content {font-family:Arial, Helvetica, sans-serif;font-size: 12px}
					.barcodeTop {font-family:Arial, Helvetica, sans-serif;font-size: 14px}
					.barcodeCenter {font-family:Arial, Helvetica, sans-serif;font-size: 40px}
					.barcodeBottom {font-family:Arial, Helvetica, sans-serif;font-size: 24px}
					.header {font-family:Arial, Helvetica, sans-serif;font-size: 10px}
					</xsl:text>
                </style>
            </head>
            <body>
                <table width="787" border="0">
                    <tr>
                        <td width="100%" scope="row">

                           <xsl:call-template name="header"/>
                        </td>
                    </tr>
            </table>
                <table width="787" border="0">
                    <tr>
                        <td width="550" scope="row">
                        </td>
                        <td width="223" rowspan="4">

                            <table border="0" align="right" class="content" width="304">
                                <tr>
                                    <td> 
                                        <div align="left" class="barcodeTop"></div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div align="left" class="barcodeCenter"></div>

                                    </td>
                                </tr>
                                <tr id="docNumber"><xsl:value-of select="$documentNumber" /></tr>
                                <tr>
                                    <td>
                                        <!--div align="left" class="barcodeBottom" style="font-size:16.0pt;mso-bidi-font-size:16.0pt;font-family:Code128bWinLarge">08CHEE000000121755.1</div-->
										<br></br>

									<script	language="javascript">

										var number= document.getElementById("docNumber").innerHTML;
											document.writeln(getBarcode(number));
									</script>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td scope="row">

                            <div align="left">
                                <span class="title">VERANLAGUNGSVERFÜGUNG AUSFUHR </span>
                            </div>
                        </td>
                    </tr>
                    <xsl:if test="$correctionCode = 0">                    
                    <tr>
                        <td scope="row">
                            <div align="left">

                                   <span class="subtitle"> Annullation </span>
                            </div>
                        </td>
                    </tr>
                    </xsl:if>
                    <tr>
                        <td scope="row">
                            <div align="left">

                                <table width="100%" class="content" border="0">
                                    <tr>
                                        <td scope="row" class="label" width="30%">
                                            <xsl:text>Annahmedatum:</xsl:text>
                                        </td>
                                        <td> 
											 <xsl:value-of select="$acceptanceDate"/>
                                             <xsl:text>, </xsl:text>

                                             <xsl:value-of select="$acceptanceTime"/>
                                        </td>
                                    </tr>
                                    <tr> 
                                        <td scope="row"  class="label">
                                            <xsl:text>Ausstellungsdatum:</xsl:text>
                                        </td>
                                        <td>
                                             <xsl:value-of select="$documentDate"/>

                                             	<xsl:text>, </xsl:text>
                                             <xsl:value-of select="$documentTime"/>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td scope="row">
                            <div align="left">
								<xsl:call-template name="customsOffice"/>
                            </div>
                        </td>
                    </tr>
                </table>
                <p>

                    <xsl:text>
                    </xsl:text>
                </p>
                <table width="788" border="0">
                    <tr>
                        <xsl:if test="receipt:consignor">
                        <td width="513" scope="row" align="left">
                            <xsl:call-template name="consignor"/>
                        </td>

                        </xsl:if>
                        <td width="259" rowspan="3" valign="top">
                            <xsl:call-template name="headerInformationRight"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="513" scope="row" align="left">
                            <xsl:call-template name="consignee"/>
                         </td>

                    </tr>
                    <tr>
                        <td width="513" scope="row">
							<xsl:call-template name="spediteur"/>
                       </td>
                    </tr>
                    <xsl:if test="receipt:carrier">
                    <tr>
                        <td width="513" scope="row">

                            <xsl:call-template name="carrier"/>
                        </td>
                    </tr>
                    </xsl:if>
                </table>
                <p>
                    <xsl:text>
                    </xsl:text>
                </p>

				
                <xsl:for-each select="receipt:goodsItem">
	                <xsl:call-template name="goodsItem"/>
                </xsl:for-each>
				<br></br><br></br><br></br>
				<table width="787" border="0">
                <xsl:for-each select="receipt:legalAdvisory">
	                <xsl:call-template name="legalAdvisory"/>
                </xsl:for-each>				
			
				</table>

            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="header">
        <table width="100%" border="0">
            <tr>
                <td width="70%" scope="row">
                    <div align="left">
                        <img src="https://www.ezv.admin.ch/ezv/en/_jcr_content/logo/image.imagespooler.png/1480534300772/logo.png" height="60px" alt="logo_switzerland"/>

                    </div>
                </td>
                <td width="30%" valign="top" class="header">
                    <xsl:text>Eidgenössisches Finanzdepartement EFD</xsl:text>
                    <br/>
                    <strong>
                        <xsl:text>Eidgenössische Zollverwaltung EZV</xsl:text>
                    </strong>

                </td>
            </tr>
            <tr>
                <td><xsl:text> </xsl:text></td>
                <td><xsl:text> </xsl:text></td>
                <td><xsl:text> </xsl:text></td>
                <td><xsl:text> </xsl:text></td>

                <td><xsl:text> </xsl:text></td>
            </tr>
        </table>
    </xsl:template>
    
    <xsl:template name="customsOffice">
        <xsl:variable name="customsOfficeNumber" select="receipt:customsOffice/receipt:customsOfficeNumber"/>
        <xsl:variable name="name" select="receipt:customsOffice/receipt:name"/>
        <xsl:variable name="street" select="receipt:customsOffice/receipt:street"/>

        <xsl:variable name="country" select="receipt:customsOffice/receipt:country"/>
        <xsl:variable name="postalCode" select="receipt:customsOffice/receipt:postalCode"/>
        <xsl:variable name="city" select="receipt:customsOffice/receipt:city"/>
        <xsl:variable name="phoneNumber" select="receipt:customsOffice/receipt:phoneNumber"/>
        <xsl:variable name="addressSupplement1" select="receipt:customsOffice/receipt:addressSupplement1"/>
        <xsl:variable name="addressSupplement2" select="receipt:customsOffice/receipt:addressSupplement2"/>
        <table width="100%" class="content" border="0">
            <tr>
                <td>

                    <xsl:value-of select="$customsOfficeNumber"/>
                    <xsl:text> </xsl:text>
                    <xsl:value-of select="$name"/>
                </td>
            </tr>
            <tr>
                <td>
                    <xsl:value-of select="$street"/>

                </td>
            </tr>
            <xsl:if test="$addressSupplement1 and string-length($addressSupplement1)>0">
                <tr>
                    <td>
                        <xsl:value-of select="$addressSupplement1"/>
                    </td>
                </tr>
            </xsl:if>

            <xsl:if test="$addressSupplement2 and string-length($addressSupplement2)>0">
                <tr>
                    <td>
                        <xsl:value-of select="$addressSupplement2"/>
                    </td>
                </tr>
            </xsl:if>
            <tr>
                <td>

                    <xsl:if test="$country and string-length($country)>0">
                        <xsl:value-of select="$country"/>
      					<xsl:text>-</xsl:text>
                    </xsl:if>
                    <xsl:value-of select="$postalCode"/>
                    <xsl:text> </xsl:text>
                    <xsl:value-of select="$city"/>
                </td>

            </tr>
            <xsl:if test="$phoneNumber and string-length($phoneNumber)>0">
                <tr>
                    <td>
                        <xsl:text>Tel: </xsl:text>
                        <xsl:value-of select="$phoneNumber"/>
                    </td>
                </tr>

            </xsl:if>
        </table>
    </xsl:template>
    
    <xsl:template name="consignor">
        <xsl:variable name="name" select="receipt:consignor/receipt:name"/>
        <xsl:variable name="street" select="receipt:consignor/receipt:street"/>
        <xsl:variable name="country" select="receipt:consignor/receipt:country"/>
        <xsl:variable name="postalCode" select="receipt:consignor/receipt:postalCode"/>
        <xsl:variable name="city" select="receipt:consignor/receipt:city"/>

        <xsl:variable name="phoneNumber" select="receipt:consignor/receipt:phoneNumber"/>
        <xsl:variable name="addressSupplement1" select="receipt:consignor/receipt:addressSupplement1"/>
        <xsl:variable name="addressSupplement2" select="receipt:consignor/receipt:addressSupplement2"/>
        <xsl:variable name="traderIdentificationNumber" select="receipt:consignor/receipt:traderIdentificationNumber"/>
        <xsl:variable name="consignorReference" select="receipt:consignor/receipt:consignorReference"/>
        
        
        <span class="label">Versender:</span>
        <table width="100%" class="content" border="0">
            <tr>

                <td><xsl:value-of select="$name"/></td>
            </tr>
            <tr>
                <td><xsl:value-of select="$street"/></td>
            </tr>            <xsl:if test="$addressSupplement1 and string-length($addressSupplement1)>0">
                <tr>
                    <td>
                        <xsl:value-of select="$addressSupplement1"/>

                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="$addressSupplement2 and string-length($addressSupplement2)>0">
                <tr>
                    <td>
                        <xsl:value-of select="$addressSupplement2"/>
                    </td>
                </tr>

            </xsl:if>
            <tr>
                <td>
                    <xsl:value-of select="$country"/>
                    <xsl:text>-</xsl:text>
                    <xsl:value-of select="$postalCode"/>
                    <xsl:text> </xsl:text>
                    <xsl:value-of select="$city"/>

                </td>
            </tr>
            <xsl:if test="$traderIdentificationNumber and string-length($traderIdentificationNumber)>0">
                <tr>
                    <td><xsl:text>TIN-Nr.: </xsl:text>
                        <xsl:value-of select="$traderIdentificationNumber"/>
                    </td>
                </tr>

            </xsl:if>
            <xsl:if test="$consignorReference and string-length($consignorReference)>0">
                <tr>
                    <td>
						<xsl:text>Ref-Nr.: </xsl:text>
                        <xsl:value-of select="$consignorReference"/>
                    </td>
                </tr>

            </xsl:if>
        </table>
    </xsl:template>
    
    <xsl:template name="consignee">
        <xsl:variable name="name" select="receipt:consignee/receipt:name"/>
        <xsl:variable name="street" select="receipt:consignee/receipt:street"/>
        <xsl:variable name="country" select="receipt:consignee/receipt:country"/>
        <xsl:variable name="postalCode" select="receipt:consignee/receipt:postalCode"/>
        <xsl:variable name="city" select="receipt:consignee/receipt:city"/>

        <xsl:variable name="phoneNumber" select="receipt:consignee/receipt:phoneNumber"/>
        <xsl:variable name="addressSupplement1" select="receipt:consignee/receipt:addressSupplement1"/>
        <xsl:variable name="addressSupplement2" select="receipt:consignee/receipt:addressSupplement2"/>
        <xsl:variable name="traderIdentificationNumber" select="receipt:consignee/receipt:traderIdentificationNumber"/>
        <xsl:variable name="consigneeReference" select="receipt:consignee/receipt:consigneeReference"/>
        
        <span class="label">Empfänger:</span>
        <table width="100%" class="content" border="0">
            <tr>

                <td>
                    <xsl:value-of select="$name"/>
                </td>
            </tr>
            <tr>
                <td>
                    <xsl:value-of select="$street"/>
                </td>
            </tr>

            <xsl:if test="$addressSupplement1 and string-length($addressSupplement1)>0">
                <tr>
                    <td>
                        <xsl:value-of select="$addressSupplement1"/>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="$addressSupplement2 and string-length($addressSupplement2)>0">
                <tr>

                    <td>
                        <xsl:value-of select="$addressSupplement2"/>
                    </td>
                </tr>
            </xsl:if>
            <tr>
                <td>
                    <xsl:value-of select="$country"/>
                    <xsl:text>-</xsl:text>

                    <xsl:value-of select="$postalCode"/>
                    <xsl:text> </xsl:text>
                    <xsl:value-of select="$city"/>
                </td>
            </tr>
            <xsl:if test="$traderIdentificationNumber and string-length($traderIdentificationNumber)>0">
                <tr>
                    <td>

						<xsl:text>TIN-Nr.: </xsl:text>
                        <xsl:value-of select="$traderIdentificationNumber"/>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="$consigneeReference and string-length($consigneeReference)>0">
                <tr>
                    <td>

						<xsl:text>Ref-Nr.: </xsl:text>
                        <xsl:value-of select="$consigneeReference"/>
                    </td>
                </tr>
            </xsl:if>
        </table>
    </xsl:template>
    
    <xsl:template name="spediteur">

        <xsl:variable name="traderIdentificationNumber" select="receipt:declarant/receipt:traderIdentificationNumber"/> <!--  Deklarationsnummer Spedi  -->
        <xsl:variable name="declarantNumber" select="receipt:declarant/receipt:declarantNumber"/> <!-- Deklarantennummer -->
        <xsl:variable name="name" select="receipt:declarant/receipt:name"/> <!-- Spedi name -->
        <xsl:variable name="street" select="receipt:declarant/receipt:street"/>
        <xsl:variable name="country" select="receipt:declarant/receipt:country"/>
        <xsl:variable name="postalCode" select="receipt:declarant/receipt:postalCode"/>
        <xsl:variable name="city" select="receipt:declarant/receipt:city"/>

        <xsl:variable name="traderDeclarationNumber" select="receipt:traderDeclarationNumber"/> <!-- Deklarationsnummer Spedi -->
        <xsl:variable name="traderReference" select="receipt:traderReference"/> <!--  Dossiernummer Spedi -->

        <span class="label">Spediteur:</span>
        <table width="100%" class="content" border="0">
            <tr>
                <td>
                    <xsl:value-of select="$traderIdentificationNumber"/>

                </td>
            </tr>
            <tr>
                <td>
                    <xsl:value-of select="$declarantNumber"/>
                </td>
            </tr>
            <tr>
                <td>

                    <xsl:value-of select="$name"/>
                </td>
            </tr>
            <xsl:if test="$street and string-length($street)>0">
                <tr>
                    <td>
                        <xsl:value-of select="$street"/>
                    </td>
                </tr>

            </xsl:if>
            <tr>
                <td>
                    <xsl:if test="$country and string-length($country)>0">
                        <xsl:value-of select="$country"/>
                        <xsl:text>-</xsl:text>
                    </xsl:if>
                    <xsl:if test="$postalCode and string-length($postalCode)>0">

                        <xsl:value-of select="$postalCode"/>
                    </xsl:if>
                    <xsl:if test="$city and string-length($city)>0">
                        <xsl:text> </xsl:text>
                        <xsl:value-of select="$city"/>
                    </xsl:if>
                </td>
            </tr>

            <xsl:if test="$traderDeclarationNumber and string-length($traderDeclarationNumber)>0">
                <tr>
                    <td><xsl:text>Dekl.Nr: </xsl:text>
                        <xsl:value-of select="$traderDeclarationNumber"/>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="$traderReference and string-length($traderReference)>0">

                <tr>
                    <td><xsl:text>Ref-Nr.: </xsl:text>
                    <xsl:value-of select="$traderReference"/>
                    </td>
                </tr>
            </xsl:if>
        </table>
    </xsl:template>

    
    <xsl:template name="carrier">
        <xsl:variable name="name" select="receipt:carrier/receipt:name"/>
        <xsl:variable name="street" select="receipt:carrier/receipt:street"/>
        <xsl:variable name="country" select="receipt:carrier/receipt:country"/>
        <xsl:variable name="postalCode" select="receipt:carrier/receipt:postalCode"/>
        <xsl:variable name="city" select="receipt:carrier/receipt:city"/>
        <xsl:variable name="phoneNumber" select="receipt:carrier/receipt:phoneNumber"/>
        <xsl:variable name="addressSupplement1" select="receipt:carrier/receipt:addressSupplement1"/>
        <xsl:variable name="addressSupplement2" select="receipt:carrier/receipt:addressSupplement2"/>

        <xsl:variable name="traderIdentificationNumber" select="receipt:carrier/receipt:traderIdentificationNumber"/>
        <xsl:variable name="carrierReference" select="receipt:carrier/receipt:consigneeReference"/>
        <span class="label">Transporteur:</span>
        <table width="100%" class="content" border="0">
            <tr>
                <td>
                    <xsl:value-of select="$name"/>
                </td>

            </tr>
            <tr>
                <td>
                    <xsl:value-of select="$street"/>
                </td>
            </tr>
            <xsl:if test="$addressSupplement1 and string-length($addressSupplement1)>0">
                <tr>
                    <td>

                        <xsl:value-of select="$addressSupplement1"/>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="$addressSupplement2 and string-length($addressSupplement2)>0">
                <tr>
                    <td>
                        <xsl:value-of select="$addressSupplement2"/>
                    </td>

                </tr>
            </xsl:if>
            <tr>
                <td>
                    <xsl:value-of select="$country"/>
                    <xsl:text>-</xsl:text>
                    <xsl:value-of select="$postalCode"/>
                    <xsl:text> </xsl:text>

                    <xsl:value-of select="$city"/>
                </td>
            </tr>
            <xsl:if test="$traderIdentificationNumber and string-length($traderIdentificationNumber)>0">
                <tr>
                    <td>
                        <xsl:value-of select="$traderIdentificationNumber"/>
                    </td>
                </tr>

            </xsl:if>
            <xsl:if test="$carrierReference and string-length($carrierReference)>0">
                <tr>
                    <td>
                        <xsl:value-of select="$carrierReference"/>
                    </td>
                </tr>
            </xsl:if>
        </table>

    </xsl:template>
    
    <xsl:template name="headerInformationRight">
    <xsl:variable name="deliveryDestination" select="receipt:deliveryDestination"/>
    <xsl:variable name="numberOfGoodsItems" select="receipt:numberOfGoodsItems"/>
    <xsl:variable name="VATNumber" select="receipt:VATNumber"/>
    <xsl:variable name="transportMode" select="receipt:transportMeans/receipt:transportMode"/> <!-- Verkehrszweig -->
    <xsl:variable name="transportationCountry" select="receipt:transportMeans/receipt:transportationCountry"/>
    <xsl:variable name="transportationNumber" select="receipt:transportMeans/receipt:transportationNumber"/>

    <xsl:variable name="container" select="receipt:container"/>
    <xsl:variable name="containerNumber" select="receipt:containerNumber"/>
    <xsl:variable name="previousDocument" select="receipt:previousDocument"/>
    <xsl:variable name="previousDocumentType" select="receipt:previousDocument/receipt:previousDocumentType"/>
    <xsl:variable name="previousDocumentReference" select="receipt:previousDocument/receipt:previousDocumentReference"/>
    <xsl:variable name="additionalInformation" select="receipt:previousDocument/receipt:additionalInformation"/>
    <xsl:variable name="specialMention" select="receipt:specialMention"/>
    
    
            
        <table width="100%" class="content" border="0">
            <xsl:if test="$deliveryDestination and string-length($deliveryDestination)>0">

                <tr>
                    <td class="label" width="50%">Bestimmungsland:</td>
                    <td>
                        <xsl:value-of select="$deliveryDestination"/>
                    </td>
                </tr>
            </xsl:if>
            <tr>

                <td class="label">Positionen:</td>
                <td>
                    <xsl:value-of select="$numberOfGoodsItems"/>
                </td>
            </tr>
            <xsl:if test="$VATNumber and string-length($VATNumber)>0">
                <tr>
                    <td class="label">MWST-Nr:</td>

                    <td>
                        <xsl:value-of select="$VATNumber"/>
                    </td>
                </tr>
            </xsl:if>
        </table>
        <table width="100%" class="content" border="0">
            <tr>
                <td class="label">Transport:</td>

            </tr>
            <tr>
                <td>
                    <xsl:value-of select="$transportMode"/>
                    <xsl:if test="$transportationCountry and string-length($transportationCountry)>0">
                        <xsl:text>, </xsl:text>
                        <xsl:value-of select="$transportationCountry"/>
                    </xsl:if>

                    <xsl:if test="$transportationNumber and string-length($transportationNumber)>0">
	                    <xsl:text>, </xsl:text>
	                    <xsl:value-of select="$transportationNumber"/>
	                </xsl:if>
                </td>
            </tr>
            <xsl:if test="$container">
                <tr>

                    <td class="label">
                        <div align="left">Container:</div>
                    </td>
                </tr>
                <xsl:for-each select="$container">
                    <tr>
                        <td>
                            <xsl:value-of select="receipt:containerNumber"/>

                        </td>
                    </tr>
                </xsl:for-each>
            </xsl:if>
            <xsl:if test="$previousDocument">
                <tr>
                    <td class="label">Vorpapiere:</td>
                </tr>

                <xsl:for-each select="$previousDocument">
                    <tr>
                        <td>
                            <xsl:value-of select="receipt:previousDocumentType"/>
                            <xsl:text>, </xsl:text>
                            <xsl:value-of select="receipt:previousDocumentReference"/>
                            <xsl:text>, </xsl:text>
                            <xsl:value-of select="receipt:additionalInformation"/>

                        </td>
                    </tr>
                </xsl:for-each>
            </xsl:if>
            <xsl:if test="$specialMention">
            <tr>
                <td class="label">Besondere Vermerke: </td>
            </tr>

            <xsl:for-each select="$specialMention">
            <tr>
                <td><xsl:value-of select="receipt:text"/></td>
            </tr>
            </xsl:for-each>
            </xsl:if>
        </table>
    </xsl:template>

    <xsl:template name="legalAdvisory">
		<xsl:variable name="title" select="receipt:title"/>
		<xsl:variable name="text" select="receipt:text"/>
		<tr class="label">
	        <xsl:value-of select="$title"/>
		</tr>
		<tr class="content">
			<xsl:value-of select="$text"/>
		</tr><br/>

	</xsl:template>
	
    <xsl:template name="goodsItem">
        <xsl:variable name="customsItemNumber" select="receipt:customsItemNumber"/>
        <xsl:variable name="description" select="receipt:description"/>
        <xsl:variable name="statisticalCode" select="receipt:statisticalCode"/>
		<xsl:variable name="statisticalValue" select="receipt:statistic/receipt:statisticalValue"/>
        <xsl:variable name="commodityCode" select="receipt:commodityCode"/>
        <xsl:variable name="customsClearanceType" select="receipt:statistic/receipt:customsClearanceType"/>
        <xsl:variable name="refund" select="receipt:refund"/>

		<xsl:variable name="refundType" select="receipt:refund/receipt:refundType"/>
        <xsl:variable name="netMass" select="receipt:netMass"/>
        <xsl:variable name="grossMass" select="receipt:grossMass"/> <!--  Rohmasse neu im Schema 0.4  -->
        <xsl:variable name="specialMention" select="receipt:specialMention"/>
        <xsl:variable name="additionalUnit" select="receipt:additionalUnit"/>
		<xsl:variable name="packaging" select="receipt:packaging"/>	
        <xsl:variable name="permit" select="receipt:permit"/>
        <xsl:variable name="producedDocument" select="receipt:producedDocument"/>
		<xsl:variable name="processType" select="receipt:repairAndRefinement/receipt:processType"/>

		<xsl:variable name="customsClearanceTypeText">
		<xsl:choose>
			<xsl:when test = "$customsClearanceType = '1'">
				<xsl:value-of select="'Normalabfertigung'"/>
			</xsl:when>
			<xsl:when test = "$customsClearanceType = '2'">
				<xsl:value-of select="'Veredelungsverkehr'"/>
			</xsl:when>

			<xsl:when test = "$customsClearanceType = '3'">
				<xsl:value-of select="'Ausbesserungsverkehr'"/>
			</xsl:when>
			<xsl:when test = "$customsClearanceType = '4'">
				<xsl:value-of select="'Rückwaren'"/>
			</xsl:when>
			<xsl:when test = "$customsClearanceType = '5'">
				<xsl:value-of select="'Zollerleichterung'"/>
			</xsl:when>

			<xsl:when test = "$customsClearanceType = '6'">
				<xsl:value-of select="'Tabak'"/>
			</xsl:when>
			<xsl:when test = "$customsClearanceType = '7'">
				<xsl:value-of select="'Zollfreie Abfertigung gem. ZG'"/>
			</xsl:when>
			<xsl:when test = "$customsClearanceType = '8'">
				<xsl:value-of select="'Abgabenfreie Abfertigung'"/>
			</xsl:when>

			<xsl:when test = "$customsClearanceType = '9'">
				<xsl:value-of select="'Sonderfälle ex ZIL Abfertigungscode 9'"/>
			</xsl:when>
		</xsl:choose>
		</xsl:variable>
		
		<xsl:variable name="refundTypeText">
		<xsl:choose>
			<xsl:when test = "$refundType = '1'">
				<xsl:value-of select="'Rückerstattung der Lenkungsabgabe auf VOC'"/>

			</xsl:when>
			<xsl:when test = "$refundType = '2'">
				<xsl:value-of select="'Antrag für Ausfuhrbeiträge für LW'"/>
			</xsl:when>
			<xsl:when test = "$refundType = '3'">
				<xsl:value-of select="'Antrag auf Alkohol'"/>
			</xsl:when>
			<xsl:when test = "$refundType = '4'">
				<xsl:value-of select="'Antrag auf mindestens 2 der Rückerstattungstyp 1 bis 3'"/>

			</xsl:when>
			<xsl:when test = "$refundType = '5'">
				<xsl:value-of select="'Rückerstattung Biersteuer'"/>
			</xsl:when>
			<xsl:when test = "$refundType = '6'">
				<xsl:value-of select="'Rückerstattung andere'"/>
			</xsl:when>
		</xsl:choose>
		</xsl:variable>

		<xsl:variable name="processTypeText">
		<xsl:choose>
			<xsl:when test = "$processType = '1'">
				<xsl:value-of select="'Ordentliches Verfahren'"/>
			</xsl:when>
			<xsl:when test = "$processType = '2'">
				<xsl:value-of select="'Vereinfachtes Verfahren'"/>
			</xsl:when>

		</xsl:choose>
		</xsl:variable>
		
        <table width="788" border="0" class="content">
            <tr><hr></hr></tr>
            <tr>
                <td colspan="2">
                    <strong><xsl:value-of select="receipt:customsItemNumber"/><xsl:text>   </xsl:text> <xsl:value-of select="receipt:description"/></strong>
                </td>

                <td width="230" align="right">
                    <strong>
                        <xsl:value-of select="$commodityCode"/>
                        <xsl:if test="$statisticalCode">
                            <xsl:text>   </xsl:text>
                            <xsl:value-of select="$statisticalCode"/>
                        </xsl:if>
                    </strong>

                </td>
            </tr>
            <xsl:if test="$customsClearanceType or $refund">
            <tr>
                <td><table width="100%" border="0" class="content">
                    <tr><td class="label" width="10%">Veranlagungstyp: </td><td><xsl:value-of select="$customsClearanceTypeText"/></td></tr>
        			</table>
                </td>

                <td  colspan="2"><span class="label">Rückerstattungstyp: </span><xsl:value-of select="$refundTypeText"/> </td>
            </tr>
            </xsl:if>
			
			<xsl:if test="$processType">
            <tr>
                <td><table width="100%" border="0" class="content">
                    <tr><td class="label" width="10%">Verfahren: </td><td><xsl:value-of select="$processTypeText"/></td></tr>

        			</table>
                </td>
            </tr>
            </xsl:if>
            
			<tr>
                <td><table width="100%" border="0" class="content">
                    <tr><td class="label" width="10%">Eigenmasse: </td><td><xsl:value-of select="$netMass"/></td></tr>
        			</table>

        		 </td>
                <td> <span class="label">Rohmasse: </span><xsl:value-of select="$grossMass"/></td>
				<td> <span class="label">Stat.Wert: </span><xsl:value-of select="$statisticalValue"/></td>
            </tr>
            <xsl:if test="$specialMention or $packaging">
            <tr>
                <td> <table width="100%" border="0" class="content">

                    <tr><td class="label">Besondere Vermerke: </td></tr>
                    <xsl:for-each select="$specialMention/receipt:text">
                    <tr><td><xsl:value-of select="."/></td></tr>
                    </xsl:for-each>
                    </table>
                </td>
                <td valign="top" colspan="2"><span class="label">Zusatzmenge: </span><xsl:value-of select="$additionalUnit"/></td>
                <td> </td>

            </tr>
            </xsl:if>
            <tr>
                <td valign="top">
                    <table width="100%" border="0" class="content">
                        <tr>
                            <td class="label">Packstücke:</td>
                        </tr>

						<tr>
                            <td class="label">(Art,Anzahl,Nummer)</td>
                        </tr>
                        <xsl:for-each select="$packaging"> 
                            <tr>
                                <td>
                                    <xsl:value-of select="./receipt:packagingType"/> <xsl:text>, </xsl:text><xsl:value-of select="./receipt:quantity"/><xsl:text>, </xsl:text><xsl:value-of select="./receipt:packagingReferenceNumber"/>

                                </td>
                            </tr>
                        </xsl:for-each>
                    </table>
                </td>
                <xsl:if test="$permit">
                    <td valign="top">
                        <table width="100%" border="0" class="content">
                            <tr>

                                <td class="label">Bewilligungen:</td>
                            </tr>
							<tr>
                                <td class="label">(Typ,Stelle,Nummer,Datum,Zusatzinformation)</td>
                            </tr>
                            <xsl:for-each select="$permit">
                                <tr>
                                    <td>

                                        <xsl:value-of select="./receipt:permitType"/>
                                        <xsl:text>, </xsl:text>
                                        <xsl:value-of select="./receipt:permitAuthority"/>
                                        <xsl:text>, </xsl:text>
                                        <xsl:value-of select="./receipt:permitNumber"/>
                                        <xsl:text>, </xsl:text>
                                        <xsl:value-of select="./receipt:issueDate"/>

                                        <xsl:text>, </xsl:text>
                                        <xsl:value-of select="./receipt:additionalInformation"/>
                                    </td>
                                </tr>
                            </xsl:for-each>
                        </table>
                    </td>
                </xsl:if>

                <xsl:if test="$producedDocument">
                    <td valign="top">
                        <table width="100%" border="0" class="content">
                            <tr>
                                <td class="label">Unterlagen: </td>
                            </tr>
							<tr>
                                <td class="label">(Art,Nummer,Datum,Zusatzinformation)</td>

                            </tr>
                            <xsl:for-each select="$producedDocument">
                                <tr>
                                    <td>
                                        <xsl:value-of select="./receipt:documentType"/>
                                        <xsl:text>, </xsl:text>
                                        <xsl:value-of select="./receipt:documentReferenceNumber"/>
                                        <xsl:text>, </xsl:text>

                                        <xsl:value-of select="./receipt:issueDate"/>
                                        <xsl:text>, </xsl:text>
                                        <xsl:value-of select="./receipt:additionalInformation"/>
                                        <xsl:text>, </xsl:text>
                                    </td>
                                </tr>
                            </xsl:for-each>
                        </table>

                    </td>
                </xsl:if>
            </tr>
        </table>
        <br></br>
    </xsl:template>
	
	    <xsl:template match="receipt:receiptRequestResponse/receipt:receiptList" name="receiptList">
        <xsl:variable name="requestDate" select="receipt:receiptRequestSummary/receipt:requestDate"/>
        <xsl:variable name="requestTime" select="receipt:receiptRequestSummary/receipt:requestTime"/>

        <xsl:variable name="numberOfDocumentsFound" select="receipt:receiptRequestSummary/receipt:numberOfDocumentsFound"/>
        <html>
            <head>
                <title>Liste der Zollanmeldungsnummern</title>
                <style type="text/css">
                    <xsl:text>
					.title {font-family:Arial, Helvetica, sans-serif; font-size: 20px; font-style:bold}
					.label {font-family:Arial, Helvetica, sans-serif;font-size: 12px; font-style:italic}
					.content {font-family:Arial, Helvetica, sans-serif;font-size: 12px}
					.header {font-family:Arial, Helvetica, sans-serif;font-size: 10px}
					</xsl:text>
                </style>

            </head>
            <body>
                <table width="787" border="0">
                    <tr>
                        <td width="100%" scope="row">
                            <xsl:call-template name="header"/>
                        </td>
                    </tr>
                    <tr>

                        <td scope="row">
                            <div align="left">
                                <span class="title">Liste der Zollanmeldungsnummern</span>
                            </div>
                            <p>
                            </p>
                            <p>
                            </p>

                        </td>
                    </tr>
                    <tr>
                        <td scope="row">
                            <div align="left">
                                <table width="100%" class="content" border="0">
                                    <tr>
                                        <td scope="row" class="label" width="30%">
                                            <xsl:text>Abfragedatum:</xsl:text>

                                            <xsl:value-of select="$requestDate"/>
                                            <xsl:text>, </xsl:text>
                                            <xsl:value-of select="$requestTime"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td scope="row" class="label" width="30%">
                                            <xsl:text>Anzahl gefundener Veranlagungsverfügungen:</xsl:text>

                                            <xsl:value-of select="$numberOfDocumentsFound"/>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>
                </table>
                <p>

                </p>
                <p>
                </p>
                <p>
                </p>
                <p>
                </p>
                <xsl:for-each select="receipt:receiptInformation">
                    <xsl:call-template name="receiptInformation"/>

                </xsl:for-each>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="receiptInformation">
        <xsl:variable name="documentType" select="receipt:documentType"/>
        <xsl:variable name="customsDeclarationNumber" select="receipt:customsDeclarationNumber"/>
        <xsl:variable name="customsDeclarationVersion" select="receipt:customsDeclarationVersion"/>
        <xsl:variable name="documentDate" select="receipt:documentDate"/>

        <xsl:variable name="documentTime" select="receipt:documentTime"/>
        <xsl:variable name="documentStatus" select="receipt:documentStatus"/>
        <xsl:variable name="consigneeName" select="receipt:consigneeName"/>
        <xsl:variable name="transportationNumber" select="receipt:transportationNumber"/>
        <xsl:variable name="customsOfficeNumber" select="receipt:customsOfficeNumber"/>
        <table width="788" border="0" class="content">
            <tr>
                <hr>
                </hr>

            </tr>
            <tr>
                <td colspan="2">
                    <strong>
                        <xsl:value-of select="$customsDeclarationNumber"/>
                    </strong>.<strong>
                                  <xsl:value-of select="$customsDeclarationVersion"/>
                              </strong>

                </td>
            </tr>
            <tr>
                <td width="60%">
                    <span class="label">Empfängername: </span>
                    <xsl:value-of select="$consigneeName"/>
                </td>
                <td>

                    <table width="100%" border="0" class="content">
                        <tr>
                            <td class="label" width="10%">Ausstellungsdatum:
	                    <xsl:value-of select="$documentDate"/>
                                <xsl:text>, </xsl:text>
                                <xsl:value-of select="$documentTime"/>
                            </td>
                        </tr>
                    </table>

                </td>
            </tr>
            <tr>
                <td>
                    <span class="label">Dokumenttyp: </span>
                    <xsl:value-of select="$documentType"/>
                </td>
                <td>

                    <span class="label">Zollstellennummer: </span>
                    <xsl:value-of select="$customsOfficeNumber"/>
                </td>
            </tr>
            <tr>
                <td>
                    <span class="label">Status: </span>
                    <xsl:value-of select="$documentStatus"/>

                </td>
                <td>
                    <span class="label">Transportnummer: </span>
                    <xsl:if test="$transportationNumber and string-length($transportationNumber)>0">
                        <xsl:value-of select="$transportationNumber"/>
                    </xsl:if>
                </td>
            </tr>

        </table>
        <br>
        </br>
    </xsl:template>

</xsl:stylesheet>        
