<?xml version="1.0" encoding="iso-8859-1" ?>
<!-- /theoffice/equip.xsl
   - Copyright© 2006 - BuckoSoft, Inc.
   - $Id: equip.xsl,v 1.7 2008/02/09 07:51:28 dick Exp $
   -
   - $Log: equip.xsl,v $
   - Revision 1.7  2008/02/09 07:51:28  dick
   - outField becomes outTitleField.
   - outField runs the template without the blue/red background. i.e. not the title line.
   -
   - Revision 1.6  2007/08/26 03:40:11  dick
   - Use a thinline class instead of an empty img for a separator
   -
   - Revision 1.5  2006/12/22 08:02:18  dick
   - Put vendor and model in separate fields.  Display OS in 2 fields (to clean up the line).
   -
   - Revision 1.4  2006/12/20 09:20:36  dick
   - Pass the current field to the template named "outField" which does all the common stuff.
   -
   - Revision 1.3  2006/12/20 09:05:48  dick
   - Display links and strikeouts.
   -
   - Revision 1.2  2006/12/19 08:28:57  dick
   - Looks almost as good as the html version.
   - Still need to fix {strike} for obsolete entries
   - and select a random icon, and urls in text.
   -
   - Revision 1.1  2006/01/20 04:59:32  dick
   - My first XSLT.
   - Rework the equipment page so it uses xsl->xml.
   - This still needs some work, but it's functional.
   -
   -->

<!DOCTYPE xsl:stylesheet [ 
 <!ENTITY nbsp_ "&#160;" >
 ]>

<xsl:stylesheet version="1.0" encoding="iso-8859-1"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<xsl:output method="html" encoding="iso-8859-1" indent="yes"/>

<xsl:template match="ip">
	<xsl:apply-templates/>
	<xsl:if test="not(position()=last())"><br/></xsl:if>
</xsl:template>

<xsl:template match="link" >
	<span class="link">
		<xsl:variable name="src" select="@src" />
		<a href="{$src}">
			<xsl:value-of select="."/>
		</a>
	</span>
</xsl:template>

<xsl:template name="outTitleField">
	<xsl:param name="arg1"/>
	<xsl:choose>
		<xsl:when test="attribute::opt='dead'">
			<td class="dead">
				<xsl:for-each select="$arg1">
					<xsl:choose>
						<xsl:when test="attribute::opt='strike'">
							<strike>
								<xsl:apply-templates/>
							</strike>
						</xsl:when>
						<xsl:otherwise>
							<xsl:apply-templates/>
						</xsl:otherwise>
					</xsl:choose>
					<xsl:if test="not(position()=last())"><br/></xsl:if>
				</xsl:for-each>
			</td>
		</xsl:when>
		<xsl:otherwise>
			<td class="title">
				<xsl:for-each select="$arg1">
					<xsl:choose>
						<xsl:when test="attribute::opt='strike'">
							<strike>
								<xsl:apply-templates/>
							</strike>
						</xsl:when>
						<xsl:otherwise>
							<xsl:apply-templates/>
						</xsl:otherwise>
					</xsl:choose>
					<xsl:if test="not(position()=last())"><br/></xsl:if>
				</xsl:for-each>
			</td>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template name="outField">
	<xsl:param name="arg1"/>
		<td>
			<xsl:for-each select="$arg1">
				<xsl:choose>
					<xsl:when test="attribute::opt='strike'">
						<strike>
							<xsl:apply-templates/>
						</strike>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates/>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:if test="not(position()=last())"><br/></xsl:if>
			</xsl:for-each>
		</td>
</xsl:template>

<xsl:template match="machine">
	<!--  black bar, aname line -->
	<tr bgcolor="black">
		<td class="thinLine" colspan="7">
			<!-- <a name="{<xsl:value-of select="name"}"/>/> -->
			<a name="{name}"/>
			<!--<img src="" width="1" HEIGHT="1" alt=""/>-->
		</td>
	</tr>
	<tr>
		<!-- Displayed name -->
		<xsl:choose>
			<xsl:when test="attribute::opt='dead'">
				<td class="deahName" rowspan="3">
				<xsl:value-of select="name"/>
				</td>
			</xsl:when>
			<xsl:otherwise>
				<td class="titleName" rowspan="3">
				<xsl:value-of select="name"/>
				</td>
			</xsl:otherwise>
		</xsl:choose>

		<!-- CPU -->
		<xsl:call-template name="outTitleField">
			<xsl:with-param name="arg1" select="cpu"/>
		</xsl:call-template>

		<!-- Memory -->
		<xsl:call-template name="outTitleField">
			<xsl:with-param name="arg1" select="memory"/>
		</xsl:call-template>

		<!-- Disk -->
		<xsl:call-template name="outTitleField">
			<xsl:with-param name="arg1" select="disk"/>
		</xsl:call-template>
		

		<!-- Network -->
		<xsl:call-template name="outTitleField">
			<xsl:with-param name="arg1" select="network"/>
		</xsl:call-template>


		<!-- IP Address -->
		<xsl:call-template name="outTitleField">
			<xsl:with-param name="arg1" select="ip"/>
		</xsl:call-template>
		
		<!-- ==== -->
		<!-- Icon -->
		<!-- ==== -->
		<!-- try to pick a random icon. :(
		<xsl:for-each select="icon[fn:current-dateTime() mod count(icon)]">
			<img src="{./@name}" width="{./@width}" height="{./@height}"/>
		</xsl:for-each>
		-->
		<xsl:choose>
			<xsl:when test="attribute::opt='dead'">
				<td class="dead" rowspan="3">
					<center>
						<img src="{icon/@name}" width="{icon/@width}" height="{icon/@height}"/>
					</center>
				</td>
			</xsl:when>
			<xsl:otherwise>
				<td class="title" rowspan="3">
					<center>
						<img src="{icon/@name}" width="{icon/@width}" height="{icon/@height}"/>
					</center>
				</td>
			</xsl:otherwise>
		</xsl:choose>
	</tr>
	
	<!-- Vendor, model, Aquisition date, OS -->
	<tr>

		<td><xsl:value-of select="vendor"/></td>
		<xsl:if test="model != ''">
			<td><xsl:value-of select="model"/></td>
		</xsl:if>
		<xsl:if test="model = ''">
			<td>&#160;</td>
		</xsl:if>
		<!-- 
		<td colspan="2"><xsl:value-of select="vendor"/>&nbsp;
						<xsl:text> </xsl:text>
						<xsl:value-of select="model"/></td>
		-->
		<td><xsl:value-of select="aqdate"/></td>
		<xsl:call-template name="outField">
			<xsl:with-param name="arg1" select="os"/>
		</xsl:call-template>
		<!-- <td colspan="1"><!==unused==></td> -->
	</tr>
	
	<!-- Comments -->
	<tr>
		<td colspan="5">
			<xsl:for-each select="comment">
				<xsl:if test="attribute::date">
					<b><xsl:value-of select="attribute::date"/>:</b>
				</xsl:if>
			
				<xsl:apply-templates/>
				<xsl:if test="not(position()=last())"><br/></xsl:if>
			</xsl:for-each>
		</td>
	</tr>
</xsl:template>
</xsl:stylesheet>
