1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
3
<xsl:variable name="initial_bottom_pos">20.5</xsl:variable>
4
<xsl:variable name="initial_left_pos">1</xsl:variable>
5
<xsl:variable name="height_increment">6.5</xsl:variable>
6
<xsl:variable name="width_increment">10</xsl:variable>
7
<xsl:variable name="frame_height">5.5cm</xsl:variable>
8
<xsl:variable name="frame_width">10cm</xsl:variable>
9
<xsl:variable name="number_columns">2</xsl:variable>
10
<xsl:variable name="max_frames">8</xsl:variable>
12
<xsl:template match="/">
13
<xsl:apply-templates select="addresses"/>
16
<xsl:template match="addresses">
18
<template leftMargin="2.0cm" rightMargin="2.0cm" topMargin="2.0cm" bottomMargin="2.0cm" title="Address list" author="Generated by Tiny ERP">
19
<pageTemplate id="all">
21
<xsl:apply-templates select="address" mode="frames"/>
25
<paraStyle name="nospace" fontName="Courier" fontSize="12" spaceBefore="0" spaceAfter="0"/>
28
<xsl:apply-templates select="address" mode="story">
29
<xsl:sort select="contact/country"/>
30
<xsl:sort select="contact/zip"/>
31
<xsl:sort select="company-name"/>
32
</xsl:apply-templates>
37
<xsl:template match="address" mode="frames">
38
<xsl:if test="position() < $max_frames + 1">
40
<xsl:attribute name="width">
41
<xsl:value-of select="$frame_width"/>
43
<xsl:attribute name="height">
44
<xsl:value-of select="$frame_height"/>
46
<xsl:attribute name="x1">
47
<xsl:value-of select="$initial_left_pos + ((position()-1) mod $number_columns) * $width_increment"/>
48
<xsl:text>cm</xsl:text>
50
<xsl:attribute name="y1">
51
<xsl:value-of select="$initial_bottom_pos - floor((position()-1) div $number_columns) * $height_increment"/>
52
<xsl:text>cm</xsl:text>
58
<xsl:template match="address" mode="story">
59
<para style="nospace"><xsl:value-of select="company-title"/><xsl:text> </xsl:text><xsl:value-of select="company-name"/></para>
61
<xsl:when test="count(contact[type='default']) >= 1">
62
<!-- apply the first 'contact' node with the type 'default' -->
63
<xsl:apply-templates select="contact[type='default'][1]"/>
65
<xsl:when test="count(contact[type='']) >= 1">
66
<!-- apply the first 'contact' node with an empty type -->
67
<xsl:apply-templates select="contact[type=''][1]"/>
70
<!-- apply the first 'contact' node -->
71
<xsl:apply-templates select="contact[1]"/>
77
<xsl:template match="contact">
78
<para style="nospace"><xsl:value-of select="title"/><xsl:text> </xsl:text><xsl:value-of select="name"/></para>
79
<para style="nospace"><xsl:value-of select="street"/></para>
80
<para style="nospace"><xsl:value-of select="street2"/></para>
81
<para style="nospace"><xsl:value-of select="zip"/><xsl:text> </xsl:text><xsl:value-of select="city"/></para>
82
<para style="nospace"><xsl:value-of select="state"/></para>
83
<para style="nospace"><xsl:value-of select="country"/></para>