added unit tests for schema validation and a test for not wellformed XML.
[utils] / support / general / src / test / resources / org / wamblee / xml / reportToHtml.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
4 <xsl:output method="xml"/>
5     <xsl:template match="report">
6         <html>
7             <head>
8                 <title>KiSS crawler report</title>
9             </head>
10             <body>
11                 <h1>KiSS crawler report</h1>
12                 <xsl:apply-templates select="recorded"/>
13                 <xsl:if test="count(interesting) > 0">
14                     <h2>Possibly interesting programs</h2>
15                     <xsl:apply-templates select="interesting"/>
16                 </xsl:if>
17                 <xsl:if test="count(//program) = 0">
18                     <xsl:text>No suitable programs found </xsl:text>
19                 </xsl:if>
20             </body>
21         </html>
22
23     </xsl:template>
24
25     <xsl:template name="programTable">
26         <p>
27         <table align="left" cellpadding="5">
28             <!-- 
29             <tr align="left">
30                 <th align="left">Time</th>
31                 <th align="left">Channel</th>
32                 <th align="left">Program</th>
33             </tr>
34             -->
35             <xsl:apply-templates select="program"/>
36         </table>
37         <br clear="left"/>
38         </p>
39     </xsl:template>
40
41     <xsl:template match="recorded">
42         <h2>
43             <xsl:choose>
44                 <xsl:when test="@result = 'OK'">
45                     <xsl:text>Successfully recorded programs </xsl:text>
46                     <xsl:call-template name="programTable"/>
47                 </xsl:when>
48                 <xsl:when test="@result = 'DUPLICATE'">
49                     <xsl:text>Already recorded programs</xsl:text>
50                     <xsl:call-template name="programTable"/>
51                 </xsl:when>
52                 <xsl:when test="@result = 'CONFLICT'">
53                     <xsl:text>Conflicts with other recorded programs</xsl:text>
54                     <xsl:call-template name="programTable"/>
55                 </xsl:when>
56                 <xsl:when test="@result='ERROR'">
57                     <xsl:text>Programs that could not be recorded for
58                     technical reasons.</xsl:text>
59                     <xsl:call-template name="programTable"/>
60                 </xsl:when>
61             </xsl:choose>
62         </h2>
63     </xsl:template>
64
65     <xsl:template name="addProgramInfo">
66         <tr align="left">
67             <td><xsl:value-of select="interval/begin"/> - <xsl:value-of select="interval/end"/>: <strong>
68                     <xsl:value-of select="name"/>
69                 </strong> (<xsl:value-of select="channel"/>/<xsl:value-of select="keywords"/>)</td>
70
71         </tr>
72         <tr>
73             <td>
74                 <blockquote>
75                         <font size="-1">
76                             <xsl:value-of select="description"/>
77                         </font>
78                 </blockquote>
79             </td>
80
81
82         </tr>
83     </xsl:template>
84
85     <xsl:template match="program">
86         <xsl:call-template name="addProgramInfo"/>
87     </xsl:template>
88
89     <xsl:template match="interesting">
90         <xsl:call-template name="programTable"/>
91         <xsl:apply-templates select="category"/>
92     </xsl:template>
93
94     <xsl:template match="category">
95         <h3>Category: <xsl:value-of select="@name"/></h3>
96         <xsl:call-template name="programTable"/>
97     </xsl:template>
98 </xsl:stylesheet>
99