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