Listing 1 statement1.xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/
Transform"
xmlns:fo="http://www.w3.org/1999/XSL/
Format">

<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master
master-name="page"
page-width="11in"
page-height="8.5in"
margin-top="0.675in"
margin-bottom="0.675in"
margin-left="0.375in"
margin-right="0.375in">
<fo:region-before
region-name="header"
extent="1.5in"/>
<fo:region-after
region-name="footer"
extent="0.675in"/>
<fo:region-body
margin-top="1.5in"
region-name="body"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence
master-reference="page">
<fo:static-content
flow-name="header">
<xsl:apply-templates select="statement/account"/>
</fo:static-content>
<fo:flow
flow-name="body">
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>

<xsl:template match="account">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>

<xsl:template match="statement">
<xsl:apply-templates select=
"holdings"/>
<xsl:apply-templates select=
"transactions"/>
<xsl:apply-templates select=
"edge-summary"/>
</xsl:template>

<xsl:template match="holdings">
<fo:block>
Portfolio Holdings
</fo:block>
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>

<xsl:template match="transactions">
<fo:block>
Transaction Detail
</fo:block>
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>

<xsl:template match="edge-summary">
<fo:block>
Contribution and Distribution 
Summary
</fo:block>
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>

</xsl:stylesheet>



Listing 2 Initial transactions table templates

<xsl:template match="transaction-list">
<fo:block xsl:use-attribute-sets="title-block">
Transaction Detail
</fo:block>
<fo:table>
<fo:table-body>
<xsl:apply-templates/>
</fo:table-body>
</fo:table>
</xsl:template>

<xsl:template match="transaction">
<fo:table-row>
<fo:table-cell>
<fo:block>
<xsl:value-of select="date"/>
</fo:block>
</fo:table-cell>
...
</fo:table-row>
</xsl:template>

<fo:table-cell
xsl:use-attribute-sets=
"numeric-cell">
<fo:block>
<xsl:call-template name=
"format-dollar-amount">
<xsl:with-param 
name="amount">
<xsl:value-of 
select="ytd"/>
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:table-cell>
</xsl:template>

<xsl:template match="period">
<fo:block>
<xsl:apply-templates select="start"/>
<xsl:text> to </xsl:text>
</fo:block>
<fo:block>
<xsl:apply-templates select="end"/>
</fo:block>
</xsl:template>

</xsl:stylesheet>

Listing 3

<?xml version="1.0" ?> 
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:include href="statement.style.xsl" /> 
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="page"
page-width="11in" page-height="8.5in"
margin-top="0.25in" margin-bottom="0.25in"
margin-left="0.5in" margin-right="0.5in">
<fo:region-before region-name="header"
extent="1.25in" /> 
<fo:region-after region-name="footer"
extent="0.25in" /> 
<fo:region-body margin-top="1.5in"
margin-bottom="0.375in" region-name="body" /> 
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="page">
<fo:static-content flow-name="header">
<xsl:apply-templates select="statement/account" /> 
</fo:static-content>
<fo:static-content flow-name="footer">
<xsl:apply-templates select="statement/account/manager" /> 
</fo:static-content>
<fo:flow flow-name="body">
<xsl:apply-templates /> 
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="account">
<fo:block>
<fo:inline-container>
<fo:block>
<fo:external-graphic src="mmlogo.jpg" /> 
</fo:block>
<fo:block xsl:use-attribute-sets="logo-block">
Mandalay Mines LTD</fo:block> 
<fo:block xsl:use-attribute-sets="account-number">
<xsl:text>Your account:</xsl:text> 
<xsl:value-of select="@id" /> 
</fo:block>
</fo:inline-container>
<fo:inline-container xsl:use-attribute-sets="owner-block">
<xsl:apply-templates select="owner" /> 
</fo:inline-container>
</fo:block>
</xsl:template>
<xsl:template match="owner">
<fo:block>
<xsl:value-of select="name" /> 
</fo:block>
<xsl:apply-templates select="address1" mode="block" /> 
<xsl:apply-templates select="address2" mode="block" /> 
<fo:block>
<xsl:value-of select="city" /> 
<xsl:text>,</xsl:text> 
<xsl:value-of select="state" /> 
</fo:block>
<fo:block text-align="right">
<xsl:value-of select="postal" /> 
</fo:block>
</xsl:template>
<xsl:template match="manager">
<fo:block xsl:use-attribute-sets="manager-block">
<xsl:text>Your account manager:</xsl:text> 
<xsl:value-of select="name" /> 
<xsl:apply-templates select="address1" mode="inline" /> 
<xsl:apply-templates select="address2" mode="inline" /> 
<xsl:text>,</xsl:text> 
<xsl:value-of select="city" /> 
<xsl:text>,</xsl:text> 
<xsl:value-of select="state" /> 
<xsl:text /> 
<xsl:value-of select="postal" /> 
<xsl:apply-templates select="email" /> 
</fo:block>
</xsl:template>
<xsl:template match="address1|address2" mode="block">
<fo:block>
<xsl:apply-templates /> 
</fo:block>
</xsl:template>
<xsl:template match="address1|address2" mode="inline">
<fo:inline>

