<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                version="1.0">

    <xsl:output method="html"
                version="4.0"
                encoding="UTF-8"
                omit-xml-declaration="yes"
                indent="yes" />

    <xsl:variable name="hexchars" select="'0123456789ABCDEF'" />

    <xsl:template name="convert-to-hex">
        <xsl:param name="number" />
        <xsl:param name="result" />
        <xsl:variable name="to-base-digit" select="substring($hexchars,$number mod 16 + 1,1)" />
        <xsl:choose>
            <xsl:when test="$number >= 16">
                <xsl:call-template name="convert-to-hex">
                    <xsl:with-param name="number" select="floor($number div 16)" />
                    <xsl:with-param name="result" select="concat($to-base-digit,$result)" />
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="concat($to-base-digit,$result)" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <xsl:template match="/Root">

    <html>
        <body>
            <xsl:variable name="FSName" select="PropertyBag/Property[@name='PartitionProperties::FileSystemRawText']" />
            <xsl:variable 
                name="HasFSProps" 
                select="$FSName != 'UNKNOWN' and 
                    $FSName != 'INVALID' and 
                    $FSName != 'FREE' and 
                    $FSName != 'UNFORM' and 
                    $FSName != 'LSWAP' and
                    $FSName != 'LSWAP1' and
                    $FSName != 'BACKUPCAPSULE' and
                    $FSName != 'SYSRESERVED' and
                    $FSName != 'Bitlocked'"
            /> 

            <!--<table style="margin-left:0px" width="100%" align="left">-->
            <table style="margin-left:0px" align="left">
                <xsl:if test="boolean($HasFSProps)">
                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::LabelDecorated']" /></span>
                        </td>
                        <td>
                            <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::LabelDecorated']" />
                        </td>
                    </tr>
                </xsl:if>

                <xsl:if test="$FSName != 'INVALID'">
                    <xsl:if test="$FSName != 'SYSRESERVED'">
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::FileSystem']" /></span>
                            </td>
                            <td>
                                <font>
                                    <xsl:attribute name="color">
                                        <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::FileSystemColor']" />
                                    </xsl:attribute>
                                    <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::FileSystem']" />
                                </font>
                            </td>
                        </tr>
                    </xsl:if>

                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HdmCommonProperties::TypeText']" /></span>
                        </td>
                        <td>
                            <xsl:value-of select="PropertyBag/Property[@name='HdmCommonProperties::TypeText']" />
                        </td>
                    </tr>

                    <xsl:if test="string(PropertyBag/Property[@name='PartitionProperties::PartitionGuidText']) != ''">
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::PartitionGuidText']" /></span>
                            </td>
                            <td>
                                <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::PartitionGuidText']" />
                            </td>
                        </tr>
                    </xsl:if>

                    <xsl:if test="string(PropertyBag/Property[@name='PartitionProperties::PartitionTypeGuidText']) != ''">
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::PartitionTypeGuidText']" /></span>
                            </td>
                            <td>
                                <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::PartitionTypeGuidText']" />
                            </td>
                        </tr>
                    </xsl:if>

                    <xsl:if test="string(PropertyBag/Property[@name='PartitionProperties::LvmPhysicalUuid']) != ''">
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;"><b><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::LvmPhysicalUuid']" /></b></span>
                            </td>
                            <td>
                                <nobr><xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::LvmPhysicalUuid']" /></nobr>
                            </td>
                        </tr>
                    </xsl:if>


                    <xsl:if test="string(PropertyBag/Property[@name='PartitionProperties::LvmLogicalUuid']) != ''">
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::LvmLogicalUuid']" /></span>
                            </td>
                            <td>
                                <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::LvmLogicalUuid']" />
                            </td>
                        </tr>
                    </xsl:if>

                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HdmCommonProperties::ShortSizeText']" /></span>
                        </td>
                        <td>
                            <xsl:value-of select="PropertyBag/Property[@name='HdmCommonProperties::ShortSizeText']" /><br/>
                            <xsl:value-of select="PropertyBag/Property[@name='HdmCommonProperties::LongSizeText']" />
                        </td>
                    </tr>
                    <!--<tr>
                        <td />
                        <td width="100%">
                            <xsl:value-of select="PropertyBag/Property[@name='HdmCommonProperties::LongSizeText']" />
                        </td>
                    </tr>-->
                </xsl:if>

                <xsl:if test="boolean($HasFSProps)">
                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::ShortDataSizeText']" /></span>
                        </td>
                        <td>
                            <xsl:value-of select="concat(PropertyBag/Property[@name='PartitionProperties::ShortDataSizeText'],' (',PropertyBag/Property[@name='PartitionProperties::UsedSpacePercent'],'%)')" /><br/>
                            <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::LongDataSizeText']" /><br />
                            <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::DataSizeInSectorsText']" />
                        </td>
                    </tr>
                    <!--<tr>
                        <td />
                        <td width="100%">
                            <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::LongDataSizeText']" />
                        </td>
                    </tr>-->
                    <!--<tr>
                        <td />
                        <td width="100%">
                            <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::DataSizeInSectorsText']" />
                        </td>
                    </tr>-->
                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::ShortFreeSizeText']" /></span>
                        </td>
                        <td>
                            <xsl:value-of select="concat(PropertyBag/Property[@name='PartitionProperties::ShortFreeSizeText'],' (',PropertyBag/Property[@name='PartitionProperties::FreeSpacePercent'],'%)')" /><br/>
                            <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::LongFreeSizeText']" />
                        </td>
                    </tr>
                    <!--<tr>
                        <td />
                        <td width="100%">
                            <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::LongFreeSizeText']" />
                        </td>
                    </tr>-->
                </xsl:if>

                <!--fsi-->
                <xsl:choose>
                    <xsl:when test="$FSName='FAT16'">
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::RootSize']" /></span>
                            </td>
                            <td>
                                <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::RootSize']" />
                            </td>
                        </tr>
                    </xsl:when> 

                    <xsl:when test="$FSName='NTFS'">
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::NtfsVersionText']" /></span>
                            </td>
                            <td>
                                <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::NtfsVersionText']" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HdmCommonProperties::SectorSize']" /></span>
                            </td>
                            <td>
                                <xsl:value-of select="PropertyBag/Property[@name='HdmCommonProperties::SectorSize']" />
                            </td>
                        </tr>
                    </xsl:when>
                    <xsl:when test="$FSName='SYSRESERVED'">
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;">QT_TRANSLATE_NOOP("QObject", "File system type")</span>
                            </td>
                            <td>
                                <p>
                                    QT_TRANSLATE_NOOP("QObject", "System reserved partition")
                                </p>
                                <p>
                                    QT_TRANSLATE_NOOP("QObject", "This partition is a specially secured place (with its own independent system layout) on the hard disk created and managed by operating system for internal usage.")
                                </p>
                            </td>
                        </tr>
                    </xsl:when>

                    <xsl:when test="$FSName='INVALID'">
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;">QT_TRANSLATE_NOOP("QObject", "File system type")</span>
                            </td>
                            <td>
                                <p>
                                    QT_TRANSLATE_NOOP("QObject", "Unknown")
                                </p>
                                <p>
                                    QT_TRANSLATE_NOOP("QObject", "Program has discovered problems with this partition. It must have been caused by an incorrect geometry. In order to resolve the issue, please collect LOG-files and send them to our Support Team")
                                </p>
                            </td>
                        </tr>
                    </xsl:when>
                </xsl:choose>

                <!--adv-->
                <tr>
                    <td class="label" valign="top">
                        <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HdmCommonProperties::HddNumber']" /></span>
                    </td>
                    <td>
                        <xsl:value-of select="PropertyBag/Property[@name='HdmCommonProperties::HddNumber']" />
                    </td>
                </tr>
                <tr>
                    <td class="label" valign="top">
                        <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::PartitionNumber']" /></span>
                    </td>
                    <td>
                        <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::PartitionNumber']" />
                    </td>
                </tr>

                <xsl:if test="$FSName != 'UNKNOWN' and $FSName != 'INVALID' and $FSName != 'UNFORM' and $FSName != 'FREE' and $FSName != 'SYSRESERVED'"> 

                    <xsl:if test="string-length(PropertyBag/Property[@name='PartitionProperties::MbrTypeText']) != 0">
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::MbrTypeText']" /></span>
                            </td>
                            <td>
                                <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::MbrTypeText']" />
                            </td>
                        </tr>
                    </xsl:if>

                    <xsl:if test="$FSName != 'EXTENDED'">
                    	<xsl:if test="string-length(PropertyBag/Property[@name='PartitionProperties::SerialNumber']) != 0">
                            <tr>
                                <td class="label" valign="top">
                                    <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::SerialNumber']" /></span>
                                </td>
                                <td>
                                    <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::SerialNumber']" />
                                </td>
                            </tr>
                    	</xsl:if>
                    </xsl:if>

                    <xsl:if test="$FSName != 'EXTENDED' and $FSName != 'BACKUPCAPSULE'">
                        <xsl:if test="string-length(PropertyBag/Property[@name='PartitionProperties::BootSize']) != 0">
                            <tr>
                                <td class="label" valign="top">
                                    <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::BootSize']" /></span>
                                </td>
                                <td>
                                    <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::BootSize']" />
                                </td>
                            </tr>
                        </xsl:if>
                        
                        <xsl:if test="string-length(PropertyBag/Property[@name='PartitionProperties::ClusterSize']) != 0">
                            <tr>
                                <td class="label" valign="top">
                                    <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='PartitionProperties::ClusterSize']" /></span>
                                </td>
                                <td>
                                    <xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::ClusterSize']" />
                                </td>
                            </tr>
                        </xsl:if>
                    </xsl:if>
                </xsl:if>
            </table> 

           <br /> 

            <!--<table cellspacing="0" cellpadding="0" align="left">-->
            <table style="margin-left:0px" align="left">
                <tr>
                    <td/>
                    <td class="label" align="right">
                        <span style="color: #7c7d7d;">
                            QT_TRANSLATE_NOOP("QObject", "Sector No:")
                        </span>
                    </td>
                    <td class="label" align="right">
                        <span style="color: #7c7d7d;">
                            QT_TRANSLATE_NOOP("QObject", "Cyl:")
                        </span>
                    </td>
                    <td class="label" align="right">
                        <span style="color: #7c7d7d;">
                            QT_TRANSLATE_NOOP("QObject", "Hd:")
                        </span>
                    </td>
                    <td class="label" align="right">
                        <span style="color: #7c7d7d;">
                            QT_TRANSLATE_NOOP("QObject", "Sec:")
                        </span>
                    </td>
                    <!--<td width="100%"/>-->
                </tr>
                <tr>
                    <td class="label">
                        <span style="color: #7c7d7d;">
                            <nobr><xsl:value-of select="PropertyList/Property[@propname='HdmCommonProperties::StartInSectors']" /></nobr>
                        </span>
                    </td>
                    <td align="right">
                        <xsl:variable name="StartSecDec" select="PropertyBag/Property[@name='HdmCommonProperties::StartInSectors']" />
                        <xsl:variable name="StartSecHex">
                            <xsl:call-template name="convert-to-hex">
                                <xsl:with-param name="number" select="$StartSecDec" />
                            </xsl:call-template>
                        </xsl:variable>
                        <nobr>0x<xsl:value-of select="$StartSecHex" /></nobr>&#160;<nobr>(<xsl:value-of select="$StartSecDec" />)</nobr>
                    </td>
                    <td align="right">
                        <nobr><xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::StartCylinderInChs']" /></nobr>
                    </td>
                    <td align="right">
                        <nobr><xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::StartHeadInChs']" /></nobr>
                    </td>
                    <td align="right">
                        <nobr><xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::StartSectorInChs']" /></nobr>
                    </td>
                    <!--<td width="100%" />-->
                </tr>

                <tr>
                    <td class="label">
                        <span style="color: #7c7d7d;">
                            <nobr><xsl:value-of select="PropertyList/Property[@propname='HdmCommonProperties::EndInSectors']" /></nobr>
                        </span>
                    </td>
                    <td align="right">
                        <xsl:variable name="EndSecDec" select="PropertyBag/Property[@name='HdmCommonProperties::EndInSectors']" />
                        <xsl:variable name="EndSecHex">
                            <xsl:call-template name="convert-to-hex">
                                <xsl:with-param name="number" select="$EndSecDec" />
                            </xsl:call-template>
                        </xsl:variable>
                        <nobr>0x<xsl:value-of select="$EndSecHex" /></nobr>&#160;<nobr>(<xsl:value-of select="$EndSecDec" />)</nobr>
                    </td>
                    <td align="right">
                        <nobr><xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::EndCylinderInChs']" /></nobr>
                    </td>
                    <td align="right">
                        <nobr><xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::EndHeadInChs']" /></nobr>
                    </td>
                    <td align="right">
                        <nobr><xsl:value-of select="PropertyBag/Property[@name='PartitionProperties::EndSectorInChs']" /></nobr>
                    </td>
                    <!--<td width="100%" />-->
                </tr>

                <tr>
                    <td class="label">
                        <span style="color: #7c7d7d;">
                            <nobr>QT_TRANSLATE_NOOP("QObject", "Hard disk geometry:")</nobr>
                        </span>
                    </td>
                    <td align="right" />
                    <td align="right">
                        <nobr><xsl:value-of select="PropertyBag/Property[@name='HddProperties::NumberOfCylinders']" /></nobr>
                    </td>
                    <td align="right">
                        <nobr><xsl:value-of select="PropertyBag/Property[@name='HddProperties::NumberOfHeads']" /></nobr>
                    </td>
                    <td align="right">
                        <nobr><xsl:value-of select="PropertyBag/Property[@name='HddProperties::SectorsPerTrack']" /></nobr>
                    </td>
                    <!--<td width="100%" />-->
                </tr>
            </table>
        </body>
    </html>

</xsl:template>
</xsl:stylesheet>


