1<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
2
3<!-- This style sheet converts any rat-report.xml file.  -->
4
5<xsl:variable name="now" select="current-dateTime()"/>
6
7<xsl:template match="/">
8
9    <html>
10
11    <xsl:comment>Generated at <xsl:value-of select="$now"/></xsl:comment>
12    <head>
13     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
14     <style type="text/css">
15    &lt;!--
16body {margin-top: 0px;font-size: 0.8em;background-color: #F9F7ED;}
17
18h1 {color:red;}
19h2 {color:blue;}
20h3 {color:green;}
21h4 {color:orange;}
22
23/* Table Design */
24
25table,tr,td {text-align:center;font-weight:bold;border:1px solid #000;}
26caption {color:blue;text-align:left;}
27.notes, .binaries, .archives, .standards {width:25%;}
28.notes {background:#D7EDEE;}
29.binaries {background:#D0F2F4;}
30.archives {background:#ABE7E9;}
31.standards {background:#A0F0F4;}
32.licenced, .generated {width:50%;}
33.licenced {background:#C6EBDD;}
34.generated {background:#ABE9D2;}
35.java_note {background:#D6EBC6;}
36.generated_note {background:#C9E7A9;}
37.unknown {width:100%;background:#E92020;}
38.unknown-zero {color:#00CC00;}
39.center{text-align:center;margin:0 auto;}
40--&gt;
41     </style>
42    </head>
43    <body>
44	    <xsl:apply-templates/>
45	    <xsl:call-template name="generated"/>
46    </body>
47    </html>
48</xsl:template>
49
50<xsl:template match="rat-report">
51
52	<h1>Rat Report</h1>
53	<p>This HTML version (yes, it is!) is generated from the RAT xml reports using Saxon9B. All the outputs required are displayed below, similar to the .txt version.
54           This is obviously a work in progress; and a prettier, easier to read and manage version will be available soon</p>
55<div class="center">
56<table id="rat-reports summary" cellspacing="0" summary="A snapshot summary of this rat report">
57<caption>
58Table 1: A snapshot summary of this rat report.
59</caption>
60  <tr>
61    <td colspan="1" class="notes">Notes: <xsl:value-of select="count(descendant::type[attribute::name=&quot;notice&quot;])"/></td>
62    <td colspan="1" class="binaries">Binaries: <xsl:value-of select="count(descendant::type[attribute::name=&quot;binary&quot;])"/></td>
63    <td colspan="1" class="archives">Archives: <xsl:value-of select="count(descendant::type[attribute::name=&quot;archive&quot;])"/></td>
64    <td colspan="1" class="standards">Standards: <xsl:value-of select="count(descendant::type[attribute::name=&quot;standard&quot;])"/></td>
65  </tr>
66  <tr>
67    <td colspan="2" class="licenced">Apache Licensed: <xsl:value-of select="count(descendant::header-type[attribute::name=&quot;AL   &quot;])"/></td>
68    <td colspan="2" class="generated">Generated Documents: <xsl:value-of select="count(descendant::header-type[attribute::name=&quot;GEN  &quot;])"/></td>
69  </tr>
70  <tr>
71    <td colspan="2" class="java_note">Note: JavaDocs are generated and so license header is optional</td>
72    <td colspan="2" class="generated_note">Note: Generated files do not require license headers</td>
73  </tr>
74  <tr>
75<xsl:choose>
76  <xsl:when test="count(descendant::header-type[attribute::name=&quot;?????&quot;]) &gt; 0">
77    <td colspan="4" class="unknown"><xsl:value-of select="count(descendant::header-type[attribute::name=&quot;?????&quot;])"/> Unknown Licenses - or files without a license.</td>
78  </xsl:when>
79  <xsl:otherwise>
80    <td colspan="4" class="unknown-zero"><xsl:value-of select="count(descendant::header-type[attribute::name=&quot;?????&quot;])"/> Unknown Licenses - or files without a license.</td>
81  </xsl:otherwise>
82</xsl:choose>
83  </tr>
84</table>
85</div>
86<hr/>
87	<h3>Unapproved Licenses:</h3>
88
89	<xsl:for-each select="descendant::resource[license-approval/@name=&quot;false&quot;]">
90  <xsl:text>  </xsl:text>
91  <xsl:value-of select="@name"/><br/>
92  <xsl:text>
93</xsl:text>
94</xsl:for-each>
95<hr/>
96
97<h3>Archives:</h3>
98
99<xsl:for-each select="descendant::resource[type/@name=&quot;archive&quot;]">
100 + <xsl:value-of select="@name"/>
101 <br/>
102 </xsl:for-each>
103 <hr/>
104
105 <p>
106	 Files with Apache License headers will be marked AL<br/>
107	 Binary files (which do not require AL headers) will be marked B<br/>
108  Compressed archives will be marked A<br/>
109  Notices, licenses etc will be marked N<br/>
110  </p>
111
112 <xsl:for-each select="descendant::resource">
113  <xsl:choose>
114	 <xsl:when test="license-approval/@name=&quot;false&quot;">!</xsl:when>
115	 <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
116 </xsl:choose>
117 <xsl:choose>
118	 <xsl:when test="type/@name=&quot;notice&quot;">N   </xsl:when>
119	 <xsl:when test="type/@name=&quot;archive&quot;">A   </xsl:when>
120	 <xsl:when test="type/@name=&quot;binary&quot;">B   </xsl:when>
121	 <xsl:when test="type/@name=&quot;standard&quot;"><xsl:value-of select="header-type/@name"/></xsl:when>
122	 <xsl:otherwise>!!!!!</xsl:otherwise>
123 </xsl:choose>
124 <xsl:text>      </xsl:text>
125 <xsl:value-of select="@name"/><br/>
126 <xsl:text>
127 </xsl:text>
128 </xsl:for-each>
129 <hr/>
130
131 <h3>Printing headers for files without AL header...</h3>
132
133 <xsl:for-each select="descendant::resource[header-type/@name=&quot;?????&quot;]">
134
135	 <h4><xsl:value-of select="@name"/></h4>
136  <xsl:value-of select="header-sample"/>
137  <hr/>
138</xsl:for-each>
139<br/>
140
141 <!-- <xsl:apply-templates select="resource"/>
142    <xsl:apply-templates select="header-sample"/>
143    <xsl:apply-templates select="header-type"/>
144    <xsl:apply-templates select="license-family"/>
145    <xsl:apply-templates select="license-approval"/>
146    <xsl:apply-templates select="type"/> -->
147
148</xsl:template>
149
150<xsl:template match="resource">
151	<div>
152		<h3>Resource: <xsl:value-of select="@name"/></h3>
153      <xsl:apply-templates/>
154    </div>
155</xsl:template>
156
157<xsl:template match="header-sample">
158	<xsl:if test="normalize-space(.) != ''">
159  <h4>First few lines of non-compliant file</h4>
160    <p>
161      <xsl:value-of select="."/>
162    </p>
163    </xsl:if>
164    <h4>Other Info:</h4>
165</xsl:template>
166
167<xsl:template match="header-type">
168	Header Type: <xsl:value-of select="@name"/>
169	<br/>
170</xsl:template>
171
172<xsl:template match="license-family">
173	License Family: <xsl:value-of select="@name"/>
174	<br/>
175</xsl:template>
176
177<xsl:template match="license-approval">
178	License Approval: <xsl:value-of select="@name"/>
179	<br/>
180</xsl:template>
181
182<xsl:template match="type">
183	Type: <xsl:value-of select="@name"/>
184	<br/>
185</xsl:template>
186
187<xsl:template name="generated">
188	<p>Generated at <xsl:value-of select="$now"/></p>
189</xsl:template>
190</xsl:transform>