<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:simple="http://my.netscape.com/rdf/simple/0.9/" xmlns:rss="http://purl.org/rss/1.0/"
	xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:atom="http://purl.org/atom/ns#"
	xmlns:atom1="http://www.w3.org/2005/Atom" xmlns:foaf="http://xmlns.com/foaf/0.1/"
	xmlns:admin="http://webns.net/mvcb/" xmlns:icbm="http://postneo.com/icbm"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	xmlns:enc="http://purl.oclc.org/net/rss_2.0/enc#"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/">
	<xsl:output method="html"/>

	<xsl:param name="Random">47</xsl:param>

	<xsl:template match="/">
		<xsl:apply-templates select="/rdf:RDF[rss:channel or simple:channel]"/>
		<xsl:apply-templates select="/rss[@version]/channel"/>
		<xsl:apply-templates select="/redirect/newLocation"/>
		<xsl:apply-templates select="/atom:feed[@version='0.3']"/>
		<xsl:apply-templates select="/atom1:feed"/>
	</xsl:template>

	<xsl:template match="rss/channel">
		<div class="box norm">
			<div class="box-i">
				<h4 class="box-first-h">
					<xsl:value-of select="title" disable-output-escaping="yes"/>
				</h4>
				<xsl:call-template name="listItem"/>
				<xsl:choose>
					<xsl:when test="title = 'Dagen i dag'">
						<p class="box-f">L&#230;s mere i:<br/><a
								href="https://ssoproxy.emu.dk/aschehoug/index.cgi?id=aschehoug">
								Aschehougs Leksikon - <xsl:value-of select="title"
									disable-output-escaping="yes"/>
							</a></p>
					</xsl:when>
					<xsl:otherwise>
						<p class="box-f">Kilde:<br/><a href="{link}">
								<xsl:value-of select="title" disable-output-escaping="yes"/>
							</a></p>
					</xsl:otherwise>
				</xsl:choose>
			</div>
		</div>
	</xsl:template>

	<xsl:template match="/atom:feed|/atom1:feed">
		<div class="box-norm">
			<div class="box-i">
				<h4 class="box-first-h">
					<xsl:apply-templates select="atom:title|atom1:title"/>
				</h4>
				<xsl:call-template name="listAtomItem"/>
				<p class="box-f">Kilde:<br/>
					<xsl:element name="a">
						<xsl:attribute name="href">
							<xsl:apply-templates select="atom:link|atom1:link"/>
						</xsl:attribute>
						<xsl:apply-templates select="atom:title|atom1:title"/>
					</xsl:element>
				</p>
			</div>
		</div>
	</xsl:template>

	<xsl:template match="atom:link|atom1:link">
		<xsl:if test="@rel = 'alternate'">
			<xsl:value-of select="@href"/>
		</xsl:if>
	</xsl:template>

	<xsl:template match="atom:title|atom1:title">
		<xsl:value-of select="." disable-output-escaping="yes"/>
	</xsl:template>

	<xsl:template match="/rdf:RDF">
		<div class="box norm">
			<div class="box-i">
				<h4 class="box-first-h">
					<xsl:value-of select="rss:channel/rss:title" disable-output-escaping="yes"/>
				</h4>
				<xsl:call-template name="listRdfItem"/>
				<p class="box-f">Kilde:<br/><a href="{rss:channel/rss:link}">
						<xsl:value-of select="rss:channel/rss:title"
							disable-output-escaping="yes"/></a>
				</p>
			</div>
		</div>
	</xsl:template>

	<!--#####################      FUNCTION 	#####################-->
	<xsl:template name="listItem">
		<xsl:variable name="countItem">
			<xsl:value-of select="count(item)"/>
		</xsl:variable>
		<xsl:variable name="showItem">
			<xsl:value-of select="1 + $Random mod $countItem"/>
		</xsl:variable>
		<dl class="rss">
			<xsl:for-each select="item">
				<xsl:if test="$showItem = position()">
					<dt>
						<!-- <a href="{link}"> -->
						<xsl:value-of select="translate(title, ':', ' ')"
							disable-output-escaping="yes"/>
						<!-- </a> -->
					</dt>
					<xsl:choose>
						<xsl:when test="count(./content:encoded) > 0">
							<dd>
								<xsl:value-of select="content:encoded" disable-output-escaping="yes"
								/>
							</dd>
						</xsl:when>
						<xsl:otherwise>
							<dd>
								<xsl:value-of select="description" disable-output-escaping="yes"/>
							</dd>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:if>
			</xsl:for-each>
		</dl>
	</xsl:template>

	<!--#####################      FUNCTION 	#####################-->
	<xsl:template name="listAtomItem">
		<dl class="rss">
			<xsl:variable name="countItem">
				<xsl:value-of select="count(atom:entry|atom1:entry)"/>
			</xsl:variable>
			<xsl:variable name="showItem">
				<xsl:value-of select="1 + $Random mod $countItem"/>
			</xsl:variable>
			<xsl:for-each select="atom:entry|atom1:entry">
				<xsl:if test="$showItem = position()">
					<dt>
						<!-- <xsl:element name="a">
							<xsl:attribute name="href">
								<xsl:apply-templates select="atom:link|atom1:link"/>
							</xsl:attribute> -->
						<xsl:apply-templates select="atom:title|atom1:title"/>
						<!-- </xsl:element> -->
					</dt>
					<xsl:choose>
						<xsl:when test="count(atom:summary) > 0">
							<dd>
								<xsl:value-of select="atom:summary" disable-output-escaping="yes"/>
							</dd>
						</xsl:when>
						<xsl:when test="count(atom1:summary) > 0">
							<dd>
								<xsl:value-of select="atom1:summary" disable-output-escaping="yes"/>
							</dd>
						</xsl:when>
					</xsl:choose>
				</xsl:if>
			</xsl:for-each>
		</dl>
	</xsl:template>

	<!--#####################      FUNCTION 	#####################-->
	<xsl:template name="listRdfItem">
		<xsl:variable name="countItem">
			<xsl:value-of select="count(rss:item)"/>
		</xsl:variable>
		<xsl:variable name="showItem">
			<xsl:value-of select="1 + $Random mod $countItem"/>
		</xsl:variable>
		<dl class="rss">
			<xsl:for-each select="rss:item">
				<xsl:if test="$showItem = position()">
					<dt>
						<!-- <a href="{rss:link}"> -->
						<xsl:value-of select="rss:title" disable-output-escaping="yes"/>
						<!-- </a> -->
					</dt>
					<dd>
						<xsl:value-of select="rss:description" disable-output-escaping="yes"/>
					</dd>
				</xsl:if>
			</xsl:for-each>
		</dl>
	</xsl:template>

	<!--#####################      FUNCTION 	#####################-->
	<!--## <pubDate>Fri, 29 Sep 2006 14:16:42 +0200</pubDate> #####-->
	<!--## <pubDate>19 Nov 2008 09:20:00 +0100</pubDate> #####-->
	<xsl:template name="listPubDate">
		<xsl:variable name="after1">
			<xsl:choose>
				<xsl:when test="contains(pubDate, ',')">
					<xsl:value-of select="substring-after(pubDate, ', ')"/>
				</xsl:when>	 
				<xsl:otherwise>
					<xsl:value-of select="pubDate"/>
				</xsl:otherwise>	 
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="day" select="substring-before($after1, ' ')"/>
		<xsl:variable name="after2" select="substring-after($after1, ' ')"/>
		<xsl:variable name="month1" select="substring-before($after2, ' ')"/>
		<xsl:variable name="after3" select="substring-after($after2, ' ')"/>
		<xsl:variable name="year" select="substring-before($after3, ' ')"/>
		<xsl:variable name="month">
			<xsl:choose>
				<xsl:when test="$month1= 'Jan'">01</xsl:when> 
				<xsl:when test="$month1= 'Feb'">02</xsl:when> 
				<xsl:when test="$month1= 'Mar'">03</xsl:when> 
				<xsl:when test="$month1= 'Apr'">04</xsl:when> 
				<xsl:when test="$month1= 'May'">05</xsl:when> 
				<xsl:when test="$month1= 'Jun'">06</xsl:when> 
				<xsl:when test="$month1= 'Jul'">07</xsl:when> 
				<xsl:when test="$month1= 'Aug'">08</xsl:when> 
				<xsl:when test="$month1= 'Sep'">09</xsl:when> 
				<xsl:when test="$month1= 'Oct'">10</xsl:when> 
				<xsl:when test="$month1= 'Nov'">11</xsl:when> 
				<xsl:when test="$month1= 'Dec'">12</xsl:when> 
				<xsl:otherwise><xsl:value-of select="$month1" /></xsl:otherwise>
			</xsl:choose>	 
		</xsl:variable>
		(<xsl:value-of select="$day" /><xsl:text>/</xsl:text><xsl:value-of select="$month" />&#160;<xsl:value-of select="$year" />)
	</xsl:template>

	<!--#####################      FUNCTION 	#####################-->
	<!--## <pubDate>Fri, 29 Sep 2006 14:16:42 +0200</pubDate> #####-->
	<xsl:template name="listDcDate">
		<xsl:variable name="year" select="substring-before(dc:date, '-')"/>
		<xsl:variable name="after1" select="substring-after(dc:date, '-')"/>
		<xsl:variable name="month" select="substring-before($after1, '-')"/>
		<xsl:variable name="after2" select="substring-after($after1, '-')"/>
		<xsl:variable name="day" select="substring($after2, 1, 2)"/> (<xsl:value-of select="$day"
			/><xsl:text>/</xsl:text><xsl:value-of select="$month"/>&#160;<xsl:value-of
			select="$year"/>) </xsl:template>

	<!--#####################      FUNCTION 	#####################-->
	<!--## <modified>2006-10-04T17:06:42Z</modified>          #####-->
	<xsl:template name="listAtomDate">
		<xsl:variable name="year" select="substring-before(atom:modified, '-')"/>
		<xsl:variable name="after1" select="substring-after(atom:modified, '-')"/>
		<xsl:variable name="month" select="substring-before($after1, '-')"/>
		<xsl:variable name="after2" select="substring-after($after1, '-')"/>
		<xsl:variable name="day" select="substring($after2, 1, 2)"/> (<xsl:value-of select="$day"
			/><xsl:text>/</xsl:text><xsl:value-of select="$month"/>&#160;<xsl:value-of
			select="$year"/>) </xsl:template>
</xsl:stylesheet>

