<?xml version="1.0"?>

<!-- the entity declaration below is apparently a bit of a hack, but it
works -->
<!DOCTYPE stylesheet [
<!ENTITY nbsp "<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' disable-output-escaping='yes'>&amp;nbsp;</xsl:text>">
]>

<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	version="1.0">

<xsl:output
	method="html"
/>

<!-- load in the sidebar for the unit we are generating pages for -->
<xsl:include href="http://www.csse.monash.edu.au/courseware/cse3308/xsl/cse3308-sidebar.xsl"/>

<!-- variables for locations of various things, to promote portability. It
should only be necessary to edit here -->
<xsl:variable name="site-url">http://www.csse.monash.edu.au</xsl:variable>
<xsl:variable name="base-url">/courseware/cse3308</xsl:variable>
<xsl:variable name="base-xsl-url">/courseware/cse3308/xsl</xsl:variable>


<!-- variables for colors -->
<xsl:variable name="toc-bgcolor">#E1CEE9</xsl:variable>
<xsl:variable name="sidebar-bgcolor">#E1CEE9</xsl:variable>
<xsl:variable name="message-bgcolor">#F1DEF9</xsl:variable>

<!-- a bunch of attribute sets for the various fonts used -->
<xsl:attribute-set name="page-title-font-attributes">
	<xsl:attribute name="size">+3</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="font-attributes">
	<xsl:attribute name="size">-1</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="section-title-font-attributes">
	<xsl:attribute name="size">+0</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="toc-section-title-font-attributes">
	<xsl:attribute name="size">-1</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="toc-intro-font-attributes">
	<xsl:attribute name="size">-1</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="sidebar-font-attributes">
	<xsl:attribute name="size">-1</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="footer-font-attributes">
	<xsl:attribute name="size">-2</xsl:attribute>
</xsl:attribute-set>

<!-- set up a rule that passes undefined elements (i.e. raw HTML) straight
through -->
<xsl:template match="*">
	<xsl:element name="{name(.)}">
	<xsl:for-each select="@*">
		<xsl:attribute name="{name(.)}">
			<xsl:value-of select="."/>
		</xsl:attribute>
	</xsl:for-each>
	<xsl:apply-templates/>
	</xsl:element>
</xsl:template>

<!-- Now the document-specific rules -->

<!-- need to redefine the <A> tag for the whole tag to be on the same line -->
<xsl:template match="a | A">
	<xsl:element name="{name(.)}">
		<!-- copy through any attributes -->
		<xsl:for-each select="@*">
			<xsl:attribute name="{name(.)}">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
         <xsl:apply-templates/>
</xsl:element>
</xsl:template>

<!-- redefine the <P> tag to ensure justified paragraphs -->
<xsl:template match="p | P">
	<xsl:element name="P">
		<xsl:attribute name="ALIGN">JUSTIFY</xsl:attribute>
	<xsl:apply-templates/>
	</xsl:element>
</xsl:template>

<!-- redefine the <CODE> tag to switch to Courier font-->
<xsl:template match="code | CODE">
	<FONT FACE="COURIER">
	<xsl:apply-templates/>
	</FONT>
</xsl:template>

<!-- redefine the <TD> and <TH> tags to ensure that the contents of table
cells is in the right font -->
<xsl:template match="td | TD | th | TH">
	<xsl:element name="{name(.)}">
		<!-- copy through any attributes -->
		<xsl:for-each select="@*">
			<xsl:attribute name="{name(.)}">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<!-- wrap up the contents in the desired font -->
		<FONT xsl:use-attribute-sets="font-attributes">
		<xsl:apply-templates/>
		</FONT>
	</xsl:element>
</xsl:template>

