﻿<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:rs='urn:schemas-microsoft-com:rowset'
 	 xmlns:z='#RowsetSchema'
	xmlns:date="http://www.ora.com/XSLTCookbook/NS/dates"
   xml:space="default"
	version="1.0">

	<xsl:param name="category"></xsl:param>
	<xsl:param name="title"></xsl:param>
	<xsl:param name="path"></xsl:param>
	<xsl:param name="url"></xsl:param>
	<xsl:param name="limit" select="100"/>
	<xsl:param name="titleLimit" select="30"/>
	<xsl:strip-space elements="true"/>
	<xsl:output omit-xml-declaration="yes" />

	<xsl:template match='//rs:data'>
		<table class="wccNewsHomeMargin" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td>
					<div class="wccNewsWPTitle">
						Nieuws
					</div>
					<xsl:apply-templates select='z:row'>
						<xsl:sort select="@ows_Datum" order="descending"/>
					</xsl:apply-templates>
					<xsl:variable name="rows" select="z:row" />
					<xsl:variable name='omenom'>
						<xsl:choose>
							<xsl:when test="count($rows) mod 2 = 0">Odd</xsl:when>
							<xsl:otherwise>Even</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>
					<div>
						<xsl:attribute name="class">
							<xsl:value-of select="concat('wccNewsText', $omenom, 'Archive')"/>
						</xsl:attribute>
						<div class="wccNewsTextBody">
							<a class="wccNewsHeader" href="/Nieuwsarchief">
								Nieuwsarchief
								<img src="/_themes/NVKL/nvkl_arrow.gif" />
							</a>
						</div>
					</div>
					<div>
						<xsl:attribute name="class">
							<xsl:value-of select="concat('wccNewsTextBottom', $omenom, 'Archive')"/>
						</xsl:attribute>
					</div>

					<xsl:if test="count($rows) &lt; 1">
						<div class="wccNewsText">
							Er zijn geen nieuwsberichten aanwezig in deze categorie.
						</div>
					</xsl:if>
				</td>
			</tr>
		</table>
	</xsl:template>

	<xsl:template match='z:row'>
		<xsl:variable name="link">
			<xsl:value-of select='concat("/Lists/Nieuws/DispFormWindexCC.aspx?ID=", @ows_ID, "&amp;Source=", $url)'/>
		</xsl:variable>
		<xsl:variable name='omenom'>
			<xsl:choose>
				<xsl:when test="position() mod 2 = 1">Odd</xsl:when>
				<xsl:otherwise>Even</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<div>
			<xsl:attribute name="class">
				<xsl:value-of select="concat('wccNewsText', $omenom)"/>
			</xsl:attribute>
			<div class="wccNewsTextBody">
				<a class="wccNewsHeader">
					<xsl:attribute name="href">
						<xsl:value-of select='$link'/>
					</xsl:attribute>
					<xsl:value-of select='@ows_LinkTitle'/>
				</a>
				<br />
				<span class="wccNewsDate">
					<xsl:call-template name="date:calculate-day-of-the-week">
						<xsl:with-param name="year" select='substring(@ows_Datum,1,4)'/>
						<xsl:with-param name="month" select='substring(@ows_Datum,6,2)'/>
						<xsl:with-param name="day" select='substring(@ows_Datum,9,2)'/>
					</xsl:call-template>
					<xsl:value-of select='number(substring(@ows_Datum,9,2))'/>
					<xsl:variable name="mo">
						<xsl:value-of select='substring(@ows_Datum,6,2)'/>
					</xsl:variable>
					<xsl:choose>
						<xsl:when test="$mo = '01'"> januari </xsl:when>
						<xsl:when test="$mo = '02'"> februari </xsl:when>
						<xsl:when test="$mo = '03'"> maart </xsl:when>
						<xsl:when test="$mo = '04'"> april </xsl:when>
						<xsl:when test="$mo = '05'"> mei </xsl:when>
						<xsl:when test="$mo = '06'"> juni </xsl:when>
						<xsl:when test="$mo = '07'"> juli </xsl:when>
						<xsl:when test="$mo = '08'"> augustus </xsl:when>
						<xsl:when test="$mo = '09'"> september </xsl:when>
						<xsl:when test="$mo = '10'"> oktober </xsl:when>
						<xsl:when test="$mo = '11'"> november </xsl:when>
						<xsl:when test="$mo = '12'"> december </xsl:when>
					</xsl:choose>
					<xsl:value-of select='substring(@ows_Datum,1,4)'/>
				</span>
				<br />
				<div class='wccNewsContent'>
					<xsl:choose>
						<xsl:when test="string-length(@ows_Inleiding) &lt; 1">
							<xsl:value-of select="@ows_Body" disable-output-escaping='yes'/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select='@ows_Inleiding' disable-output-escaping='yes'  />
						</xsl:otherwise>
					</xsl:choose>
				</div>
				<img src="/_themes/NVKL/nvkl_arrow.gif" />
			</div>
		</div>
		<div>
			<xsl:attribute name="class">
				<xsl:value-of select="concat('wccNewsTextBottom', $omenom)"/>
			</xsl:attribute>
		</div>
		<br style="line-height: 12px;" />
	</xsl:template>

	<xsl:template name="date:calculate-day-of-the-week">
		<xsl:param name="date-time"/>
		<xsl:param name="date" select="substring-before($date-time,'T')"/>
		<xsl:param name="year" select="substring-before($date,'-')"/>
		<xsl:param name="month"
				  select="substring-before(substring-after($date,'-'),'-')"/>
		<xsl:param name="day" select="substring-after(substring-after($date,'-'),'-')"/>

		<xsl:variable name="a" select="floor((14 - $month) div 12)"/>
		<xsl:variable name="y" select="$year - $a"/>
		<xsl:variable name="m" select="$month + 12 * $a - 2"/>

		<xsl:variable name="d" select="($day + $y + floor($y div 4) - floor($y div 100) 
    + floor($y div 400) + floor((31 * $m) div 12)) mod 7"/>
		<xsl:choose>
			<xsl:when test="$d = 1">maandag </xsl:when>
			<xsl:when test="$d = 2">dinsdag </xsl:when>
			<xsl:when test="$d = 3">woensdag </xsl:when>
			<xsl:when test="$d = 4">donderdag </xsl:when>
			<xsl:when test="$d = 5">vrijdag </xsl:when>
			<xsl:when test="$d = 6">zaterdag </xsl:when>
			<xsl:when test="$d = 0">zondag </xsl:when>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>