<?xml version="1.0" encoding="utf-8"?>


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/" >


<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="literal_block" /> 


<xsl:template match="/">

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
   <title>Stian Husemoen - Online diary</title>
   <link>http://www.batbelt.com/diary.html</link>
   <description>This is my online diary. Just small things and thoughts from my
everyday life</description>

 <xsl:apply-templates select="document/section[position() &lt; 21]" />

</channel></rss>

</xsl:template>


<xsl:template match="section">
  <item>
    <title><xsl:value-of select="section/title"/></title>
    <link>http://www.batbelt.com/diary.html#<xsl:value-of select="section/@ids"/></link>

    <description>
       <xsl:apply-templates select="section/*[not(self::title)]" mode="plain"/>
    </description>


    <content:encoded>
      <xsl:text disable-output-escaping="yes">&lt;![CDATA[ </xsl:text>
         <xsl:apply-templates select="section/*[not(self::title)]" />
      <xsl:text disable-output-escaping="yes">]]&gt; </xsl:text>
    </content:encoded>


    <dc:date><xsl:value-of select="substring(., 7,4)"/>-<xsl:value-of select="substring(., 4,2)"/>-<xsl:value-of select="substring(., 1,2)"/></dc:date>
   </item>

</xsl:template>


<xsl:template match="paragraph">
   <p><xsl:apply-templates /></p>
</xsl:template>

<xsl:template match="paragraph" mode="list">
   <xsl:apply-templates />
</xsl:template>

<xsl:template match="paragraph" mode="plain">
   <xsl:apply-templates mode="plain" />
   <xsl:text>&#10;</xsl:text>
   <xsl:text>&#10;</xsl:text>
</xsl:template>

<xsl:template match="bullet_list">
   <ul><xsl:apply-templates /></ul>
</xsl:template>

<xsl:template match="list_item">
   <li><xsl:apply-templates mode="list" /></li>
</xsl:template>

<xsl:template match="list_item" mode="plain">
 * <xsl:value-of select="." />
   <xsl:text>&#10;</xsl:text>
</xsl:template>

<xsl:template match="literal_block"> 
    <pre><xsl:apply-templates /></pre>
</xsl:template>

<xsl:template match="literal_block" mode="plain"> 
   <xsl:value-of select="." />
   <xsl:text>&#10;</xsl:text>
   <xsl:text>&#10;</xsl:text>
</xsl:template>

<xsl:template match="reference">
<xsl:text disable-output-escaping="yes">&lt;a href=&quot;</xsl:text><xsl:value-of select="@refuri" />&quot;<xsl:text disable-output-escaping="yes">&gt;</xsl:text><xsl:apply-templates /><xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text></xsl:template>

<xsl:template match="reference" mode="plain">
<xsl:value-of select="@name" />
</xsl:template>
 
<xsl:template match="image">
<xsl:text disable-output-escaping="yes">&lt;img src=&quot;</xsl:text><xsl:value-of select="@uri" />&quot; align=&quot;<xsl:value-of select="@align"/>&quot; alt=&quot;<xsl:value-of select="@alt" />&quot; height=&quot;<xsl:value-of select="@height" />&quot; width=&quot;<xsl:value-of select="@width" />&quot; <xsl:text disable-output-escaping="yes"> /&gt;</xsl:text></xsl:template>

<xsl:template match="strong">
   <xsl:copy-of select="." />
</xsl:template>

 
</xsl:stylesheet>
