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">
4 <xsl:template match="/">
5 <xsl:apply-templates select="report"/>
8 <xsl:template match="report">
9 <document filename="example_5.pdf">
10 <template leftMargin="1.5cm" rightMargin="1.5cm" topMargin="1.5cm" bottomMargin="1.5cm"
11 title="Reporting" author="Generated by OpenERP, Fabien Pinckaers">
12 <xsl:attribute name="pageSize">
13 <xsl:value-of select="/report/config/pageSize"/>
15 <pageTemplate id="first">
18 <xsl:attribute name="x">
19 <xsl:value-of select="/report/config/pageWidth div 2"/>
21 <xsl:attribute name="y">
22 <xsl:value-of select="/report/config/pageHeight - 56.69"/>
24 <xsl:value-of select="config/report-header"/>
27 <fill color="(0.2,0.2,0.2)"/>
28 <setFont name="Helvetica" size="10"/>
29 <drawCentredString y="10mm">
30 <xsl:attribute name="x">
31 <xsl:value-of select="/report/config/pageWidth div 2"/>
33 <xsl:value-of select="config/report-footer"/>
36 <fill color="(0.969,0.2,0.2)"/>
37 <setFont name="Helvetica" size="8"/>
38 <drawString x="1.5cm">
39 <xsl:attribute name="y">
40 <xsl:value-of select="/report/config/pageHeight - 56.69"/>
41 </xsl:attribute><xsl:text>OpenERP</xsl:text>
44 <fill color="(0.2,0.2,0.2)"/>
46 <xsl:attribute name="x">
47 <xsl:value-of select="/report/config/pageWidth - 45"/>
49 <xsl:attribute name="y">
50 <xsl:value-of select="/report/config/pageHeight - 56.69"/>
51 </xsl:attribute><xsl:value-of select="/report/config/date"/>
54 <frame id="column" x1="1.5cm" y1="1.5cm">
55 <xsl:attribute name="width">
56 <xsl:value-of select="/report/config/pageWidth - 85"/>
58 <xsl:attribute name="height">
59 <xsl:value-of select="/report/config/pageHeight - 100"/>
65 <paraStyle name="sum" fontName="Helvetica" textColor="green"/>
66 <paraStyle name="sum_float" fontName="Helvetica" alignment="right" textColor="green"/>
67 <paraStyle name="sum_end" fontName="Helvetica" textColor="red"/>
68 <paraStyle name="sum_float_end" fontName="Helvetica" alignment="right" textColor="red"/>
69 <blockTableStyle id="table">
70 <blockValign value="TOP"/>
71 <blockFont name="Helvetica" size="12" start="0,0" stop="-1,0"/>
72 <blockBackground colorName="(0.8,0.8,0.8)" start="0,0" stop="-1,0"/>
74 <lineStyle kind="GRID" colorName="lightgrey" thickness="0.3"/>
76 <lineStyle kind="LINEBELOW" colorName="black" thickness="1.5" start="0,0" stop="-1,0"/>
77 <lineStyle kind="LINEABOVE" colorName="black" thickness="1.5" start="0,0" stop="-1,0"/>
81 <blockTable style="table">
82 <xsl:attribute name="colWidths">
83 <xsl:value-of select="/report/config/tableSize"/>
85 <xsl:apply-templates select="header"/>
86 <xsl:apply-templates select="group"/>
88 <xsl:if test="group//@sum">
90 <xsl:for-each select="group[position()=1]/record[position()=1]/field">
92 <xsl:when test="position()=1">
93 <td><para style="sum_end">SUM</para></td>
95 <xsl:when test="@sum">
96 <xsl:variable name="ici">
97 <xsl:value-of select="@id"/>
99 <td><para style="sum_float_end"><xsl:value-of select="sum(../../../group/record/field[@id=$ici])"/></para></td>
108 <xsl:if test="group//@count">
110 <xsl:for-each select="group[position()=1]/record[position()=1]/field">
112 <xsl:when test="position()=1">
113 <td><para style="sum_end">#</para></td>
115 <xsl:when test="@count">
116 <xsl:variable name="ici">
117 <xsl:value-of select="@id"/>
119 <td><para style="sum_float_end"><xsl:value-of select="count(../../../group/record/field[@id=$ici])"/></para></td>
128 <xsl:if test="group//@avg">
130 <xsl:for-each select="group[position()=1]/record[position()=1]/field">
132 <xsl:when test="position()=1">
133 <td><para style="sum_end">AVG</para></td>
135 <xsl:when test="@avg">
136 <xsl:variable name="ici">
137 <xsl:value-of select="@id"/>
139 <td><para style="sum_float_end"><xsl:value-of select="sum(../../../group/record/field[@id=$ici]) div count(../../../group/record/field[@id=$ici])"/></para></td>
153 <xsl:template match="header">
155 <xsl:apply-templates select="field"/>
159 <xsl:template match="group">
160 <xsl:if test="not(/report/config/totalonly)">
161 <xsl:apply-templates select="record"/>
163 <xsl:if test="/report/config/groupby">
165 <xsl:if test="//@sum">
167 <xsl:for-each select="record[position()=1]/field">
169 <xsl:when test="/report/config/groupby = @id">
170 <td><para style="sum"><xsl:value-of select="."/> (SUM)</para></td>
172 <xsl:when test="@sum">
173 <xsl:variable name="ici">
174 <xsl:value-of select="@id"/>
176 <td><para style="sum_float"><xsl:value-of select="sum(../../record/field[@id=$ici])"/></para></td>
186 <xsl:if test="//@count">
188 <xsl:for-each select="record[position()=1]/field">
190 <xsl:when test="/report/config/groupby = @id">
191 <td><para style="sum"><xsl:value-of select="."/> (#)</para></td>
193 <xsl:when test="@count">
194 <xsl:variable name="ici">
195 <xsl:value-of select="@id"/>
197 <td><para style="sum_float"><xsl:value-of select="count(../../record/field[@id=$ici])"/></para></td>
207 <xsl:if test="//@avg">
209 <xsl:for-each select="record[position()=1]/field">
211 <xsl:when test="/report/config/groupby = @id">
212 <td><para style="sum"><xsl:value-of select="."/> (AVG)</para></td>
214 <xsl:when test="@avg">
215 <xsl:variable name="ici">
216 <xsl:value-of select="@id"/>
218 <td><para style="sum_float"><xsl:value-of select="sum(../../record/field[@id=$ici]) div count(../../record/field[@id=$ici])"/></para></td>
230 <xsl:template match="record">
232 <xsl:apply-templates select="field"/>
236 <xsl:template match="field">
238 <xsl:when test="@level">
239 <td><pre><xsl:value-of select="@level"/><xsl:value-of select="."/></pre></td>
242 <td><para><xsl:value-of select="."/></para></td>