<?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> 
            <table style="margin-left:0px" align="left">
                <!-- Disk number -->
                <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>
                <!-- Type text -->
                <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>
                <!-- Online status -->
                <tr>
                    <td class="label" valign="top">
                        <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HddProperties::OnlineStatusText']" /></span>
                    </td>
                    <td>
                        <xsl:value-of select="PropertyBag/Property[@name='HddProperties::OnlineStatusText']" />
                    </td>
                </tr>
                <!-- Disk GUID, if any-->
                <xsl:if test="string(PropertyBag/Property[@name='HddProperties::DiskGuidText']) != ''">
                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HddProperties::DiskGuidText']" /></span>
                        </td>
                        <td>
                            <xsl:value-of select="PropertyBag/Property[@name='HddProperties::DiskGuidText']" />
                        </td>
                    </tr>
                </xsl:if>
                <!-- MBR id, if any-->
                <xsl:if test="string(PropertyBag/Property[@name='HddProperties::MbrId']) != ''">
                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HddProperties::MbrId']" /></span>
                        </td>
                        <td>
                            <xsl:variable name="MbrIdHex">
                            <xsl:call-template name="convert-to-hex">
                                <xsl:with-param name="number" select="PropertyBag/Property[@name='HddProperties::MbrId']" />
                            </xsl:call-template>
                            </xsl:variable>
                            <nobr>0x<xsl:value-of select="$MbrIdHex" /></nobr>
                        </td>
                    </tr>
                </xsl:if>
                <!--Model number-->
                <tr>
                    <td class="label" valign="top" >
                        <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HddProperties::ModelNumber']" /></span>
                    </td>
                    <td>
                        <xsl:value-of select="PropertyBag/Property[@name='HddProperties::ModelNumber']" />
                    </td>
                </tr>
                <!--Serial number, if any-->
                <xsl:if test="string(PropertyBag/Property[@name='HddProperties::SerialNumber']) != ''">
                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HddProperties::SerialNumber']" /></span>
                        </td>
                        <td>
                            <xsl:value-of select="PropertyBag/Property[@name='HddProperties::SerialNumber']" />
                        </td>
                    </tr>
                </xsl:if>
                <!--Firmware revision, if any-->
                <xsl:if test="string(PropertyBag/Property[@name='HddProperties::FirmwareRevision']) != ''">
                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HddProperties::FirmwareRevision']" /></span>
                        </td>
                        <td>
                            <xsl:value-of select="PropertyBag/Property[@name='HddProperties::FirmwareRevision']" />
                        </td>
                    </tr>
                </xsl:if>
                <!-- Short and full size -->
                <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>
                <!-- Short and full physical size -->
                <tr>
                    <td class="label" valign="top">
                        <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HddProperties::ShortPhysicalSizeText']" /></span>
                    </td>
                    <td>
                        <xsl:value-of select="PropertyBag/Property[@name='HddProperties::ShortPhysicalSizeText']" /><br/>
                        <xsl:value-of select="PropertyBag/Property[@name='HddProperties::LongPhysicalSizeText']" /><br />
                        <xsl:value-of select="PropertyBag/Property[@name='HddProperties::PhysicalSizeInSectorsText']" />
                    </td>
                </tr>
                <!-- Number of cylinders-->
                <tr>
                    <td class="label" valign="top">
                        <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HddProperties::NumberOfCylinders']" /></span>
                    </td>
                    <td>
                        <xsl:variable name="CylDec" select="PropertyBag/Property[@name='HddProperties::NumberOfCylinders']" />
                        <xsl:variable name="CylHex">
                            <xsl:call-template name="convert-to-hex">
                                <xsl:with-param name="number" select="$CylDec" />
                            </xsl:call-template>
                        </xsl:variable>
                        <nobr>0x<xsl:value-of select="$CylHex" /></nobr>&#160;<nobr>(<xsl:value-of select="$CylDec" />)</nobr>
                    </td>
                </tr>
                <!-- Number of heads -->
                <tr>
                    <td class="label" valign="top">
                        <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HddProperties::NumberOfHeads']" /></span>
                    </td>
                    <td>
                        <xsl:variable name="HeadsDec" select="PropertyBag/Property[@name='HddProperties::NumberOfHeads']" />
                        <xsl:variable name="HeadsHex">
                            <xsl:call-template name="convert-to-hex">
                                <xsl:with-param name="number" select="$HeadsDec" />
                            </xsl:call-template>
                        </xsl:variable>
                        <nobr>0x<xsl:value-of select="$HeadsHex" /></nobr>&#160;<nobr>(<xsl:value-of select="$HeadsDec" />)</nobr>
                    </td>
                </tr>
                <!-- Sectors per track -->
                <tr>
                    <td class="label" valign="top">
                        <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='HddProperties::SectorsPerTrack']" /></span>
                    </td>
                    <td>
                        <xsl:variable name="SectorsDec" select="PropertyBag/Property[@name='HddProperties::SectorsPerTrack']" />
                        <xsl:variable name="SectorsHex">
                            <xsl:call-template name="convert-to-hex">
                                <xsl:with-param name="number" select="$SectorsDec" />
                            </xsl:call-template>
                        </xsl:variable>
                        <nobr>0x<xsl:value-of select="$SectorsHex" /></nobr>&#160;<nobr>(<xsl:value-of select="$SectorsDec" />)</nobr>
                    </td>
                </tr>
                <!-- Sectors size -->
                <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>
                <!-- VIM properties begin -->
                <xsl:if test="PropertyBag/Property[@name='HddProperties::IsVirtual'] != 'false'">
                    <tr>
                        <td colspan="2"><hr /></td>
                    </tr>
                    <!--Disk file path-->
                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='VirtualHddProperties::DiskFilePath']" /></span>
                        </td>
                        <td>
                            <xsl:value-of select="translate(string(PropertyBag/Property[@name='VirtualHddProperties::DiskFilePath']), '/', '\\')" />
                        </td>
                    </tr>
                    <!--Virtual vendor name-->
                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='VirtualHddProperties::VendorName']" /></span>
                        </td>
                        <td>
                            <xsl:value-of select="PropertyBag/Property[@name='VirtualHddProperties::VendorName']" />
                        </td>
                    </tr>
                    <!--Adapter name-->
                    <xsl:if test="string(PropertyBag/Property[@name='VirtualHddProperties::AdapterName']) != ''">
                        <tr>
                            <td class="label" valign="top">
                                <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='VirtualHddProperties::AdapterName']" /></span>
                            </td>
                            <td>
                                <xsl:value-of select="PropertyBag/Property[@name='VirtualHddProperties::AdapterName']" />
                            </td>
                        </tr>
                    </xsl:if>
                    <!--Attributes-->
                    <tr>
                        <td class="label" valign="top">
                            <span style="color: #7c7d7d;"><xsl:value-of select="PropertyList/Property[@propname='VirtualHddProperties::AttributesText']" /></span>
                        </td>
                        <td>
                            <xsl:value-of select="PropertyBag/Property[@name='VirtualHddProperties::AttributesText']" />
                        </td>
                    </tr>
                </xsl:if>
                <!-- VIM properties end -->
            </table>
        </body>
    </html>
</xsl:template>
</xsl:stylesheet>