<xsl:apply-templates /> 
</fo:inline>
</xsl:template>
<xsl:template match="email">
<xsl:text>email:</xsl:text> 
<xsl:apply-templates /> 
</xsl:template>
<xsl:template match="statement">
<xsl:apply-templates select="holdings" /> 
<xsl:apply-templates select="transaction-list" /> 
<xsl:apply-templates select="edge-summary" /> 
</xsl:template>
<xsl:template match="holdings">
<fo:table xsl:use-attribute-sets="table-layout">
<fo:table-header>
<fo:table-cell ends-row="true">
<fo:block xsl:use-attribute-sets="title-block">
Portfolio Holdings</fo:block> 
</fo:table-cell>
</fo:table-header>
<fo:table-body>
<xsl:apply-templates /> 
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template name="format-dollar-amount">
<xsl:param name="amount" /> 
<xsl:value-of select="format-number
($amount, '###,###,###.00')" /> 
</xsl:template>
<xsl:template name="portfolio-columns">
<fo:table-column column-width="1.5in" /> 
<fo:table-column column-width="3.0in" /> 
<fo:table-column column-width="1.25in" /> 
<fo:table-column column-width="1.25in" /> 
<fo:table-column column-width="1.25in" /> 
<fo:table-column column-width="1.5in" /> 
</xsl:template>
<xsl:template match="holdings/cash">
<fo:table-row xsl:use-attribute-sets="portfolio-subtable">
<fo:table-cell>
<fo:block xsl:use-attribute-sets="subtitle-block">
Cash and Equivalents</fo:block> 
<fo:table>
<xsl:call-template name="portfolio-columns" /> 
<fo:table-header xsl:use-attribute-sets="table-header-text">
<fo:table-row xsl:use-attribute-sets="table-header-separator">
<fo:table-cell /> 
<fo:table-cell column-number="2">
<fo:block text-align="left">Description</fo:block> 
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="center">Current Value</fo:block> 
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-footer xsl:use-attribute-sets="table-summary">
<fo:table-row border-before-style="solid"
border-before-width="1pt">
<fo:table-cell number-columns-spanned="2">
<fo:block>Total Cash and Equivalents</fo:block> 
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:call-template name="format-dollar-amount">
<xsl:with-param name="amount">
<xsl:value-of select="sum(stake/value)" /> 
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-footer>
<fo:table-body>
<xsl:apply-templates /> 
</fo:table-body>
</fo:table>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="cash/stake">
<fo:table-row>
<fo:table-cell column-number="2">
<fo:block>
<xsl:value-of select="name" /> 
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:value-of select="value" /> 
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="holdings/mutual-funds">
<fo:table-row xsl:use-attribute-sets="portfolio-subtable">
<fo:table-cell>
<fo:block xsl:use-attribute-sets="subtitle-block">
Mutual Funds</fo:block> 
<fo:table xsl:use-attribute-sets="table-layout">
<xsl:call-template name="portfolio-columns" /> 
<fo:table-header xsl:use-attribute-sets="table-header-text">
<fo:table-row xsl:use-attribute-sets="table-header-separator">
<fo:table-cell>
<fo:block text-align="center">Quantity</fo:block> 
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="left">Description/</fo:block> 
<fo:block text-align="left">Security ID</fo:block> 
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell-header">
<fo:block text-align="center">Price</fo:block> 
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell-header">
<fo:block text-align="center">Market Value</fo:block> 
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell-header">
<fo:block>Dividends/</fo:block> 
<fo:block>Capital Gains</fo:block> 
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell-header">
<fo:block>Annual Income/</fo:block> 
<fo:block>Est. 30 day yield</fo:block> 
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-footer xsl:use-attribute-sets="table-summary">
<fo:table-row xsl:use-attribute-sets="table-summary">
<fo:table-cell number-columns-spanned="3">
<fo:block>Total Mutual Funds</fo:block> 
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:call-template name="format-dollar-amount">
<xsl:with-param name="amount">
<xsl:value-of select="sum(stake/value)" /> 
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:table-cell>
<fo:table-cell column-number="6"
xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:call-template name="format-dollar-amount">
<xsl:with-param name="amount">
<xsl:value-of select="sum(stake/yield-estimate/amount)" /> 
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-footer>
<fo:table-body>
<xsl:apply-templates /> 
</fo:table-body>
</fo:table>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="mutual-funds/stake">
<fo:table-row padding-after="4pt">
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<xsl:variable name="q">
<xsl:value-of select="quantity" /> 
</xsl:variable>
<fo:block>
<xsl:value-of select="format-number
($q,'###,###,###.00000')" /> 
</fo:block>
</fo:table-cell>
<fo:table-cell column-number="2">
<fo:block>
<xsl:value-of select="name" /> 
</fo:block>
<fo:block>
<xsl:value-of select="@id" /> 
</fo:block>
<fo:block>
<xsl:value-of select="type" /> 
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:call-template name="format-dollar-amount">
<xsl:with-param name="amount">
<xsl:value-of select="price" /> 
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:call-template name="format-dollar-amount">
<xsl:with-param name="amount">
<xsl:value-of select="value" /> 
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="dividend-action" /> 
</fo:block>
<fo:block>
<xsl:value-of select="gain-action" /> 
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:call-template name="format-dollar-amount">
<xsl:with-param name="amount">
<xsl:value-of select="yield-estimate/amount" /> 
</xsl:with-param>
</xsl:call-template>
</fo:block>
<fo:block>
<xsl:value-of select="yield-estimate/rate" /> 