<!-- The master rule that wraps up the entire document -->
<xsl:template match="courseware-web-page">
	<html>

	<xsl:comment>
	This file was automatically generated from an XML source using an XSL
	stylesheet. Do NOT attempt to edit it. All changes will be lost.
	</xsl:comment>

	<xsl:comment>
	Note that accented character entities are not yet "properly" supported.
	</xsl:comment>

	<head>
	<title><xsl:apply-templates select="header-title"/></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" href="http://assets.monash.edu.au/styles/monash.css" type="text/css" />
	<link rel="stylesheet" href="http://assets.monash.edu.au/styles/print.css" type="text/css" media="print" />
	<link rel="shortcut icon" href="http://www.monash.edu.au/favicon.ico" />
	<xsl:comment>include Information Technology stylesheet</xsl:comment>
	<link rel="stylesheet" href="http://www.infotech.monash.edu.au/assets/styles/infotech.css" type="text/css"/>
	<meta name="author" content="ing,dms" />
	<iwov_metatags docroots='@docRoots' preprocess='$funcref' xsltpath='custom/config/stdMetadataOutput.xsl' mtlookup='0'/>
	</head>

<body>
<table id="layouttable" summary="Layout for page">
	<thead>
		<tr id="pageheaderrow">
			<td colspan="2">
			<xsl:comment>SUBNET DETECTION</xsl:comment>
																									<xsl:comment>C H E C K   I F    B R O W S E R   I S    N E T S C A P E 4   A N D   S E T  NS4  V A R </xsl:comment>
	<!--
 	<script language="javascript" src="http://infotech.monash.edu/assets/scripts/stats.js" ></script>
	-->
<a name="top" />
<xsl:comment>V E R S I O N   F O R   O L D E R   B R O W S E R S </xsl:comment>
 <xsl:comment>V E R S I O N   F O R   N E W E R   B R O W S E R S
 </xsl:comment> <xsl:comment>A C C E S S I B I L I T Y   S E C T I O N
 </xsl:comment>  <div class="spacer"></div> <xsl:comment>S I T E   L O G O
 &amp;  B A N N E R   I M A G E </xsl:comment> <div id="global-header">
 <div id="global-images"> <a href="http://infotech.monash.edu.au"
 accesskey="0"><img id="logo" src="http://infotech.monash.edu.au/assets/images/infotechlogo.gif" width="343" height="79" alt="Information Technology" /> </a> 		

<img id="banner-image" src="http://www.csse.monash.edu.au/~davids/images/TransparentPixel.gif" width="275" height="79" alt=" " title="Decorative Image" />
 	</div> 	<div class="spacer"></div> 	<xsl:comment>G L O B A L   N A V   B A R </xsl:comment> 	<table id="global-nav" summary="Layout for site-wide navigation"> 		<tr> 			<td>
				 					<a
									href="http://www.monash.edu.au">Monash
									Home</a> | <a href="http://infotech.monash.edu.au/">Infotech Home</a> |
				<a href="http://infotech.monash.edu.au/about/">About Us</a> | <a href="http://infotech.monash.edu.au/courses/">Courses</a> | <a href="http://infotech.monash.edu.au/units/">Units</a> | <a href="http://infotech.monash.edu.au/resources/">Support &amp; Services </a> <xsl:comment>| <a href="http://infotech.monash.edu.au/promotion/study-with-us/">Study with Us</a></xsl:comment>| <a href="http://infotech.monash.edu.au/research/">Research</a> <xsl:comment>| <a href="http://infotech.monash.edu.au/communities/">Communities</a></xsl:comment> </td> 		</tr> 	</table>
	<xsl:comment>I N T E R N A L   A N C H O R S </xsl:comment>
	<table id="global-utils" summary="Layout for utility navigation"
	style="width: 100%; vertical-align: middle; horizontal-align: left" >
	<tr align="left">
	<td width="100%" colspan="5">
		<STRONG>
		In this page:&nbsp;&nbsp;
		</STRONG>
		<xsl:apply-templates select="//section/title" mode="toc"/>
	</td>
    </tr>
