<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
	<html>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<head>
			<title>	Library Homepage URL </title>
			<style>
				body {background-color: #FFFFD0; font: lucinda grande 10pt; color: #660000;
				  line-height: 1.5;}
				h1{color: #660000;} h2{font-size: 11pt; color: #FFE87C;}
				th {background-color:#660000; color: #FFE87C; font-size:11pt;}
				.EN {background-color:#FFCC00;}
			</style>
		</head>
		<body>
			<h1> Library Homepage URL </h1>
			<p> (English version website URLs are highlighted in the table below.) </p>
			<table border="1" cellpadding="5">
				<tr>
					<th><strong>Library Name</strong></th>
					<th><strong>Websiite</strong></th>
				</tr>
	<xsl:apply-templates/>
			</table>
		</body>
	</html>
</xsl:template>

<!-- count(node-set) counts the current node.  so count(url)=1 for each library
	but count(url/*) counts the number of child nodes under url. -->
	
<xsl:template match="library">
	<xsl:variable name="rowcount" select="count(url/*)"/>
	<tr>
		<td rowspan="{$rowcount}">
			<strong><xsl:value-of select="name/nameEn"/></strong>
		</td>
		<td><xsl:value-of select="url/urlMain"/></td>
	</tr>
<!-- the use of xsl:for-each -->
	<xsl:for-each select="url/urlOther">
		<tr>
			<td class="{@language}">
				<xsl:value-of select="."/>
				<xsl:text>   </xsl:text>
				(<xsl:value-of select="@language"/>)
			</td>
		</tr>
	</xsl:for-each>
	
<!-- a failed if statement attempt. html doesn't do loops.
	<xsl:if test="(count(url/urlOther)- position()) >=0">
		<tr>
			<td>
				<xsl:value-of select="url/urlOther"/>
			</td>
		</tr>
	</xsl:if> -->

</xsl:template>
</xsl:stylesheet>