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