741a678ddd231b8dc6781465591dc0cde1d94c4a
[utils] / crawler / kiss / src / main / resources / reportToText.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3   <xsl:output method="text"/>
4   
5   <xsl:include href="utilities.xsl"/>
6   <xsl:template match="report">
7     <xsl:text>KiSS crawler report</xsl:text>
8     <xsl:value-of select="$newline"/>
9     <xsl:value-of select="$newline"/>
10     
11     <xsl:apply-templates select="recorded"/>
12     <xsl:if test="count(interesting) > 0">
13       <xsl:text>Possibly interesting programs</xsl:text>
14       <xsl:value-of select="$newline"/>
15       <xsl:value-of select="$newline"/>
16       
17       <xsl:apply-templates select="interesting"/>
18     </xsl:if>
19     
20     <xsl:apply-templates select="messages"/>
21   </xsl:template>
22   
23   <xsl:template name="programTable">
24     <xsl:apply-templates select="program"/>
25   </xsl:template>
26   <xsl:template match="recorded">
27     <xsl:choose>
28       <xsl:when test="@result = 'OK'">
29         <xsl:text>Successfully recorded programs </xsl:text>
30         <xsl:value-of select="$newline"/>
31         <xsl:value-of select="$newline"/>
32         <xsl:call-template name="programTable"/>
33       </xsl:when>
34       <xsl:when test="@result = 'DUPLICATE'">
35         <xsl:text>Already recorded programs</xsl:text>
36         <xsl:value-of select="$newline"/>
37         <xsl:value-of select="$newline"/>
38         <xsl:call-template name="programTable"/>
39       </xsl:when>
40       <xsl:when test="@result = 'CONFLICT'">
41         <xsl:text>Conflicts with other recorded programs</xsl:text>
42         <xsl:value-of select="$newline"/>
43         <xsl:value-of select="$newline"/>
44         <xsl:call-template name="programTable"/>
45       </xsl:when>
46       <xsl:when test="@result='ERROR'">
47         <xsl:text>Programs that could not be recorded for technical reasons.</xsl:text>
48         <xsl:value-of select="$newline"/>
49         <xsl:value-of select="$newline"/>
50         <xsl:call-template name="programTable"/>
51       </xsl:when>
52     </xsl:choose>
53     
54   </xsl:template>
55   
56   <xsl:template name="addProgramInfo">
57     <xsl:text>*</xsl:text>
58     <xsl:value-of select="interval/begin"/> - <xsl:value-of select="interval/end"/>
59     <xsl:text>: </xsl:text>
60     <xsl:value-of select="name"/>
61     <xsl:text>(</xsl:text>
62     <xsl:value-of select="channel"/>
63     <xsl:text>/</xsl:text><xsl:value-of select="keywords"/>
64     <xsl:text>)</xsl:text>
65     <xsl:value-of select="$newline"/> 
66     <xsl:variable name="indent">
67       <xsl:text>    </xsl:text>
68     </xsl:variable>
69     <xsl:call-template name="indent">
70       <xsl:with-param name="src">
71         <xsl:call-template name="word-wrap">
72           <xsl:with-param name="src"><xsl:value-of select="description"/></xsl:with-param>
73           <xsl:with-param name="width"><xsl:value-of select="72"/></xsl:with-param>
74         </xsl:call-template>    
75       </xsl:with-param>
76       <xsl:with-param name="indentString">
77         <xsl:text>    </xsl:text>
78       </xsl:with-param>
79       
80     </xsl:call-template>
81     
82     <!-- 
83     <xsl:value-of select="$indent"/>
84     <xsl:call-template name="string-replace">
85       <xsl:with-param name="src"><xsl:value-of select="description"/></xsl:with-param>
86       <xsl:with-param name="from"><xsl:value-of select="$newline"/></xsl:with-param>
87       <xsl:with-param name="to"><xsl:value-of select="$newline"/><xsl:value-of select="$indent"/></xsl:with-param>
88     </xsl:call-template>
89       -->
90     <xsl:value-of select="$newline"/>
91     <xsl:value-of select="$newline"/>  
92   </xsl:template>
93   
94   <xsl:template match="program">
95     <xsl:call-template name="addProgramInfo"/>
96   </xsl:template>
97   
98   <xsl:template match="interesting">
99     <xsl:call-template name="programTable"/>
100     <xsl:apply-templates select="category"/>
101   </xsl:template>
102   
103   <xsl:template match="category">
104     <xsl:text>Category: </xsl:text><xsl:value-of select="@name"/>
105     <xsl:value-of select="$newline"/>
106     <xsl:value-of select="$newline"/>
107     <xsl:call-template name="programTable"/>
108   </xsl:template>
109   
110   <xsl:template match="messages">
111     <xsl:text>Messages</xsl:text>
112     <xsl:value-of select="$newline"/>
113     <xsl:value-of select="$newline"/>
114       <xsl:for-each select="message">
115         <xsl:text>* </xsl:text>
116         <xsl:value-of select="."/>
117         <xsl:value-of select="$newline"/>
118       </xsl:for-each>
119   </xsl:template>
120   
121 </xsl:stylesheet>