<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"
version="1.0">

  <xsl:output method="xml" 
    media-type="text/html" 
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="DTD/xhtml1-strict.dtd"
	
    cdata-section-elements="script"
	omit-xml-declaration="yes"
    indent="yes"
    encoding="ISO-8859-1"/>
	
<xsl:template match="root">
<html>
<head>
	<title>Campus Arenberg</title>
	 <link rel="stylesheet" type="text/css" media="screen" href="default.css"/>
	 <script language="javascript" type="text/javascript" src="highlighter.es"><xsl:text> </xsl:text></script>
	 <script language="javascript" type="text/javascript" src="sticky.es"><xsl:text> </xsl:text></script>
	  <link rel="author" href="http://users.telenet.be/root-jg/me.html"/>
	  <link rel="home" href="http://student.kuleuven.be/~s0170633/projects/campus3D"/>
	  
	<style media="screen">
	

		#map {
			width: 1350px;
			height: 700px;
			background: url(../map.png) no-repeat;
			margin: 10px auto; padding: 0;
			position: relative;
		}
	
		#map li {margin: 0; padding: 0; list-style: none; display: block; position: absolute;}

		#map a {display: block;}
		

		<xsl:for-each select="//Group[area]">
		#<xsl:call-template name="makeid"/> {<xsl:apply-templates select="area/bbox"/>}<xsl:text/>
		</xsl:for-each>
		
		<xsl:for-each select="//Group[area]">
		#<xsl:call-template name="makeid"/> a {<xsl:apply-templates select="area/bbox/@height" mode="css"/>}<xsl:text/>
		</xsl:for-each>
		
		<xsl:for-each select="//Group[area]">
		#<xsl:call-template name="makeid"/> a:hover, #<xsl:call-template name="makeid"/> a.active, #<xsl:call-template name="makeid"/> a.sticky   {background: url(../collage.png) -<xsl:value-of select="area/highlightmap/@left"/>px -<xsl:value-of select="area/highlightmap/@top"/>px no-repeat}<xsl:text/>
		</xsl:for-each>
		
	</style>
</head>
<body onload="sticky(start().cachedIndex)">
	<h1>Modeled entities of the <a href="http://student.kuleuven.be/~s0170633/projects/campus3D" rel="home">3D campus</a></h1>
	<h2>Data table</h2>
	<table>
		<caption>Available information for modeled entities</caption>
		<thead>
			<tr>
				<th>name</th>
				<th>type</th>
				<th>title</th>
				<th>URL</th>
				<th>capacity</th>
				<th>actions</th>
			</tr>
		</thead>
		<tbody>
			<xsl:apply-templates select="Group" mode="table">
				<xsl:sort select="@name"/>
			</xsl:apply-templates>
		</tbody>
	</table>
	<h2><a name="map">Image map</a></h2>
	<ol id="map">
		<xsl:apply-templates select="Group">
			<xsl:sort select="@name"/>
		</xsl:apply-templates>
	</ol>
</body>
</html>

</xsl:template>

<xsl:template match="Group">
	<li class="{@type}" id="{generate-id()}">
		<xsl:attribute name="id">
			<xsl:call-template name="makeid"/>
		</xsl:attribute>
		<a title="click to make a sticky reference to {@type} {@name}">
			<xsl:attribute name="href">?sticky=<xsl:call-template name="makeid"/>#table_<xsl:call-template name="makeid"/></xsl:attribute>
			<xsl:attribute name="name">map_<xsl:call-template name="makeid"/></xsl:attribute>
			<xsl:value-of select="@name"/>
		</a>
		<xsl:if test="Group">
			<ol>
				<xsl:apply-templates select="Group">
					<xsl:sort select="@name"/>
				</xsl:apply-templates>
			</ol>
		</xsl:if>
	</li>
</xsl:template>

<xsl:template match="bbox">
	<xsl:apply-templates select="@*" mode="css"/>
</xsl:template>

<xsl:template match="@top|@left" mode="css"><xsl:value-of select="local-name()"/>: <xsl:value-of select=". - sum(ancestor::Group[position() &gt; 1]/area/bbox/attribute::*[local-name()=local-name(current())])"/>px;</xsl:template>

<xsl:template match="@height|@width" mode="css"><xsl:value-of select="local-name()"/>: <xsl:value-of select=". - 1"/>px;</xsl:template>

<xsl:template name="makeid">model<xsl:for-each select="ancestor-or-self::Group">
	<xsl:value-of select="translate(@name,' .','_')"/>

</xsl:for-each>

</xsl:template>

<xsl:template match="Group" mode="table">
<tr>
	<th style="padding-left: {count(ancestor::Group)}em">
		<xsl:attribute name="axis"><xsl:call-template name="makeid"/></xsl:attribute>
		<xsl:attribute name="headers">
			<xsl:for-each select="ancestor::Group">
				<xsl:call-template name="makeid"/>
				<xsl:if test="position() != last()"><xsl:text> </xsl:text></xsl:if>
			</xsl:for-each>
		</xsl:attribute>
		<a>
			<xsl:attribute name="name">table_<xsl:call-template name="makeid"/></xsl:attribute>
			<xsl:value-of select="@name"/>
		</a>
	</th>
	<td><xsl:value-of select="@type"/></td>
	<td><xsl:value-of select="@title"/></td>
	<td><a href="{@URL}"><xsl:value-of select="@URL"/></a></td>
	<td><xsl:value-of select="@capacity"/></td>
	<td><a title="make a sticky reference to {@type} {@name}"><xsl:attribute name="href">?sticky=<xsl:call-template name="makeid"/>#map_<xsl:call-template name="makeid"/></xsl:attribute>Sticky</a></td>
</tr>
	
		<xsl:apply-templates select="Group" mode="table">
			<xsl:sort select="@name"/>
		</xsl:apply-templates>
</xsl:template>

</xsl:stylesheet>