</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="transaction-list">
<fo:marker marker-class-name="tx-cont" /> 
<fo:table xsl:use-attribute-sets="table-layout">
<fo:table-column column-width="1.5in" /> 
<fo:table-column column-width="2in" /> 
<fo:table-column column-width="2in" /> 
<fo:table-column column-width="1in" /> 
<fo:table-column column-width="1in" /> 
<fo:table-header xsl:use-attribute-sets="table-header-text">
<fo:table-row>
<fo:table-cell number-columns-spanned="5">
<fo:block xsl:use-attribute-sets="title-block">
<xsl:text>Transaction Detail</xsl:text> 
<fo:retrieve-marker retrieve-class-name="tx-cont" /> 
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row xsl:use-attribute-sets="table-header-separator">
<fo:table-cell>
<fo:block>Date</fo:block> 
</fo:table-cell>
<fo:table-cell>
<fo:block>Type</fo:block> 
</fo:table-cell>
<fo:table-cell>
<fo:block>Description</fo:block> 
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell-header">
<fo:block>Debit</fo:block> 
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell-header">
<fo:block>Credit</fo:block> 
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-footer>
<fo:table-row xsl:use-attribute-sets="table-summary">
<fo:table-cell number-columns-spanned="3">
<fo:block>Total Transactions</fo:block> 
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:call-template name="format-dollar-amount">
<xsl:with-param name="amount">
<xsl:value-of select="sum(transaction/debit)" /> 
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:call-template name="format-dollar-amount">
<xsl:with-param name="amount">
<xsl:value-of select="sum(transaction/credit)" /> 
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-footer>
<fo:table-body>
<xsl:apply-templates /> 
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="transaction">
<fo:table-row>
<fo:table-cell>
<fo:marker marker-class-name="tx-cont">(continued)</fo:marker> 
<fo:block>
<xsl:value-of select="date" /> 
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="type" /> 
</fo:block>
</fo:table-cell>
<fo:table-cell>
<xsl:variable name="acctID">
<xsl:value-of select="account/@id" /> 
</xsl:variable>
<fo:block>
<xsl:value-of select="//stake[@id=$acctID]/name" /> 
</fo:block>
<fo:block>
<xsl:value-of select="//stake[@id=$acctID]/type" /> 
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:value-of select="debit" /> 
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:value-of select="credit" /> 
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="edge-summary">
<fo:block xsl:use-attribute-sets="title-block">
Contribution and Distribution Summary</fo:block> 
<fo:table>
<fo:table-column column-width="1.25in" /> 
<fo:table-column column-width="2in" /> 
<fo:table-column column-width="2in" /> 
<fo:table-header xsl:use-attribute-sets="table-header-text">
<fo:table-row xsl:use-attribute-sets="table-header-separator">
<fo:table-cell column-number="2"
xsl:use-attribute-sets="numeric-cell-header">
<xsl:apply-templates select="/statement/period" /> 
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell-header">
<fo:block>Year to Date</fo:block> 
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:apply-templates /> 
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="distributions">
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="table-header-text">
<fo:block>Distributions</fo:block> 
</fo:table-cell>
<xsl:call-template name="period-ytd-cells" /> 
</fo:table-row>
</xsl:template>
<xsl:template match="withholding">
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="table-header-text">
<fo:block>Withholding</fo:block> 
</fo:table-cell>
<xsl:call-template name="period-ytd-cells" /> 
</fo:table-row>
</xsl:template>
<xsl:template name="period-ytd-cells">
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:call-template name="format-dollar-amount">
<xsl:with-param name="amount">
<xsl:value-of select="period" /> 
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="numeric-cell">
<fo:block>
<xsl:call-template name="format-dollar-amount">
<xsl:with-param name="amount">
<xsl:value-of select="ytd" /> 
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:table-cell>
</xsl:template>
<xsl:template match="period">
<fo:block>
<xsl:apply-templates select="start" /> 
<xsl:text>to</xsl:text> 
</fo:block>
<fo:block>
<xsl:apply-templates select="end" /> 
</fo:block>
</xsl:template>
</xsl:stylesheet>

