<?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:variable name="printrange" select="/dw:ItemList/itemlist/@printrange" />
    <xsl:template match="dw:ItemList">
        <html lang="en" xlmns="http://www.w3.org/TR/html4/strict.dtd">
            <head>
                <title><xsl:value-of select="@name" /></title>
                <style>
                    @media all
                    {   h1  {   font-family: arial, sans-serif, tahoma;
                                font-size: 16pt;
                            }
                        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;
                            }
                        th.address
                            {   padding-right: 0em;
                            }
                        td.online
                            {   background-color: yellow;
                            }
                    }
                </style>
                <xsl:if test="@css">
                    <link rel="stylesheet" type="text/css" href="{@css}" />
                </xsl:if>
            </head>
            <body>
                <xsl:apply-templates select="name" />
                <xsl:apply-templates select="comment" />
                <xsl:apply-templates select="itemlist" />
            </body>
        </html>
    </xsl:template>
     <xsl:template match="dw:ItemList/name">
        <h1><xsl:value-of select="." /></h1>
    </xsl:template>
    <xsl:template match="comment">
        <div>
            <p class="comment"><xsl:value-of select="." /></p>
        </div>
    </xsl:template>
    <xsl:template match="itemlist">
        <xsl:apply-templates select="items" />
    </xsl:template>
    <xsl:template match="items">
        <table>
            <thead>
                <tr>
                    <th class="name">Name</th>
                    <th class="value">Value</th>
                    <th class="address">OPC&#xA0;Address</th>
                </tr>
            </thead>
            <tbody>
                <xsl:apply-templates select="item" />
            </tbody>
        </table>
    </xsl:template>
    <xsl:template match="item">
        <xsl:if test="$printrange='all' or $printrange='selected' and @selected='yes'">
                <tr>
                    <xsl:apply-templates select="name" />
                    <xsl:apply-templates select="display-value" />
                    <xsl:apply-templates select="opc-address" />
                </tr>
        </xsl:if>
    </xsl:template>
    <xsl:template match="name">
                    <td class="name"><xsl:value-of select="." /></td>
    </xsl:template>
    <xsl:template match="display-value">
        <xsl:choose>
            <xsl:when test="../@on-line='yes'">
                    <td class="online"><xsl:value-of select="." /></td>
            </xsl:when>
            <xsl:otherwise>
                    <td class="value"><xsl:value-of select="." /></td>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="opc-address">
                    <td class="address"><xsl:value-of select="." /></td>
    </xsl:template>
</xsl:stylesheet>