<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="html" media-type="text/html"/>
	<xsl:template match="/">
		<output>
		<xsl:apply-templates/>
		</output>
	</xsl:template>
	<xsl:template match="viewentries">
		<div id="documentbody"> This view contains <xsl:value-of select="@toplevelentries"/> documents.
<table id="viewcontent">
				<thead>
					<xsl:apply-templates mode="header"/>
				</thead>
				<tbody>
					<xsl:apply-templates/>
				</tbody>
			</table>
		</div>
	</xsl:template>
	<xsl:template match="viewentry">
		<!--Each viewentry translates to a row in the table -->
		<tr>
			<xsl:apply-templates/>
		</tr>
	</xsl:template>
	<xsl:template match="entrydata">
		<!-- each entry data is a column in the table -->
		<td>
			<xsl:apply-templates/>
		</td>
	</xsl:template>
	<!-- Here are the 3 data types in single value, number and date time are just copied, would need some facelift -->
	<xsl:template match="text">
		<!--copy the column value -->
		<xsl:element name="a"><xsl:attribute name="href">/AjaxTest.nsf/0/<xsl:value-of select="../../@unid"/></xsl:attribute><xsl:attribute name="id"><xsl:value-of select="../../@unid"/></xsl:attribute>
			<xsl:value-of select="."/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="number">
		<!--copy the column value -->
		<xsl:value-of select="."/>
	</xsl:template>
	<xsl:template match="datetime">
		<!--copy the column value -->
		<xsl:value-of select="."/>
	</xsl:template>
	<!-- the 3 list types -->
	<xsl:template match="textlist">
		<!--display as ordered list -->
		<ol>
			<xsl:apply-templates/>
		</ol>
	</xsl:template>
	<xsl:template match="numberlist">
		<!--display as unordered list -->
		<ul>
			<xsl:apply-templates/>
		</ul>
	</xsl:template>
	<xsl:template match="datetimelist">
		<!--display as unordered list -->
		<ul>
			<xsl:apply-templates/>
		</ul>
	</xsl:template>
	<!-- Here are the 3 data types in multi value, number and date time are just copied, would need some facelift -->
	<xsl:template match="textlist/text">
		<!--copy the column value -->
		<li>
			<xsl:value-of select="."/>
		</li>
	</xsl:template>
	<xsl:template match="numberlist/number">
		<!--copy the column value -->
		<li>
			<xsl:value-of select="."/>
		</li>
	</xsl:template>
	<xsl:template match="datetimelist/datetime">
		<!--copy the column value -->
		<li>
			<xsl:value-of select="."/>
		</li>
	</xsl:template>
	<!-- Here are the templates to create the table header -->
	<xsl:template match="viewentry[position()=1]" mode="header">
		<tr>
			<xsl:apply-templates mode="header"/>
		</tr>
	</xsl:template>
	<xsl:template match="entrydata" mode="header">
		<th>
			<xsl:value-of select="@name"/>
		</th>
	</xsl:template>
	<!-- With the following statement we make sure, that NO unwanted elements are copied into the output -->
	<xsl:template match="*" mode="header"/>
	<xsl:template match="*"/>
</xsl:stylesheet>