<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xml.apache.org/fop/extensions" xmlns:xi="http://www.w3.org/2001/Xinclude" xmlns:foa="http://fabio">
  <xsl:import href="statementsAtts.xsl"></xsl:import>
  <xsl:param name="customer"/>
  <xsl:include href="StatementsVars.xsl"></xsl:include>
  <xsl:output method="xml" encoding="UTF-8" indent="yes"></xsl:output>
  <xsl:strip-space elements="row transaction transaction row transaction row row stock entry abbr-transaction"></xsl:strip-space>
  <xsl:template match="/">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master margin-left="0.5cm" page-width="210mm" margin-right="0.5cm" margin-bottom="0.5cm" margin-top="2cm" master-name="letter" page-height="297mm">
          <fo:region-start extent="5cm"></fo:region-start>
          <fo:region-after extent="3cm"></fo:region-after>
          <fo:region-body  margin-left="5cm" margin-right="1cm" margin-bottom="3cm" margin-top="3cm"></fo:region-body >
          <fo:region-before extent="3cm"></fo:region-before>
          <fo:region-end extent="1cm"></fo:region-end>
        </fo:simple-page-master>
        <fo:page-sequence-master master-name="statementLetter">
          <fo:repeatable-page-master-reference master-reference="letter"/>
        </fo:page-sequence-master>
      </fo:layout-master-set>
      <fo:page-sequence  master-reference="statementLetter">
        <fo:static-content flow-name="xsl-region-before">
          <xsl:apply-templates select="document('common/letter.xml')/letter/header"/>
        </fo:static-content>
        <fo:static-content flow-name="xsl-region-end">
        </fo:static-content>
        <fo:static-content flow-name="xsl-region-after">
        </fo:static-content>
        <fo:static-content flow-name="xsl-region-start">
          <xsl:apply-templates select="document('common/letter.xml')/letter/left"/>
        </fo:static-content>
        <fo:flow  flow-name="xsl-region-body">
          <xsl:apply-templates select="document('common/letter.xml')/letter/body"/>
        </fo:flow >
      </fo:page-sequence >
    </fo:root>
  </xsl:template>
  <xsl:template match="letter/body/closingFormula/signature" foa:name="DigitalSignature" foa:group="image" foa:class="image" >
    <fo:external-graphic foa:name="DigitalSignature" foa:group="image" foa:class="image" foa:content="static" src="url({@href})" xsl:use-attribute-sets=" image">
      <xsl:apply-templates/>
    </fo:external-graphic>
  </xsl:template>
  <xsl:template match="//logo" foa:name="Logo" foa:group="image" foa:class="image" >
    <fo:external-graphic foa:name="Logo" foa:group="image" foa:class="image" foa:content="static" src="url({@href})" xsl:use-attribute-sets="image">
      <xsl:apply-templates/>
    </fo:external-graphic>
  </xsl:template>
  <xsl:template match="//customer/personal/address/street" foa:name="CustStreet" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CustStreet" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//customer/personal/internet/page" foa:name="CustWebPage" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CustWebPage" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" EndCustomer">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//service" foa:name="Services" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="Services" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Service">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//customer/personal/telephone/home" foa:name="CustHomeTel" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CustHomeTel" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="letter/body/closingText" foa:name="CloseText" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CloseText" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="name" foa:name="CustomerName" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CustomerName" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//left" foa:name="LeftSide" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="LeftSide" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets="LeftStyle">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="letter/body/openingFormulas" foa:name="OpenFormula" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="OpenFormula" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//letter/body/customer" foa:name="Customer" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="Customer" foa:group="paragraph" foa:class="block" foa:content="dynamic" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates select="$customerFile/customers/customer"/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//customer/personal/telephone/businnes" foa:name="CustBusTel" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CustBusTel" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//customer/personal/address/zip" foa:name="CustZip" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CustZip" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//service/access" foa:name="ServAcc" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="ServAcc" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" ServName">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="letter/body/accountInformation/accountStatements" foa:name="AccountStatements" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="AccountStatements" foa:group="paragraph" foa:class="block" foa:content="dynamic" xsl:use-attribute-sets=" StatementListBlock">
      <xsl:apply-templates select="$customerFile/customers/transactions/account"/>
    </fo:block>
  </xsl:template>
  <xsl:template match="letter/body/accountInformation" foa:name="AccountInfo" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="AccountInfo" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="customers/customer" foa:name="FirstCustomer" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="FirstCustomer" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//customer/personal/address/city" foa:name="CustCity" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CustCity" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//service/name" foa:name="SerName" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="SerName" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" ServNameNavy">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//customer/personal/telephone/mobile" foa:name="CustMobTel" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CustMobTel" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//customer/personal/internet/email" foa:name="CustEMail" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CustEMail" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//customer/personal/address/country" foa:name="CustCountry" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CustCountry" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//header" foa:name="Header" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="Header" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Centered">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="letter/body/openingText" foa:name="OpenText" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="OpenText" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="letter/body/closingFormula" foa:name="ClosingFormula" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="ClosingFormula" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Signature">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//customer/personal/address/state" foa:name="CustState" foa:group="paragraph" foa:class="block" >
    <fo:block foa:name="CustState" foa:group="paragraph" foa:class="block" foa:content="static" xsl:use-attribute-sets=" Normal">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="letter/body/accountInformation/accountNumber" foa:name="AccountNumber" foa:group="emphasis" foa:class="inline" >
    <fo:inline foa:name="AccountNumber" foa:group="emphasis" foa:class="inline" foa:content="dynamic" xsl:use-attribute-sets=" red">
      <xsl:apply-templates select="$customerFile//accounts/account/number"/>
    </fo:inline>
  </xsl:template>
  <xsl:template match="customers/customer/personal/name" foa:name="InlineName" foa:group="emphasis" foa:class="inline" >
    <fo:inline foa:name="InlineName" foa:group="emphasis" foa:class="inline" foa:content="static" xsl:use-attribute-sets=" italic">
      <xsl:apply-templates/>
    </fo:inline>
  </xsl:template>
  <xsl:template match="letter/body/openingFormulas/customerName" foa:name="ReceiverName" foa:group="emphasis" foa:class="inline" >
    <fo:inline foa:name="ReceiverName" foa:group="emphasis" foa:class="inline" foa:content="dynamic" xsl:use-attribute-sets=" bold_italic">
      <xsl:apply-templates select="$customerFile//customers/customer/personal/name"/>
    </fo:inline>
  </xsl:template>
  <xsl:template match="letter/body/openingText/emph" foa:name="EmphText" foa:group="emphasis" foa:class="inline" >
    <fo:inline foa:name="EmphText" foa:group="emphasis" foa:class="inline" foa:content="static" xsl:use-attribute-sets=" bold_italic">
      <xsl:apply-templates/>
    </fo:inline>
  </xsl:template>
  <xsl:template match="//link" foa:name="ExternalLink" foa:group="ext-link" foa:class="inline" >
    <fo:basic-link foa:name="ExternalLink" foa:group="ext-link" foa:class="inline" foa:content="static" external-destination="{@href}" xsl:use-attribute-sets=" link">
      <xsl:apply-templates/>
    </fo:basic-link>
  </xsl:template>
  <xsl:template match="customers/transactions/account" foa:name="TransactionTable" foa:group="simple-table" foa:class="table" >
    <fo:table foa:name="TransactionTable" foa:group="simple-table" foa:class="table" foa:content="static" table-layout="fixed" width="375.0pt" xsl:use-attribute-sets=" Table_1">
      <fo:table-column column-number="1" column-width="80pt"/>
      <fo:table-column column-number="2" column-width="150pt"/>
      <fo:table-column column-number="3" column-width="85pt"/>
      <fo:table-column column-number="4" column-width="60pt"/>
      <fo:table-body>
        <xsl:apply-templates/>
      </fo:table-body>
    </fo:table>
  </xsl:template>
  <xsl:template match="customers/transactions/account/transaction" foa:name="TransactionTable" foa:group="simple-table" foa:type="table-row" foa:class="table-row" >
    <fo:table-row foa:name="TransactionTable" foa:group="simple-table" foa:type="table-row" foa:class="table-row" foa:content="static" xsl:use-attribute-sets=" Row">
      <xsl:apply-templates/>
    </fo:table-row>
  </xsl:template>
  <xsl:template match="customers/transactions/account/transaction/date[@class='header']" foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" >
    <fo:table-cell foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="{position()}" xsl:use-attribute-sets=" Cell_1">
      <fo:block>
        <xsl:apply-templates/>
      </fo:block>
    </fo:table-cell>
  </xsl:template>
  <xsl:template match="customers/transactions/account/transaction/description[@class='header']" foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" >
    <fo:table-cell foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="{position()}" xsl:use-attribute-sets=" Cell_1">
      <fo:block>
        <xsl:apply-templates/>
      </fo:block>
    </fo:table-cell>
  </xsl:template>
  <xsl:template match="customers/transactions/account/transaction/type[@class='header']" foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" >
    <fo:table-cell foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="{position()}" xsl:use-attribute-sets=" Cell_1">
      <fo:block>
        <xsl:apply-templates/>
      </fo:block>
    </fo:table-cell>
  </xsl:template>
  <xsl:template match="customers/transactions/account/transaction/amount[@class='header']" foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" >
    <fo:table-cell foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="{position()}" xsl:use-attribute-sets=" Cell_1">
      <fo:block>
        <xsl:apply-templates/>
      </fo:block>
    </fo:table-cell>
  </xsl:template>
  <xsl:template match="customers/transactions/account/transaction/date[@class='value']" foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" >
    <fo:table-cell foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="{position()}" xsl:use-attribute-sets=" Cell_2">
      <fo:block>
        <xsl:apply-templates/>
      </fo:block>
    </fo:table-cell>
  </xsl:template>
  <xsl:template match="customers/transactions/account/transaction/description[@class='value']" foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" >
    <fo:table-cell foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="{position()}" xsl:use-attribute-sets=" Cell">
      <fo:block>
        <xsl:apply-templates/>
      </fo:block>
    </fo:table-cell>
  </xsl:template>
  <xsl:template match="customers/transactions/account/transaction/type[@class='value']" foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" >
    <fo:table-cell foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="{position()}" xsl:use-attribute-sets=" Cell_2">
      <fo:block>
        <xsl:apply-templates/>
      </fo:block>
    </fo:table-cell>
  </xsl:template>
  <xsl:template match="customers/transactions/account/transaction/amount[@class='value']" foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" >
    <fo:table-cell foa:name="TransactionTable" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="{position()}" xsl:use-attribute-sets=" Cell">
      <fo:block>
        <xsl:apply-templates/>
      </fo:block>
    </fo:table-cell>
  </xsl:template>
</xsl:stylesheet>
