﻿<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:import href="report_common.xslt"/>
	<xsl:variable name="localization" select="document('localization.xml')/strings/group[@name='report']/string"/>
	<xsl:variable name="spam_cates_TMASE" select="document('localization.xml')/strings/group[@name='SpamCate_TMASE']/string"/>
	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
	<xsl:template match="/">
		<!--||Spam Summary ||-->
		<xsl:variable name="spam_summary_data" select="/report//dataset/data[@name='report_item_spam_summary']"/>
		<xsl:variable name="total_message" select="$spam_summary_data/datarow/@total_message_count"/>
		<xsl:variable name="spam_detected" select="$spam_summary_data/datarow/@spam_detected_count"/>
		<xsl:variable name="phish_detected" select="$spam_summary_data/datarow/@phish_detected_count"/>
		<xsl:variable name="false_positive" select="$spam_summary_data/datarow/@false_positive_count"/>
		<!--||Spam message Graph||-->
		<tr>
			<td class="tableheadergreyM">Spam Detection Graph</td>
		</tr>
		<tr>
			<td class="border2" align="center">
				<img alt="Spam graph">
					<xsl:attribute name="src">images/<xsl:value-of select="/report/dataset/data[starts-with(@name,'report_item_spam_graph')]/@name"/>.png</xsl:attribute>
				</img>
			</td>
		</tr>
		<!--||Top Reported False Positives||-->
		<xsl:variable name="top_fp_sender_data" select="/report/dataset/data[@name='report_item_spam_top_false_positive_sender']"/>
		<tr>
			<td class="border2">
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
		</tr>
		<tr id="FalsePositives_Title">
			<td class="tableheader">Top Reported False Positives</td>
		</tr>
		<tr id="FalsePositives_Content">
			<td>
				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="border2">
					<tr>
						<td class="grey" height="20">Sender</td>
						<td class="grey-end" align="right">Total</td>
					</tr>
					<!--|| Main Loop ||-->
					<xsl:for-each select="$top_fp_sender_data//datarow">
						<tr>
							<td height="20">
								<xsl:attribute name="class">data<xsl:value-of select="((position()+1) mod 2) + 1"/>b</xsl:attribute>
								<xsl:value-of select="@fp_sender"/>
							</td>
							<td align="right">
								<xsl:attribute name="class">data<xsl:value-of select="((position()+1) mod 2) + 1"/></xsl:attribute>
								<xsl:value-of select="@fp_count"/>
							</td>
						</tr>
					</xsl:for-each>
					<!-- ************* -->
				</table>
			</td>
		</tr>
		<!--||Spam detection by category||-->
		<!--xsl:variable name="spam_category_data" select="/report//dataset/data[@name='report_item_spam_categories']"/-->
		<!--tr><td class="tableheader">Spam Detection by Category</td></tr-->
		<!--
    <xsl:variable name="data-nodes" select="/report/dataset/data[@name='report_item_spam_categories']/datarow[starts-with(@categories, 'AS_CAT_')]"/>
		<xsl:variable name="total_count" select="sum($data-nodes/@spam_count)"/>
		<tr>
			<td class="border2">
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
		</tr>
		<tr>
			<td class="tableheader">
				<xsl:value-of select="$localization[@name='report_item_spam_categories']"/>
			</td>
		</tr>
		<tr>
			<td>
				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="border2">
					<thead>
						<tr>
							<td width="35%" class="grey">
								<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
							</td>
							<td width="35%" class="grey" align="right">Total</td>
							<td width="30%" class="grey-end" align="right">Percentage of Spam Detected</td>
						</tr>
					</thead>
					<tbody>
						<xsl:for-each select="$data-nodes">
							<tr>
								<td width="35%">
									<xsl:attribute name="class">data<xsl:value-of select="((position()+1) mod 2) + 1"/>b</xsl:attribute>
									<xsl:value-of select="$spam_cates_TMASE[@name=current()/@categories]"/>
								</td>
								<td width="35%" align="right">
									<xsl:attribute name="class">data<xsl:value-of select="((position()+1) mod 2) + 1"/></xsl:attribute>
									<xsl:value-of select="@spam_count"/>
								</td>
								<td width="30%" align="right">
									<xsl:attribute name="class">data<xsl:value-of select="((position()+1) mod 2) + 1"/></xsl:attribute>
									<xsl:call-template name="format_percentage">
										<xsl:with-param name="numerator" select="@spam_count"/>
										<xsl:with-param name="denominator" select="$total_count"/>
									</xsl:call-template>
								</td>
							</tr>
						</xsl:for-each>
					</tbody>
				</table>
			</td>
		</tr>
    -->
		<tr>
			<td class="border2">
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
		</tr>
	</xsl:template>
</xsl:stylesheet>
