~ubuntu-branches/ubuntu/oneiric/awstats/oneiric

« back to all changes in this revision

Viewing changes to tools/xslt/awstats.datademo2.xslt

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2009-03-03 18:19:24 UTC
  • mto: (9.2.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090303181924-ovnysh9kq6ormn9k
Tags: upstream-6.9~dfsg
ImportĀ upstreamĀ versionĀ 6.9~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8"?>
 
2
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
 
3
        <xsl:output method="text"/>
 
4
 
 
5
<!-- 
 
6
        This xsl parses a awstats xml "history file" and generates a small
 
7
        plaintext report, nicely suited for cron and mail. some decisions have been
 
8
        made regarding what to display - pages or hits, etc. You are free to tweak.
 
9
 
 
10
        Commissioned by LabforCulture
 
11
        *pike@labforculture.org 20060708
 
12
        
 
13
        usage:  
 
14
        mail -s stats yourboss@yoursite < xsltproc thisfile.xsl database.xml
 
15
        
 
16
        build for AWSTATS DATA FILE 6.5 (build 1.857)
 
17
        
 
18
        
 
19
-->     
 
20
 
 
21
    <xsl:template match="/">
 
22
        
 
23
        <xsl:for-each select="/xml/section[@id='general']/table/tr">
 
24
 
 
25
                <xsl:text>&#xa;----------------</xsl:text>        
 
26
 
 
27
                <xsl:for-each select="td[text()='FirstTime']">
 
28
                        <xsl:text>&#xa;Period                   </xsl:text>
 
29
 
 
30
                        <xsl:for-each select="./following-sibling::node()">
 
31
                                <xsl:value-of select="concat(': ',substring(.,1,4),'/',substring(.,5,2),'/',substring(.,7,2))" />
 
32
                        </xsl:for-each>
 
33
                        <xsl:for-each select="../../tr/td[text()='LastTime']/following-sibling::node()">
 
34
                                <xsl:value-of select="concat(' - ',substring(.,1,4),'/',substring(.,5,2),'/',substring(.,7,2))" />
 
35
                        </xsl:for-each>
 
36
                </xsl:for-each>
 
37
                
 
38
                <xsl:for-each select="td[text()='TotalUnique']/following-sibling::node()">
 
39
                        <xsl:text>&#xa;Total unique visitors    : </xsl:text>
 
40
 
 
41
                        <xsl:value-of select="." />
 
42
                </xsl:for-each>
 
43
                
 
44
                <xsl:for-each select="td[text()='TotalVisits']/following-sibling::node()">
 
45
                        <xsl:text>&#xa;Total visits             : </xsl:text>
 
46
                        <xsl:value-of select="." />
 
47
                </xsl:for-each>
 
48
                        
 
49
        </xsl:for-each>
 
50
        
 
51
        <xsl:for-each  select="/xml/section[@id='time']/table">
 
52
 
 
53
                <xsl:text>&#xa;Total viewed pages       : </xsl:text><xsl:value-of select="sum(tr/td[2])" />
 
54
                <xsl:text>&#xa;Total viewed hits        : </xsl:text><xsl:value-of select="sum(tr/td[3])" />
 
55
                <xsl:text>&#xa;Total not viewed pages   : </xsl:text><xsl:value-of select="sum(tr/td[5])" />
 
56
                <xsl:text>&#xa;Total not viewed hits    : </xsl:text><xsl:value-of select="sum(tr/td[6])" />
 
57
                
 
58
        </xsl:for-each>
 
59
        
 
60
                <xsl:for-each  select="/xml/section[@id='misc']/table">
 
61
 
 
62
                        <xsl:for-each select="tr/td[text()='AddToFavourites']/following-sibling::node()[2]">
 
63
                                <xsl:text>&#xa;Added to favourites (?)  : </xsl:text>
 
64
                                <xsl:value-of select="." />
 
65
                        </xsl:for-each>
 
66
                </xsl:for-each>
 
67
 
 
68
                <xsl:text>&#xa;----------------</xsl:text>       
 
69
 
 
70
 
 
71
                <xsl:for-each  select="/xml/section[@id='session']/table">
 
72
                        <xsl:text>&#xa;Visit duration:</xsl:text>
 
73
 
 
74
                        <xsl:for-each select="tr/td[text()='0s-30s']/following-sibling::node()">
 
75
                                <xsl:text>&#xa; 0s-30s          : </xsl:text>
 
76
                                <xsl:value-of select="." />
 
77
                        </xsl:for-each>
 
78
                        <xsl:for-each select="tr/td[text()='30s-2mn']/following-sibling::node()">
 
79
                                <xsl:text>&#xa; 30s-2mn         : </xsl:text>
 
80
                                <xsl:value-of select="." />
 
81
 
 
82
                        </xsl:for-each>
 
83
                        <xsl:for-each select="tr/td[text()='2mn-5mn']/following-sibling::node()">
 
84
                                <xsl:text>&#xa; 2mn-5mn         : </xsl:text>
 
85
                                <xsl:value-of select="." />
 
86
                        </xsl:for-each>
 
87
                        <xsl:for-each select="tr/td[text()='5mn-15mn']/following-sibling::node()">
 
88
                                <xsl:text>&#xa; 5mn-15mn        : </xsl:text>
 
89
 
 
90
                                <xsl:value-of select="." />
 
91
                        </xsl:for-each>
 
92
                        <xsl:for-each select="tr/td[text()='15mn-30mn']/following-sibling::node()">
 
93
                                <xsl:text>&#xa; 15mn-30mn       : </xsl:text>
 
94
                                <xsl:value-of select="." />
 
95
                        </xsl:for-each>         
 
96
                        <xsl:for-each select="tr/td[text()='30mn-1h']/following-sibling::node()">
 
97
                                <xsl:text>&#xa; 30mn-1h         : </xsl:text>
 
98
 
 
99
                                <xsl:value-of select="." />
 
100
                        </xsl:for-each> 
 
101
                        <xsl:for-each select="tr/td[text()='1h+']/following-sibling::node()">
 
102
                                <xsl:text>&#xa; 1h+             : </xsl:text>
 
103
                                <xsl:value-of select="." />
 
104
                        </xsl:for-each>
 
105
                        
 
106
                </xsl:for-each>
 
107
 
 
108
                <xsl:text>&#xa;----------------</xsl:text>       
 
109
 
 
110
                
 
111
                <xsl:for-each  select="/xml/section[@id='domain']/table">
 
112
 
 
113
                        <xsl:text>&#xa;Countries top 5:</xsl:text>
 
114
                        <xsl:for-each select="tr">
 
115
                                <xsl:sort select="td[2]" data-type="number" order="descending"/>
 
116
                                <xsl:if test="position()&lt;=5">
 
117
                                        <xsl:text>&#xa; </xsl:text>
 
118
                                        <xsl:value-of select="td[1]" />
 
119
                                        <xsl:text>              : </xsl:text>
 
120
 
 
121
                                        <xsl:value-of select="td[2]" />
 
122
                                        <xsl:text> pages</xsl:text>
 
123
                                </xsl:if>
 
124
                        </xsl:for-each>
 
125
                        
 
126
                </xsl:for-each>
 
127
 
 
128
                <xsl:text>&#xa;----------------</xsl:text>       
 
129
<!-- 
 
130
        awstats xml output is seriously bugged here in my version.
 
131
        the first 10 rows of sider has 5 columns, the rest has 4 columns .. 
 
132
        the second columns content is added as plaintext inside the first column !
 
133
        
 
134
        i will wait for a fix. meanwhile, the numbers outputted
 
135
        here are dead wrong.
 
136
        
 
137
 
 
138
                
 
139
                <xsl:for-each  select="/xml/section[@id='sider']/table">
 
140
        
 
141
        
 
142
                        <xsl:text>&#xa;Entry pages top 10 (bugged):</xsl:text>
 
143
                        <xsl:for-each select="tr">
 
144
                                <xsl:sort select="td[4]" data-type="number" order="descending"/>
 
145
                                <xsl:if test="position()&lt;=10">
 
146
                                        <xsl:text>&#xa;         </xsl:text>
 
147
                                        <xsl:value-of select="td[4]" />
 
148
                                        <xsl:text>      : </xsl:text>
 
149
                                        <xsl:value-of select="td[1]" />
 
150
                                </xsl:if>
 
151
                        </xsl:for-each>
 
152
                        
 
153
                        <xsl:text>&#xa;Exit pages top 10 (bugged):</xsl:text>                   
 
154
                        <xsl:for-each select="tr[position()&lt;=10]">
 
155
                                <xsl:sort select="td[5]" data-type="number" order="descending"/>
 
156
                                <xsl:if test="position()&lt;=10">
 
157
                                        <xsl:text>&#xa;         </xsl:text>
 
158
                                        <xsl:value-of select="td[5]" />
 
159
                                        <xsl:text>      : </xsl:text>
 
160
                                        <xsl:value-of select="td[1]" />
 
161
                                </xsl:if>
 
162
                        </xsl:for-each>
 
163
                                        
 
164
                </xsl:for-each>
 
165
        
 
166
-->
 
167
 
 
168
                        
 
169
        <xsl:for-each  select="/xml/section[@id='origin']/table">
 
170
                <xsl:text>&#xa;Users arrived via:</xsl:text>
 
171
                <xsl:for-each select="tr">
 
172
                        <xsl:sort select="td[2]" data-type="number" order="descending"/>
 
173
                        <xsl:if test="td[1]='From0'">
 
174
                                <xsl:text>&#xa; Typed in / from bookmarks               : </xsl:text>
 
175
                                <xsl:value-of select="td[2]" /><xsl:text> pages</xsl:text>
 
176
 
 
177
                        </xsl:if>
 
178
                        <xsl:if test="td[1]='From1'">
 
179
                                <xsl:text>&#xa; Unknown                                 : </xsl:text>
 
180
                                <xsl:value-of select="td[2]" /><xsl:text> pages</xsl:text>
 
181
                        </xsl:if>
 
182
                        <xsl:if test="td[1]='From2'">
 
183
                                <xsl:text>&#xa; Linked from an Internet Search Engine   : </xsl:text>
 
184
 
 
185
                                <xsl:value-of select="td[2]" /><xsl:text> pages</xsl:text>
 
186
                        </xsl:if>
 
187
                        <xsl:if test="td[1]='From3'">
 
188
                                <xsl:text>&#xa; Linked from an external page            : </xsl:text>
 
189
                                <xsl:value-of select="td[2]" /><xsl:text> pages</xsl:text>
 
190
                        </xsl:if>
 
191
 
 
192
                        <xsl:if test="td[1]='From4'">
 
193
                                <xsl:text>&#xa; Linked from an internal page            : </xsl:text>
 
194
                                <xsl:value-of select="td[2]" /><xsl:text> pages</xsl:text>
 
195
                        </xsl:if>
 
196
                        <xsl:if test="td[1]='From5'">
 
197
                                <xsl:text>&#xa; Linked from newsgroups                  : </xsl:text>
 
198
 
 
199
                                <xsl:value-of select="td[2]" /><xsl:text> pages</xsl:text>
 
200
                        </xsl:if>
 
201
                        </xsl:for-each>
 
202
        </xsl:for-each>
 
203
                
 
204
        <xsl:text>&#xa;----------------</xsl:text>              
 
205
        
 
206
        <xsl:for-each  select="/xml/section[@id='searchwords']/table">
 
207
                <xsl:text>&#xa;Top search phrases:</xsl:text>   
 
208
                <xsl:for-each select="tr[position()&lt;=10]">
 
209
 
 
210
                        <xsl:text>&#xa; </xsl:text>
 
211
                        <xsl:value-of select="td[1]" />
 
212
                        <xsl:text> - </xsl:text>
 
213
                        <xsl:value-of select="td[2]" />
 
214
                        <xsl:text> hits</xsl:text>
 
215
                </xsl:for-each>
 
216
 
 
217
        </xsl:for-each>
 
218
        
 
219
        
 
220
        <xsl:text>&#xa;----------------</xsl:text>              
 
221
        
 
222
        <xsl:for-each  select="/xml/section[@id='sereferrals']/table">
 
223
                <xsl:text>&#xa;Robots/spiders:</xsl:text>       
 
224
                <xsl:for-each select="tr">
 
225
                        <xsl:sort select="td[3]" data-type="number" order="descending"/>
 
226
                        <xsl:if test="position()&lt;=10">
 
227
                                <xsl:text>&#xa; </xsl:text>
 
228
 
 
229
                                <xsl:value-of select="td[1]" />
 
230
                                <xsl:text> - </xsl:text>
 
231
                                <xsl:value-of select="td[3]" />
 
232
                                <xsl:text> hits</xsl:text>
 
233
                        </xsl:if>
 
234
                </xsl:for-each>
 
235
        </xsl:for-each>
 
236
 
 
237
        
 
238
        
 
239
        <xsl:text>&#xa;----------------&#xa;</xsl:text>     
 
240
 
 
241
    </xsl:template>
 
242
</xsl:stylesheet>