<!-- Credited to Aristotle Pagaltzis and heavily modified by jlouis@mongers.org.
     Though Aristotele placed it in the public domain, I would like to credit him
     properly for writing the basic parts and getting my mind onto the right track.
-->
<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:atom="http://purl.org/atom/ns#"
	xmlns:date="http://exslt.org/dates-and-times"
	xmlns="http://www.w3.org/1999/xhtml"
	exclude-result-prefixes="atom date"
	extension-element-prefixes="date"
>


<xsl:output
	method="xml"
	indent="yes"
	omit-xml-declaration="yes"
	doctype-public="-//W3C//DTD XHTML 1.1//EN"
	doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
	encoding="utf-8"
/>


<!-- We strip excessive spaces from all elements by default -->
<xsl:strip-space elements="*" />

<!-- default policy for elements is discard -->
<xsl:template match="node()|@*" />


<!-- define a few utility templates first of all -->
<xsl:template match="node()" mode="copy-checking-escaping">
	<xsl:value-of select="normalize-space(.)" />
</xsl:template>

<xsl:template match="node()[@mode='escaped']" mode="copy-checking-escaping">
	<xsl:value-of select="normalize-space(.)" disable-output-escaping="yes" />
</xsl:template>

<xsl:template match="node()" mode="make-link">
	<xsl:variable name="href"><xsl:value-of select="../atom:link[@rel='alternate']/@href" /></xsl:variable>
	<xsl:choose>
		<xsl:when test="$href">
			<a href="{$href}"><xsl:apply-templates select="." mode="copy-checking-escaping" /></a>
		</xsl:when>
		<xsl:otherwise>
			<xsl:apply-templates select="." mode="copy-checking-escaping" />
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="@*|node()" mode="deep-copy">
	<xsl:copy>
		<xsl:apply-templates select="@*|node()" mode="deep-copy"/>
	</xsl:copy>
</xsl:template>


<xsl:template name="format-date">
	<!-- hooray for verbosity - sometimes I really love XSLT.. -->
	<xsl:param name="the-date" />
	<xsl:value-of select="date:month-abbreviation( $the-date )" />
	<xsl:text> </xsl:text>
	<xsl:value-of select="date:day-in-month( $the-date )" />
	<xsl:text>, </xsl:text>
	<xsl:value-of select="date:year( $the-date )" />
</xsl:template>

<!-- Main header -->
<xsl:template match="/">
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
		<xsl:apply-templates select="atom:feed"/>
	</html>
</xsl:template>

   <xsl:template match="atom:feed">
     <head>
       <title><xsl:value-of select="atom:title"/></title>

       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
       <meta name="MSSmartTagsPreventParsing" content="true" />
       <meta name="generator" content="jlouisBlog" />
       <xsl:element name="link">
         <xsl:attribute name="rel">alternate</xsl:attribute>
         <xsl:attribute name="type">application/atom+xml</xsl:attribute>
         <xsl:attribute name="title">Ramblings of jlouis</xsl:attribute>
         <xsl:attribute name="href">/atom.xml</xsl:attribute>
       </xsl:element>

       <style type="text/css">
	  @import url(style.css);
       </style>
     </head>
     <body>
	<div id="header">
		<h1 id="blog-title"><xsl:value-of select="atom:title"/></h1>
		<p id="description"><xsl:value-of select="atom:tagline"/></p>
	</div>
	<div id="content">
	  <div id="main">
	    <div id="main2">
	      <xsl:apply-templates select="atom:entry"/>
	    </div>
	  </div>
	</div>
	<div id="sidebar">
	  <div id="sidebar2">
	    <div id="profile-container">
	      <h2 class="sidebar-title">Contact</h2>
	      <dl class="profile-datablock">
	        <dd class="profile-data">
	          <strong>Name:</strong>Jesper Louis Andersen<br/>
	          <a href="mailto:jlouis@mongers.org">jlouis@mongers.org</a>
	        </dd>
	      </dl>
	    </div>
	    <h2 class="sidebar-title">Resources - Scheme</h2>
              <ul><li><a href="http://www.scheme.dk/planet/">Planet Scheme</a></li>
                  <li><a href="http://www.call-with-current-continuation.org">Chicken Scheme System</a></li>
                  <li><a href="http://s48.org">Scheme48</a></li>
	          <li><a href="http://plt-scheme.org">PLT Scheme</a></li>
	      </ul>
	    <h2 class="sidebar-title">Older entries</h2>
	    <ul><li><a href="/full.html">All entries</a></li>
	    </ul>
	    </div>
	  </div>
        <div id="footer"><hr />
	<p>
	  Words in here are mine, though the style has been
	  stolen. Proper credit is in the .css file
	</p>
        <p>
	  Everything set by hand in the Emacs editor.
	</p>
        </div>
     </body>
    </xsl:template>

<xsl:template match="atom:entry">
	<h2 class="date-header">
		<xsl:call-template name="format-date">
			<xsl:with-param name="the-date" select="atom:issued"/>
		</xsl:call-template>
	</h2>
    	<div class="post">
    		<h3 class="post-title">
    			<xsl:apply-templates select="atom:title" mode="make-link"/>
    		</h3>
    		<div class="post-body">
    			<xsl:apply-templates select="atom:summary" mode="copy-checking-escaping"/>
    			<xsl:apply-templates select="atom:content" mode="deep-copy"/>
    		</div>
		<p class="post-footer">
		  <em>posted by <xsl:value-of select="atom:author"/></em>
		</p>
	</div>
</xsl:template>

<xsl:template match="atom:entry/atom:summary">
	<div class="summary">
		<xsl:apply-templates select="." mode="copy-checking-escaping" />
	</div>
</xsl:template>

<xsl:template match="atom:entry/atom:content">
	<div class="content">
		<xsl:apply-templates select="." mode="deep-copy" />
	</div>
</xsl:template>

</xsl:stylesheet>