</table>
		</div>  
			</td>

		</tr>
	</thead>
	<tbody>
		<tr>
			
			<td valign="top">

<!--   E N D    H E A D E R   -->


<H1>
<xsl:apply-templates select="page-title"/>
</H1>


		<!-- SIDEBAR AND BODY OF PAGE -->
		<TABLE CELLPADDING="5">
			<TR>
				<TD VALIGN="TOP">
				<!-- SIDEBAR -->
					<TABLE WIDTH="130" CELLPADDING="10">
						<xsl:call-template name="sidebar"/>
					</TABLE>
				</TD>
				<!-- BODY -->
				<TD VALIGN="TOP">
					<xsl:apply-templates select="body"/>
				</TD>
			</TR>
		</TABLE>
		<!-- END SIDEBAR AND BODY -->
	<!--   B E G I N   F O O T E R   -->
			</td>

		</tr>
	</tbody>
	<tfoot>
		<tr id="pagefooterrow">
			<td colspan="2">
				<!-- A D D   H O R I Z O N T A L   R U L E   F O R   O L D E R   B R O W S E R S  -->
				<table id="footer" width="100%">
		<tr align="center" valign="middle">
		<td>
		Generated from XML source and an
		<A HREF="{$base-url}/xsl/courseware-web-page.xsl">XSL
		stylesheet</A>,
		using <A HREF="http://xmlsoft.org/XSLT/">xsltproc</A>
		<BR/>
		Last modified
		<!-- embedded Javascript to output the last modification date -->
		<script language="javascript" type="text/javascript">
		<xsl:comment>
		<xsl:text>

		function monthString(Month) {

			switch(Month) {
			case 0:
				return 'January';
			case 1:
				return 'February';
			case 2:
				return 'March';
			case 3:
				return 'April';
			case 4:
				return 'May';
			case 5:
				return 'June';
			case 6:
				return 'July';
			case 7:
				return 'August';
			case 8:
				return 'September';
			case 9:
				return 'October';
			case 10:
				return 'November';
			case 11:
				return 'December';
			}
		}

		function takeYear(theDate) {

			x = theDate.getYear();
			var y = x % 100;
			y += (y &lt; 38) ? 2000 : 1900;
			return y;
		}

		function lastMod() {

			if (document.lastModified == 0) {
				return '';
			}
			Modif = new Date(document.lastModified);
			Year = takeYear(Modif);
			Month = Modif.getMonth();
			Day = Modif.getDate();
			Time = Modif.getHours() + ':' + Modif.getMinutes() + ':' + Modif.getSeconds() ;
			return(Day + ' ' + monthString(Month) + ' ' + Year + ' ' + Time);
		}

		// csse web server does not provide a last modifed line in the
		// response
		//document.write(lastMod());
		
		
		</xsl:text>
		</xsl:comment>
		</script>
		<!-- if a last-editor tag is defined, output a byline, linked to a
		mailto: tag if the email attribute is given -->
		<xsl:if test="last-editor">
			by
			<xsl:choose>
				<xsl:when test="last-editor/@email">
					<xsl:element name="A">
						<xsl:attribute name="HREF">
							mailto:<xsl:value-of select="last-editor/@email"/>
						</xsl:attribute>
						<xsl:value-of select="last-editor"/>
					</xsl:element>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="last-editor"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
		<P/>
		</td>
		</tr>
				</table>
				
 
			</td>

		</tr>
	</tfoot>
</table>
</body>
</html>
	<!--   E N D   F O O T E R   -->
</xsl:template>

<!-- need some empty rules to avoid the default rule -->
<xsl:template match="header-title | page-title | address | item | title">
	<xsl:apply-templates/>
</xsl:template>

<!-- everything other than the header information is in the body -->
<xsl:template match="body">
	<xsl:apply-templates/>
</xsl:template>