Listing 4

<?xml version="1.0" ?> 
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:attribute-set name="table-header-separator">
<xsl:attribute name="border-after-width">1pt</xsl:attribute> 
<xsl:attribute name="border-after-style">solid</xsl:attribute> 
</xsl:attribute-set>
<xsl:attribute-set name="table-header-text">
<xsl:attribute name="font-weight">bold</xsl:attribute> 
<xsl:attribute name="display-align">after</xsl:attribute> 
</xsl:attribute-set>
<xsl:attribute-set name="numeric-cell-header">
<xsl:attribute name="text-align">center</xsl:attribute> 
</xsl:attribute-set>
<xsl:attribute-set name="numeric-cell">
<xsl:attribute name="text-align">end</xsl:attribute> 
<xsl:attribute name="padding-end">0.25in</xsl:attribute> 
<xsl:attribute name="font-family">courier, monospace</xsl:attribute> 
</xsl:attribute-set>
<xsl:attribute-set name="table-summary">
<xsl:attribute name="font-weight">bold</xsl:attribute> 
<xsl:attribute name="border-before-style">solid</xsl:attribute> 
<xsl:attribute name="border-before-width">1pt</xsl:attribute> 
<xsl:attribute name="space-after">8pt</xsl:attribute> 
</xsl:attribute-set>
<xsl:attribute-set name="title-block">
<xsl:attribute name="border-before-width">1pt</xsl:attribute> 
<xsl:attribute name="border-after-width">1pt</xsl:attribute> 
<xsl:attribute name="border-start-width">1pt</xsl:attribute> 
<xsl:attribute name="border-end-width">1pt</xsl:attribute> 
<xsl:attribute name="border-before-style">solid</xsl:attribute> 
<xsl:attribute name="border-after-style">solid</xsl:attribute> 
<xsl:attribute name="border-start-style">solid</xsl:attribute>
<xsl:attribute name="border-end-style">solid</xsl:attribute>
<xsl:attribute name="padding-before">4pt</xsl:attribute>
<xsl:attribute name="padding-start">6pt</xsl:attribute>
<xsl:attribute name="background-color">gray</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="font-size">16pt</xsl:attribute>
<xsl:attribute name="space-before">8pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table-layout">
<xsl:attribute name="width">100%</xsl:attribute>
<xsl:attribute name="table-omit-footer-at-break">true</xsl:attribute>
<xsl:attribute name="space-after">0.25in</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="portfolio-subtable">
<xsl:attribute name="space-before">8pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="subtitle-block">
<xsl:attribute name="border-after-width">0.5pt</xsl:attribute> 
<xsl:attribute name="border-after-style">solid</xsl:attribute>
<xsl:attribute name="padding-start">8pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute> 
<xsl:attribute name="space-before">4pt</xsl:attribute>
<xsl:attribute name="space-after">4pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="logo-block">
<xsl:attribute name="padding-start">8pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="font-family">cursive</xsl:attribute>
<xsl:attribute name="font-size">24pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="account-number">
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="font-family">serif</xsl:attribute>
<xsl:attribute name="font-size">14pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="owner-block">
<xsl:attribute name="space-start">1in</xsl:attribute>
<xsl:attribute name="font-family">
arial black, arial, sans-serif</xsl:attribute>
<xsl:attribute name="font-size">12pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="manager-block">
<xsl:attribute name="space-start">1in</xsl:attribute>
<xsl:attribute name="font-family">
arial black, arial, sans-serif</xsl:attribute>
<xsl:attribute name="font-size">8pt</xsl:attribute>
</xsl:attribute-set>
</xsl:stylesheet>