﻿<?xml version='1.0' encoding='utf-8'?>
<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="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'>
		<div style='display: none;'>
			<br/>
			<table width="547" cellpadding="0" cellspacing="0">
				<tbody>
					<xsl:apply-templates select='z:row'>
						<xsl:sort select="@ows_Datum" order="descending"/>
					</xsl:apply-templates>
					<xsl:variable name="rows" select="z:row" />
					<xsl:if test="count($rows) &lt; 1">
						<div style="padding:10px;">Er zijn geen kandidaat-nieuwsberichten aanwezig in deze categorie.</div>
					</xsl:if>
				</tbody>
			</table>
		</div>
	</xsl:template>

	<xsl:template match='z:row'>
		<xsl:if test="@ows_Nieuwsbriefopname = 'Kandidaat'">
			<xsl:variable name="rawUrl">
				<xsl:value-of select='substring-before(@ows_EncodedAbsUrl, "_.")'/>
			</xsl:variable>
			<xsl:variable name='url'>
				<xsl:value-of select='concat("/Lists/Nieuwsberichten/DispFormWindexCC.aspx?ID=", @ows_ID, "&amp;Source=http://www.lwv.nl")'/>
			</xsl:variable>
			<TR>
				<td width="547">
					<xsl:attribute name="class">wccNewsText</xsl:attribute>
					<table bgcolor="#dbddde" border="0" cellSpacing="0" cellPadding="0" width="100%" style="background-color: transparent; margin: 0px; padding 0px; border: 0px;">
						<tr>
							<td rowspan="2" width="168" height="152" bgcolor="#dbddde">
								<a target="_blank" title="Lees dit artikel">
									<xsl:attribute name="href">
										<xsl:value-of select='$url'/>
									</xsl:attribute>
									<img border="0">
										<xsl:attribute name="src">
											<xsl:value-of select="substring-before(@ows_Nieuwsbriefafbeelding, ',')"/>
										</xsl:attribute>
									</img>
								</a>
							</td>
							<td rowspan="2" width="20" height="14" bgcolor="#dbddde">
								<img src="/_layouts/images/void.gif" width="20"/>
							</td>
							<td width="377" bgcolor="#dbddde">
								<span id="Actions" style="width:100%;">
									<br/>
									<a class="wccNewsHeader" style="font-size:16px; font-family:'Trebuchet MS', Geneva, sans-serif; font-weight:bold; color:#477491;">
										<xsl:attribute name="href">
											<xsl:value-of select='$url'/>
										</xsl:attribute>
										<font face="Trebuchet MS" color="#477491">
											<b>
												<xsl:choose>
													<xsl:when test="string-length(@ows_LinkTitle) &lt; 1">
														<xsl:value-of select="substring(@ows_Body,0,$titleLimit)" disable-output-escaping='yes'/>
													</xsl:when>
													<xsl:otherwise>
														<xsl:value-of select='@ows_LinkTitle' disable-output-escaping='yes'  />
													</xsl:otherwise>
												</xsl:choose>
											</b>
										</font>
									</a>
								</span>
								<!-- end actions -->
							</td>
							<td align="right" bgcolor="#dbddde">
								<select id="NewsWebPartOrderingSelector">
								</select>
								<select id="NewsWebPartCandidateSelector">
									<option value="Kandidaat">Kandidaat</option>
									<option value="Geplaatst" selected="selected">Plaatsen</option>
									<option value="Niet geplaatst">Niet plaatsen</option>
								</select>
							</td>
							<td width="11" rowspan="2" bgcolor="#dbddde">
								<img src="/_layouts/images/void.gif" width="10"/>
							</td>
						</tr>
						<tr>
							<td valign="top" colspan="2" bgcolor="#dbddde">
								<div name="NewsWebPartNewsBody" style="font-size:12px; font-family:'Trebuchet MS', Geneva, sans-serif;">
									<xsl:choose>
										<xsl:when test="string-length(@ows_Inleiding) &gt; 1">
											<font face="Trebuchet MS">
												<xsl:call-template name="removeHtmlTags">
													<xsl:with-param name="html" select="@ows_Inleiding" />
												</xsl:call-template>
											</font>
										</xsl:when>
										<xsl:otherwise>
											<xsl:variable name="body">
												<xsl:call-template name="removeHtmlTags">
													<xsl:with-param name="html" select="@ows_Body" />
												</xsl:call-template>
											</xsl:variable>
											<xsl:choose>
												<xsl:when test="string-length($body) &lt;= 238">
													<xsl:value-of select="$body"/>
												</xsl:when>
												<xsl:otherwise>
													<font face="Trebuchet MS">
														<xsl:value-of select="substring($body,0,230)"/>
														<xsl:value-of select="substring-before(substring($body,230,20), ' ')"/>
														...
													</font>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:otherwise>
									</xsl:choose>
									<br/>
									<span name="NewsWebPartCategoryLabel" style="display: none; color: white;">
										<xsl:value-of select="concat(@ows_Nieuwsbriefcategorie, ';#')" disable-output-escaping='yes'  />
									</span>
									<a class="wccNewsHeader" style="font-size:12px; font-family:'Trebuchet MS', Geneva, sans-serif; color:#477491; font-style: italic">
										<xsl:attribute name="href">
											<xsl:value-of select='$url'/>
										</xsl:attribute>
										&gt;
										<font face="Trebuchet MS" color="#477491">
											lees hier het hele artikel
										</font>
									</a>
								</div>
							</td>
						</tr>
					</table>
					<xsl:text> </xsl:text>
				</td>
			</TR>
		</xsl:if>
	</xsl:template>

	<xsl:template name="removeHtmlTags">
		<xsl:param name="html"/>
		<xsl:choose>
			<xsl:when test="contains($html, '&lt;')">
				<xsl:value-of select="substring-before($html, '&lt;')"/>
				<!-- Recurse through HTML -->
				<xsl:call-template name="removeHtmlTags">
					<xsl:with-param name="html" select="substring-after($html, '&gt;')"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$html"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
