<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" version="4.0" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/>

	<xsl:template match="/wipereport">
		<table width="100%" border="0">
			<!-- Report header -->
			<tr>
				<td colspan="2">
					<b>QT_TRANSLATE_NOOP("QObject", "Data Sanitization Report (<WiperProductFullNameWithVersion>)")</b>
					<br/>
					<b>QT_TRANSLATE_NOOP("QObject", "Check the data erased according to the following requirements:")</b>
				</td>
			</tr>
			<tr>
				<td valign="center" colspan="2">
					<img src="hline_gray"/>
				</td>
			</tr>
			<!-- Hdd Info -->
			<xsl:apply-templates select="hddinfo"/>
			<!-- General Info -->
			<xsl:apply-templates select="operation"/>
			<!-- Algorithm Info -->
			<xsl:apply-templates select="algorithm"/>
			<!-- Bad Blocks Info -->
			<xsl:apply-templates select="badblocks"/>
			<!-- Dump -->
			<xsl:apply-templates select="sectors"/>
		</table>
	</xsl:template>
	
	<xsl:template match="hddinfo">
		<tr>
			<td colspan="2">
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Hard Disk Info")</b>
				</nobr>
			</td>
		</tr>
		<tr>
			<td valign="center" colspan="2">
				<img src="hline_gray"/>
			</td>
		</tr>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Hard Disk")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="name"/>
			</td>
		</tr>
		<xsl:if test="string-length(serial) != 0">
			<tr>
				<td>
					<nobr>
						<b>QT_TRANSLATE_NOOP("QObject", "Serial Number")</b>
					</nobr>
				</td>
				<td>
					<xsl:value-of select="serial"/>
				</td>
			</tr>
		</xsl:if>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Capacity")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="capasity"/>
			</td>
		</tr>
	</xsl:template>
	
	<xsl:template match="operation">
		<tr>
			<td colspan="2"/>
		</tr>
		<tr>
			<td colspan="2">
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "General Info")</b>
				</nobr>
			</td>
		</tr>
		<tr>
			<td valign="center" colspan="2">
				<img src="hline_gray"/>
			</td>
		</tr>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Object")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="object"/>
			</td>
		</tr>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Free Space Only")</b>
				</nobr>
			</td>
			<td>
				<xsl:choose>
					<xsl:when test="object/@onlyFreeSpace=1">QT_TRANSLATE_NOOP("QObject", "Yes")</xsl:when>
					<xsl:otherwise>QT_TRANSLATE_NOOP("QObject", "No")</xsl:otherwise>
				</xsl:choose>
			</td>
		</tr>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Start Time")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="starttime"/>
			</td>
		</tr>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "End Time")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="finishtime"/>
			</td>
		</tr>
	</xsl:template>
	
	<xsl:template match="algorithm">
		<tr>
			<td colspan="2"/>
		</tr>
		<tr>
			<td colspan="2">
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Algorithm Info")</b>
				</nobr>
			</td>
		</tr>
		<tr>
			<td valign="center" colspan="2">
				<img src="hline_gray"/>
			</td>
		</tr>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Name")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="name"/>
			</td>
		</tr>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Description")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="description"/>
			</td>
		</tr>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Write Pass Count")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="writepass"/>
			</td>
		</tr>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Verify Pass Count")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="verifypass"/>
			</td>
		</tr>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Verify Percent")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="verifyPercent"/>
			</td>
		</tr>
	</xsl:template>
	
	<xsl:template match="badblocks">
		<tr>
			<td colspan="2"/>
		</tr>
		<tr>
			<td colspan="2">
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Bad Blocks Info")</b>
				</nobr>
			</td>
		</tr>
		<tr>
			<td valign="center" colspan="2">
				<img src="hline_gray"/>
			</td>
		</tr>
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Total Bad Blocks")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="count"/>
			</td>
		</tr>
		<xsl:variable name="badblocks" select="list/badblock"/>
		<xsl:choose>
			<xsl:when test="count($badblocks) > 0">
				<tr>
					<td>
						<nobr>
							<b>QT_TRANSLATE_NOOP("QObject", "List")</b>
						</nobr>
					</td>
					<td>
						<xsl:call-template name="badblocklist">
							<xsl:with-param name="badblocks" select="$badblocks"/>
						</xsl:call-template>
					</td>
				</tr>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="badblocklist">
		<xsl:param name="badblocks"/>
		<xsl:choose>
			<xsl:when test="count($badblocks) > 1">
				<xsl:variable name="head" select="$badblocks[1]"/>
				<xsl:variable name="tail">
					<xsl:call-template name="badblocklist">
						<xsl:with-param name="badblocks" select="$badblocks[position() != 1]"/>
					</xsl:call-template>
				</xsl:variable>
				<xsl:choose>
					<xsl:when test="$tail">
						<xsl:value-of select="concat($head, ', ', $tail)"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$head"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:when test="count($badblocks) = 1">
				<xsl:value-of select="$badblocks[1]"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="sectors">
		<tr>
			<td colspan="2"/>
		</tr>
		<tr>
			<td colspan="2">
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Dump")</b>
				</nobr>
			</td>
		</tr>
		<tr>
			<td valign="center" colspan="2">
				<img src="hline_gray"/>
			</td>
		</tr>
		<xsl:apply-templates select="sector"/>
	</xsl:template>
	
	<xsl:template match="sector">
		<tr>
			<td>
				<nobr>
					<b>QT_TRANSLATE_NOOP("QObject", "Sector")</b>
				</nobr>
			</td>
			<td>
				<xsl:value-of select="@address"/>
			</td>
		</tr>

		<tr>
			<td colspan="2">
				<table cellspacing="1">
					<xsl:call-template name="dumper">
						<xsl:with-param name="bytes" select="byte"/>
					</xsl:call-template>
				</table>
			</td>
		</tr>
	</xsl:template>
	
	<xsl:template name="dumper">
		<xsl:param name="bytes"/>
		
		<xsl:if test="$bytes">
			<tr>
				<xsl:for-each select="$bytes[16 >= position()]"><td><xsl:value-of select="."/></td></xsl:for-each>
			</tr>
			
			<xsl:call-template name="dumper">
				<xsl:with-param name="bytes" select="$bytes[position() > 16]"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	
</xsl:stylesheet>