<!-- everything within contents should be wrapped up in a section, which
has an optional title, and three other possible child elements: itemize,
text and multicol. All these can occur multiple times, and they can be
nested. -->
<xsl:template match="section">
	<P>
	<xsl:apply-templates select="title"/>
	</P>
	<FONT xsl:use-attribute-sets="font-attributes">
	<xsl:apply-templates select="itemize|text|announcements"/>
	</FONT>
</xsl:template>

<xsl:template match="section/title">
	<xsl:element name="A">
		<xsl:attribute name="NAME">
			<xsl:if test="../@name">
				<xsl:value-of select="../@name"/>
			</xsl:if>
			<xsl:if test="not(../@name)">
				<xsl:value-of select="."/>
			</xsl:if>
		</xsl:attribute>
	</xsl:element>
	<FONT xsl:use-attribute-sets="section-title-font-attributes">
	<STRONG>
	<xsl:if test="@href">
		<A HREF="{@href}">
		<xsl:apply-templates/>
		</A>
	</xsl:if>
	<xsl:if test="not(@href)">
		<xsl:apply-templates/>
	</xsl:if>
	</STRONG>
	</FONT>
</xsl:template>
<xsl:template match="section/title" mode="toc">
	<xsl:if test="not(@notoc)">
		<xsl:element name="A">
			<xsl:attribute name="HREF">
				<xsl:if test="../@name">
					#<xsl:value-of select="../@name"/>
				</xsl:if>
				<xsl:if test="not(../@name)">
					#<xsl:value-of select="."/>
				</xsl:if>
			</xsl:attribute>
			<FONT xsl:use-attribute-sets="toc-section-title-font-attributes">
			<xsl:apply-templates/>&nbsp;
			</FONT>
		</xsl:element>
		| 
	</xsl:if>
</xsl:template>

<xsl:template match="section//text">
	<xsl:apply-templates/>
</xsl:template>

<xsl:template match="section//itemize">
	<UL>
		<xsl:apply-templates/>
	</UL>
</xsl:template>

<xsl:template match="itemize/item">
	<LI>
		<xsl:apply-templates/>
	</LI>
</xsl:template>

<xsl:template match="section//itemize/item/title">
	<B>
	<xsl:apply-templates/>
	</B>
	<BR/>
</xsl:template>

<!-- Announcements section. Probably only used on home page -->
<xsl:template match="announcements">
	<TABLE BGCOLOR="{$message-bgcolor}" CELLPADDING="3" STYLE="width: 100%; vertical-align:
	middle; border-collapse: collapse; border: 2px solid">
	<xsl:apply-templates/>
	</TABLE>
</xsl:template>

<xsl:template match="announcement">
	<TR>
	<TD STYLE="border: 1px solid">
	<FONT xsl:use-attribute-sets="font-attributes">
	<xsl:value-of select="date"/>
	<xsl:if test="@newsflash">
		<BR/><BLINK><FONT COLOR="RED">Newsflash!</FONT></BLINK>
	</xsl:if>
	</FONT>
	</TD>
	<TD STYLE="border: 1px solid">
	<FONT xsl:use-attribute-sets="font-attributes">
	<xsl:apply-templates select="message"/>
	</FONT>
	</TD>
	</TR>
</xsl:template>

<xsl:template name="sidebar-entry">
	<xsl:param name="title">Dummy</xsl:param> <!-- placeholder -->
	<xsl:param name="url">Dummy</xsl:param> <!-- placeholder -->
	<TR>
	<TD VALIGN="TOP" WIDTH = "130"  bgcolor="{$sidebar-bgcolor}">
	<A HREF="{$url}"><FONT
	xsl:use-attribute-sets="sidebar-font-attributes"><STRONG><xsl:value-of
	select="$title"/></STRONG></FONT><FONT SIZE="-3"></FONT></A>
	</TD>
	</TR>
</xsl:template>

<xsl:template match="comment">
	<xsl:comment><xsl:apply-templates/></xsl:comment>
</xsl:template>

</xsl:stylesheet>

