<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dw="uri:drivewindow-2">
    <xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01//EN" encoding="ISO-8859-1" indent="yes"/>
    <xsl:template match="dw:Parameters">
        <html lang="en" xlmns="http://www.w3.org/TR/html4/strict.dtd">
            <head>
                <title>Parameters as Commissioned</title>
                <style>
                    @media all
                    {   h1  {   font-family: arial, sans-serif, tahoma;
                                font-size: 24pt;
                            }
                        h2  {   font-family: arial, sans-serif, tahoma;
                                font-size: 24pt;
                            }
                        h3  {   font-family: arial, sans-serif, tahoma;
                                font-size: 12pt;
                            }
                        h4  {   font-family: arial, sans-serif, tahoma;
                                font-size: 12pt;
                                font-weight: bold;
                                padding-left: 1.5em;
                            }
                        body
                            {   font-family: sans-serif, tahoma, arial;
                                font-size: 9pt;
                            }
                        th  {   text-align: left;
                                background-color: gray;
                                padding-right: 1em;
                                padding-left: 1em;
                            }
                        td  {   vertical-align: top;
                                padding-left: 1em;
                            }
                        h3.properties
                            {
                            }
                        table.properties
                            {
                            }
                        h3.application
                            {
                            }
                        table.application
                            {
                            }
                        tr.property
                            {
                            }
                        td.property-name
                            {   padding-left: 3em;
                            }
                        td.property-value
                            {
                            }
                        h3.parameters
                            {   font-size: 16pt;
                            }
                        table.parameter-group
                            {   margin-left: 2em;
                            }
                        th.name
                            {   padding-left: 2em;
                            }
                        th.value
                            {   padding-left: 3em;
                            }
                        tr.parameter
                            {
                            }
                        td.parameter-name
                            {   padding-left: 2em;
                                padding-right: 3em;
                            }
                        td.parameter-value
                            {   padding-left: 3em;
                                padding-right: 1em;
                            }
                        .box
                            {   position: relative;
                                border: solid black 2px;
                                color: black;
                                width: 300px;
                                height: 50px;
                                font-weight: bold;
                                padding-left: 1em;
                                float: left;
                                margin-left. 0px;
                                margin-top: 30px;
                            }
                        #prep
                            {
                            }
                        #appr
                            {
                            }
                        .logo
                            {   margin-top: 30px;
                                margin-bottom: 30px;
                                margin-left: 40%;
                            }
                    }
                </style>
                <xsl:if test="@css">
                    <link rel="stylesheet" type="text/css" href="{@css}" />
                </xsl:if>
            </head>
            <body>
                <img class="logo" src="logo.gif" />
                <h1>Parameters as Commissioned</h1>
                <xsl:apply-templates select="comment" />
                <xsl:apply-templates select="drivelist" />
                <div class="box" id="prep">
                    <p class="prepared">Prep.</p>
                </div>
                <div class="box" id="appr">
                    <p class="approved">Appr.</p>
                </div>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="comment">
        <div>
            <p><xsl:value-of select="." /></p>
        </div>
    </xsl:template>
    <xsl:template match="drivelist">
        <xsl:apply-templates select="drive" />
    </xsl:template>
    <xsl:template match="drive">
        <xsl:choose>
            <xsl:when test="@type='file'">
                <h2><xsl:value-of select="./name" /></h2>
            </xsl:when>
            <xsl:otherwise>
                <h2>Drive: <xsl:value-of select="./name" /></h2>
            </xsl:otherwise>
        </xsl:choose>
            <h3 class="properties">Properties</h3>
            <table class="properties">
        <xsl:apply-templates select="branch[name='Properties']/items" mode="properties" />
            </table>
            <h3 class="application">Application</h3>
             <table class="application">
       <xsl:apply-templates select="branch[name='Application']/branch[name='Properties']/items"  mode="properties" />
            </table>
            <h3 class="parameters">Parameters</h3>
        <xsl:apply-templates select="branch[name='Parameters']/branch[number(substring-before(name,':'))&gt;9 and number(substring-before(name,':'))&lt;=99]" />
    </xsl:template>
    <xsl:template match="drive/branch[name='Properties']/items/item[name='Name']" mode="properties">
        <xsl:if test="../../../@type='file'">
            <xsl:call-template name="property" />
        </xsl:if>
    </xsl:template>
    <xsl:template match="item" name="property" mode="properties">
        <tr class="property">
            <xsl:apply-templates select="name" mode="properties" />
            <xsl:apply-templates select="display-value" mode="properties" />
        </tr>
    </xsl:template>
    <xsl:template match="item/name" mode="properties">
            <td class="property-name"><xsl:value-of select="." /></td>
    </xsl:template>
    <xsl:template match="item/display-value" mode="properties">
            <td class="property-value"><xsl:value-of select="." /></td>
    </xsl:template>
    <xsl:template match="branch[../name='Parameters']">
        <h4><xsl:value-of select="name" /></h4>
        <table class="parameter-group">
            <thead>
                <tr>
                    <th class="name">Name</th>
                    <th class="value">Value</th>
                </tr>
            </thead>
            <tbody>
                <xsl:apply-templates select="items/item[@readable='yes']" />
            </tbody>

        </table>
    </xsl:template>
    <xsl:template match="item">
                <tr class="parameter">
                    <xsl:apply-templates select="name" />
                    <xsl:apply-templates select="display-value" />
                </tr>
    </xsl:template>
    <xsl:template match="item/name">
                    <td class="parameter-name"><xsl:value-of select="." /></td>
    </xsl:template>
    <xsl:template match="item/display-value">
                    <td class="parameter-value"><xsl:value-of select="." /></td>
    </xsl:template>
</xsl:stylesheet>