topical media & game development

talk show tell print

professional-xml-04-XMLSpyFiles-Invoice.xsl / 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 xmlns:fo="http://www.w3.org/1999/XSL/Format">
                          <fo:layout-master-set>
                                  <fo:simple-page-master         master-name="A4" 
                                                                                                          page-width="29.7cm" 
                                                                                                          page-height="21cm" 
                                                                                                          margin-top="1cm" 
                                                                                                          margin-bottom="1cm" 
                                                                                                          margin-left="1cm" 
                                                                                                          margin-right="1cm">
                                          <fo:region-body/>
                                  </fo:simple-page-master>
                          </fo:layout-master-set>
                          <fo:page-sequence master-reference="A4">
                                  <fo:flow flow-name="xsl-region-body">
                                          <!-- Invoice Header Table-->
                                          <fo:table>
                                                  <fo:table-column column-width="9cm"/>
                                                  <fo:table-column column-width="9cm"/>
                                                  <fo:table-column column-width="9cm"/>
                                                  <fo:table-body>
                                                          <xsl:apply-templates select="//ROOT/Invoice"/>
                                                  </fo:table-body>
                                          </fo:table>
                                          <fo:block         padding="2px">
                                                  Payment Terms:        This invoice must be paid no later than 
                                                                  <xsl:value-of select="//ROOT/Invoice/CreditTerms"/> 
                                                  from the invoice date.
                                          </fo:block>
                                          <!-- Hire Item Table-->
                                          <fo:table padding="2px" table-omit-header-at-break="true">
                                                  <fo:table-column column-width="4cm"/>
                                                  <fo:table-column column-width="5cm"/>
                                                  <fo:table-column column-width="3cm"/>
                                                  <fo:table-column column-width="3cm"/>
                                                  <fo:table-column column-width="2cm"/>
                                                  <fo:table-column column-width="2cm"/>
                                                  <fo:table-column column-width="2cm"/>
                                                  <fo:table-column column-width="2cm"/>
                                                  <fo:table-column column-width="2cm"/>
                                                  <fo:table-column column-width="2cm"/>
                                                  <fo:table-header border-style="solid">
                                                          <fo:table-row background-color="white">
                                                                  <fo:table-cell number-columns-spanned="10">
                                                                          <fo:block font-family="serif" font-weight="bold" font-size="20pt">Hire Items</fo:block>
                                                                  </fo:table-cell>
                                                          </fo:table-row>
                                                          <fo:table-row background-color="silver">
                                                                  <fo:table-cell padding="2px">
                                                                          <fo:block>Code</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell padding="2px">
                                                                          <fo:block>Description</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell padding="2px">
                                                                          <fo:block>From Date</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell padding="2px">
                                                                          <fo:block>To Date</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell padding="2px" text-align="right">
                                                                          <fo:block>Weeks</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell padding="2px" text-align="right">
                                                                          <fo:block>Rate</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell padding="2px" text-align="right">
                                                                          <fo:block>Quantity</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell padding="2px" text-align="right">
                                                                          <fo:block>VATCode</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell padding="2px" text-align="right">
                                                                          <fo:block>Discount</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell padding="2px" text-align="right">
                                                                          <fo:block>Value</fo:block>
                                                                  </fo:table-cell>
                                                          </fo:table-row>
                                                  </fo:table-header>
                                                  <fo:table-body>
                                                          <xsl:apply-templates select="//ROOT/Invoice/HireItem"/>
                                                  </fo:table-body>
                                          </fo:table>
                                          <!-- Sale Items Table-->
                                          <fo:table>
                                                  <fo:table-column padding="2px" column-width="10cm"/>
                                                  <fo:table-column padding="2px" column-width="5cm"/>
                                                  <fo:table-column padding="2px" column-width="3cm"/>
                                                  <fo:table-column padding="2px" column-width="3cm"/>
                                                  <fo:table-column padding="2px" column-width="3cm"/>
                                                  <fo:table-column padding="2px" padding-top="5px" column-width="3cm"/>
                                                  <fo:table-header border-style="solid">
                                                          <fo:table-row background-color="white" border-style="none">
                                                                  <fo:table-cell number-columns-spanned="6">
                                                                          <fo:block font-family="serif" font-weight="bold" font-size="20pt">Sale Items</fo:block>
                                                                  </fo:table-cell>
                                                          </fo:table-row>
                                                          <fo:table-row background-color="silver">
                                                                  <fo:table-cell>
                                                                          <fo:block>Description</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell>
                                                                          <fo:block>Date</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell>
                                                                          <fo:block>Quantity</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell>
                                                                          <fo:block>Price</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell>
                                                                          <fo:block>VATCode</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell>
                                                                          <fo:block>Value</fo:block>
                                                                  </fo:table-cell>
                                                          </fo:table-row>
                                                  </fo:table-header>
                                                  <fo:table-body>
                                                          <xsl:apply-templates select="//ROOT/Invoice/SaleItem"/>
                                                  </fo:table-body>
                                          </fo:table>
                                          <!-- Invoice Totals Table-->
                                          <fo:table display-align="after" text-align="right" font-family="serif" font-weight="bold" font-size="18pt">
                                                  <fo:table-header border-style="none">
                                                          <fo:table-row background-color="white" border-style="none">
                                                                  <fo:table-cell number-columns-spanned="2" text-align="left" padding-top="10px">
                                                                          <fo:block font-family="serif" font-weight="bold" font-size="20pt">Invoice Totals</fo:block>
                                                                  </fo:table-cell>
                                                          </fo:table-row>
                                                  </fo:table-header>
                                                  <fo:table-column padding="2px" column-width="23cm"/>
                                                  <fo:table-column padding="2px" column-width="4cm"/>
                                                  <fo:table-body>
                                                          <fo:table-row border-style="none">
                                                                  <fo:table-cell padding-top="5px" padding-right="10px">
                                                                          <fo:block>Net</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell padding-top="5px" background-color="silver">
                                                                          <fo:block>£<xsl:value-of select="//ROOT/Invoice/PreVATTotal"/>
                                                                          </fo:block>
                                                                  </fo:table-cell>
                                                          </fo:table-row>
                                                          <fo:table-row>
                                                                  <fo:table-cell padding-right="10px">
                                                                          <fo:block>VAT</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell background-color="silver">
                                                                          <fo:block>£<xsl:value-of select="//ROOT/Invoice/VAT1"/>
                                                                          </fo:block>
                                                                  </fo:table-cell>
                                                          </fo:table-row>
                                                          <fo:table-row>
                                                                  <fo:table-cell padding-right="10px">
                                                                          <fo:block>Total</fo:block>
                                                                  </fo:table-cell>
                                                                  <fo:table-cell background-color="silver">
                                                                          <fo:block>£<xsl:value-of select="//ROOT/Invoice/InvoiceTotal"/>
                                                                          </fo:block>
                                                                  </fo:table-cell>
                                                          </fo:table-row>
                                                  </fo:table-body>
                                          </fo:table>
                                  </fo:flow>
                          </fo:page-sequence>
                  </fo:root>
          </xsl:template>
          <xsl:template match="//ROOT/Invoice">
                  <fo:table-row background-color="silver" text-align="center" width="27cm">
                          <fo:table-cell number-columns-spanned="3">
                                  <fo:block>
                                          <fo:external-graphic src="C:\Wrox\Professional XML\Chp4\Code\AcmeLogo.JPG" content-height="0.5cm"/>
                                  </fo:block>
                          </fo:table-cell>
                  </fo:table-row>
                  <fo:table-row background-color="white" width="27cm">
                          <fo:table-cell number-columns-spanned="3" border-style="none">
                                  <fo:block font-family="serif" font-weight="bold" font-size="28pt">Hire Invoice</fo:block>
                          </fo:table-cell>
                  </fo:table-row>
                  <fo:table-row background-color="white" width="100%">
                          <fo:table-cell padding="2px" border-top-style="solid" border-left-style="solid" border-right-style="solid" width="33%">
                                  <fo:block>Invoice:        <xsl:value-of select="InvoiceID"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell padding="2px" border-top-style="solid" border-left-style="solid" border-right-style="solid" width="33%">
                                  <fo:block font-family="serif" font-weight="bold" font-size="14pt">Customer Details</fo:block>
                          </fo:table-cell>
                          <fo:table-cell padding="2px" border-top-style="solid" border-left-style="solid" border-right-style="solid" width="33%" text-align="right">
                                  <fo:block font-family="serif" font-weight="bold" font-size="14pt">Site Address</fo:block>
                          </fo:table-cell>
                  </fo:table-row>
                  <fo:table-row background-color="white" width="100%">
                          <fo:table-cell padding="2px" border-left-style="solid" border-right-style="solid" width="33%">
                                  <fo:block>Contract:        <xsl:value-of select="ContractID"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell padding="2px" border-left-style="solid" border-right-style="solid" width="33%">
                                  <fo:block>
                                          <xsl:value-of select="AccountNumber"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell padding="2px" border-left-style="solid" border-right-style="solid" width="33%" text-align="right">
                                  <fo:block>
                                          <xsl:value-of select="DeliveryAddress1"/>
                                  </fo:block>
                          </fo:table-cell>
                  </fo:table-row>
                  <fo:table-row background-color="white" width="100%">
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%">
                                  <fo:block>Contract:        <xsl:value-of select="ContractID"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%">
                                  <fo:block>
                                          <xsl:value-of select="CustomerName"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%" text-align="right">
                                  <fo:block>
                                          <xsl:value-of select="DeliveryAddress2"/>
                                  </fo:block>
                          </fo:table-cell>
                  </fo:table-row>
                  <fo:table-row background-color="white" width="100%">
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%">
                                  <fo:block>Order No/Name:        <xsl:value-of select="OrderNumber"/>/<xsl:value-of select="OrderName"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%">
                                  <fo:block>
                                          <xsl:value-of select="CustomerAddress1"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%" text-align="right">
                                  <fo:block>
                                          <xsl:value-of select="DeliveryAddress3"/>
                                  </fo:block>
                          </fo:table-cell>
                  </fo:table-row>
                  <fo:table-row background-color="white" width="100%">
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%">
                                  <fo:block>Contract Status:        <xsl:value-of select="HireStatus"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%">
                                  <fo:block>
                                          <xsl:value-of select="CustomerAddress2"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%" text-align="right">
                                  <fo:block>
                                          <xsl:value-of select="DeliveryAddress4"/>
                                  </fo:block>
                          </fo:table-cell>
                  </fo:table-row>
                  <fo:table-row background-color="white" width="100%">
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%">
                  </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%">
                                  <fo:block>
                                          <xsl:value-of select="CustomerAddress3"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" width="33%" text-align="right">
                  </fo:table-cell>
                  </fo:table-row>
                  <fo:table-row background-color="white" width="100%">
                          <fo:table-cell border-bottom-style="solid" border-left-style="solid" border-right-style="solid" padding="2px" width="33%">
                  </fo:table-cell>
                          <fo:table-cell border-bottom-style="solid" border-left-style="solid" border-right-style="solid" padding="2px" width="33%">
                                  <fo:block>
                                          <xsl:value-of select="CustomerAddress4"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-bottom-style="solid" border-left-style="solid" border-right-style="solid" padding="2px" width="33%" text-align="right">
                                  <fo:block>Invoice Date:        <xsl:value-of select="InvoiceDate"/>
                                  </fo:block>
                          </fo:table-cell>
                  </fo:table-row>
          </xsl:template>
          <xsl:template match="//ROOT/Invoice/HireItem">
                  <fo:table-row background-color="white" width="100%">
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid">
                                  <fo:block>
                                          <xsl:value-of select="ProductCode"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid">
                                  <fo:block>
                                          <xsl:value-of select="Description"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid">
                                  <fo:block>
                                          <xsl:value-of select="FromDate"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid">
                                  <fo:block>
                                          <xsl:value-of select="ToDate"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid">
                                  <fo:block>
                                          <xsl:value-of select="Weeks"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" text-align="right">
                                  <fo:block>
                                          <xsl:value-of select="Rate"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" text-align="right">
                                  <fo:block>
                                          <xsl:value-of select="Quantity"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" text-align="right">
                                  <fo:block>
                                          <xsl:value-of select="VATCode"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" text-align="right">
                                  <fo:block>
                                          <xsl:value-of select="Discount"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid" text-align="right">
                                  <fo:block>
                                          <xsl:value-of select="Value"/>
                                  </fo:block>
                          </fo:table-cell>
                  </fo:table-row>
          </xsl:template>
          <xsl:template match="//ROOT/Invoice/SaleItem">
                  <fo:table-row  keep-with-next="always" background-color="white" width="100%">
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid">
                                  <fo:block>
                                          <xsl:value-of select="Description"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid">
                                  <fo:block>
                                          <xsl:value-of select="Date"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid">
                                  <fo:block>
                                          <xsl:value-of select="Quantity"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid">
                                  <fo:block>
                                          <xsl:value-of select="Price"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid">
                                  <fo:block>
                                          <xsl:value-of select="VATCode"/>
                                  </fo:block>
                          </fo:table-cell>
                          <fo:table-cell border-left-style="solid" padding="2px" border-right-style="solid">
                                  <fo:block>
                                          <xsl:value-of select="Value"/>
                                  </fo:block>
                          </fo:table-cell>
                  </fo:table-row>
          </xsl:template>
  </xsl:stylesheet>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.