<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:date="http://exslt.org/dates-and-times"
	xmlns:str="http://exslt.org/strings"
	xmlns:ex="tag:plasmasturm.org,2004:EXSLT-Functions"
	xmlns:html="http://www.w3.org/1999/xhtml"
	xmlns="http://www.w3.org/2005/Atom"
	extension-element-prefixes="date str ex"
	exclude-result-prefixes="html"
>
<xsl:output method="xml" indent="no" encoding="utf-8"/>

<xsl:template match="node()|@*">
	<xsl:apply-templates select="node()|@*"/>
</xsl:template>

<xsl:include href="exslt-extras.xslt" />

<xsl:template match="html:div[@class='quote'][@id]">
	<xsl:variable name="permalink" select="html:div[@class='quote_header']/html:span[@class='id']/html:a" />
	<xsl:variable name="datetime">
		<xsl:variable name="component" select="str:tokenize( html:div[@class='quote_header']/html:span[@class='date'], '. ' )" />
		<xsl:value-of select="concat( $component[3], '-', $component[2], '-', $component[1], 'T', $component[4] , ':00+01:00' )" />
	</xsl:variable>
	<entry>
		<title><xsl:value-of select="$permalink/node()" /></title>
		<link href="http://german-bash.org{ $permalink/@href }"/>
		<id>tag:german-bash.org,2004:<xsl:value-of select="substring-after( $permalink/node(), '#' )" /></id>
		<updated><xsl:value-of select="$datetime" /></updated>
		<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><tt>
			<xsl:for-each select="html:div[@class='zitat']/html:span[ @class = 'quote_zeile' ]">
				<xsl:copy-of select="ex:multiple-spaces-to-nbsp( normalize-space( . ) )" />
				<xsl:if test="position() &lt; last()"><br/></xsl:if>
			</xsl:for-each>
		</tt></div></content>
	</entry>
</xsl:template>

<xsl:variable name="source-url" select="'http://german-bash.org/action/latest/n/50'"/>
<xsl:variable name="tidy-arg" select="'-utf8'" />

<xsl:template match="/">
	<feed>
		<title>german-bash.org</title>
		<id>urn:uuid:1b437088-61e8-11da-9fcb-dd680b0526e0</id>
		<icon>http://german-bash.org/favicon.ico</icon>
		<logo>http://german-bash.org/images/banner/button1.gif</logo>
		<link href="{$source-url}"/>
		<link rel="self" href="http://plasmasturm.org/feeds/german-bash-latest/"/>
		<updated><xsl:value-of select="date:date-time()" /></updated>
		<author><name>german-bash.org</name></author>
		<xsl:apply-templates />
	</feed>
</xsl:template>

</xsl:stylesheet>
