sk@sethwklein.net
 

sethwklein.net



This site is generated from an XML document using the XSL stylesheet below.

sethwklein.net.xsl

<?xml version="1.0" standalone="no"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exsl="http://exslt.org/common"
  extension-element-prefixes="exsl"
  xmlns:xi="http://www.w3.org/2001/XInclude"
  exclude-result-prefixes="xi"
>

<xsl:include href="lib/get-relative-url.xsl"/>

<!-- comment element -->
<xsl:template match="X"/>
<!-- default rule for comments and processing instructions is not included
  in some buggy processors -->
<xsl:template match="processing-instruction()|comment()"/>

<xsl:template match="page|moved">
  <!--
  <xsl:message>
    <xsl:text>#</xsl:text>
    <xsl:value-of select="@id"/>
  </xsl:message>
  <xsl:message>
    <xsl:text>../@</xsl:text>
    <xsl:value-of select="../@filename"/>
  </xsl:message>
  <xsl:message>
    <xsl:text>@</xsl:text>
    <xsl:value-of select="@filename"/>
  </xsl:message>
  <xsl:message>
    <xsl:text>c$</xsl:text>
    <xsl:value-of select="$current-filename"/>
  </xsl:message>
  <xsl:message>
    <xsl:text>r$</xsl:text>
    <xsl:value-of select="$relative-filename"/>
  </xsl:message>
  -->
  <xsl:variable name="current-filename" select="@filename"/>
  <xsl:variable name="relative-filename">
    <xsl:choose>
      <xsl:when test="not(ancestor::*)">
	<xsl:value-of select="@filename"/>
      </xsl:when>
      <xsl:otherwise>
	<xsl:call-template name="get-relative-path">
	  <xsl:with-param name="from" select="../@filename"/>
	  <xsl:with-param name="to" select="@filename"/>
	</xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <exsl:document href="{$relative-filename}"
      method="html" indent="yes" version="4.01" encoding="ISO-8859-1">
    <html lang="en-US">
      <head>
	<title>
	  <xsl:for-each select="ancestor-or-self::*[self::page or self::moved]">
	    <xsl:sort data-type="number" order="descending"
		select="count(ancestor-or-self::*[self::page or self::moved])"/>
	    <xsl:apply-templates select="title" mode="header"/>
	    <xsl:if test="ancestor::*[self::page or self::moved]">
	      <xsl:text> . </xsl:text>
	    </xsl:if>
	  </xsl:for-each>
	</title>
	<link rel="stylesheet" type="text/css" title="SethWKlein.Net">
	  <xsl:attribute name="href">
	    <xsl:call-template name="get-relative-url">
	      <xsl:with-param name="to" select="'main.css'"/>
	    </xsl:call-template>
	  </xsl:attribute>
	</link>
	<xsl:if test="$current-filename = 'index.html'">
	  <link rel="openid.server" href="http://sethwklein.net/id/"/>
	  <link rel="openid.delegate" href="http://sethwklein.net/id/"/>
	</xsl:if>
      </head>
      <body>
	<div id="color">
	  <img width="196" height="196">
	    <xsl:attribute name="src">
	      <xsl:call-template name="get-relative-url">
		<xsl:with-param name="to"
		    select="'cimg0739-cq196.jpg'"/>
	      </xsl:call-template>
	    </xsl:attribute>
	  </img>
	  <br/>
	  <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
	  <br/>
	  <a>
	    <xsl:attribute name="href">
	      <xsl:call-template name="get-relative-url">
		<xsl:with-param name="from" select="$current-filename"/>
		<xsl:with-param name="to" select="'about/contact.html'"/>
	      </xsl:call-template>
	    </xsl:attribute>
	    <xsl:text>sk@sethwklein.net</xsl:text>
	  </a>
	  <br/>
	  <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
	  <br/>
	</div>
	<xsl:if test="count(ancestor::page|ancestor::moved)">
	  <ul class="nav-up">
	    <xsl:for-each select="ancestor::page|ancestor::moved">
	      <li>
		<a>
		  <xsl:attribute name="href">
		    <xsl:call-template name="get-relative-url">
		      <xsl:with-param name="from" select="$current-filename"/>
		      <xsl:with-param name="to" select="@filename"/>
		    </xsl:call-template>
		  </xsl:attribute>
		  <xsl:apply-templates select="title" mode="header"/>
		</a>
	      </li>
	    </xsl:for-each>
	  </ul>
	</xsl:if>
	<h1>
	  <xsl:apply-templates select="title" mode="header"/>
	</h1>
	<xsl:if test="count(page)">
	  <ul class="nav-down">
	    <xsl:for-each select="page">
	      <li>
		<a>
		  <xsl:attribute name="href">
		    <xsl:call-template name="get-relative-url">
		      <xsl:with-param name="from" select="$current-filename"/>
		      <xsl:with-param name="to" select="@filename"/>
		    </xsl:call-template>
		  </xsl:attribute>
		  <xsl:apply-templates select="title" mode="header"/>
		</a>
		<div class="synopsis">
		  <xsl:apply-templates select="synopsis" mode="header"/>
		</div>
	      </li>
	    </xsl:for-each>
	  </ul>
	</xsl:if>
	<br clear="left"/>
	<xsl:if test="count(section) > 1">
	  <ul class="nav-in">
	    <xsl:for-each select="section">
	      <li>
		<a href="#{@id}">
		  <xsl:apply-templates select="title" mode="header"/>
		</a>
	      </li>
	    </xsl:for-each>
	  </ul>
	</xsl:if>
	<br clear="left"/>
	<xsl:apply-templates/>
	<hr/>
	<div class="footer">
	  <a>
	    <xsl:attribute name="href">
	      <xsl:call-template name="get-relative-url">
		<xsl:with-param name="from" select="$current-filename"/>
		<xsl:with-param name="to" select="'site/noie.html'"/>
	      </xsl:call-template>
	    </xsl:attribute>
	    <img width="45" height="45" border="0" alt="[No IE]">
	      <xsl:attribute name="src">
		<xsl:call-template name="get-relative-url">
		  <xsl:with-param name="from" select="$current-filename"/>
		  <xsl:with-param name="to" select="'site/noIE-45x45.png'"/>
		</xsl:call-template>
	      </xsl:attribute>
	    </img>
	  </a>
	</div>
      </body>
    </html>
  </exsl:document>
</xsl:template>

<xsl:template match="title|synopsis"/>
  <!-- handled in procedural -->

<xsl:template match="synopsis|title" mode="header">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="section">
  <!-- XXX add  nested section title handling -->
  <a name="{@id}">
    <xsl:element name="h{count(ancestor-or-self::section) + 1}">
      <xsl:apply-templates select="title" mode="header"/>
    </xsl:element>
  </a>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="para">
  <p>
    <!-- actually, as of this writing, the dtd limits this to @style -->
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </p>
</xsl:template>

<xsl:template match="link">
  <a href="{@url}">
    <xsl:choose>
      <xsl:when test="node()">
	<xsl:apply-templates/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
	  <xsl:when test="substring(@url, 0, string-length('mailto:') + 1)
	      = 'mailto:'">
	    <xsl:value-of select="substring(@url,
		string-length('mailto:') + 1)"/>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:value-of select="@url"/>
	  </xsl:otherwise>
	</xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </a>
</xsl:template>

<xsl:template match="emdash">
  <xsl:text disable-output-escaping="yes">&amp;mdash;</xsl:text>
</xsl:template>

<xsl:template match="copy">
  <xsl:text disable-output-escaping="yes">&amp;copy;</xsl:text>
</xsl:template>

<xsl:template match="sp">
  <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
</xsl:template>

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

<xsl:template match="bib-sep">
  <hr class="bib"/>
</xsl:template>

<xsl:template match="bib-quot">
  <div class="bib-quot">
    <xsl:apply-templates/>
  </div>
</xsl:template>

<xsl:template match="bib-comm">
  <div class="bib-comm">
    <xsl:apply-templates/>
  </div>
</xsl:template>

</xsl:stylesheet>

lib/get-relative-url.xsl

<?xml version="1.0" standalone="no"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>

<xsl:template name="get-relative-url">
  <xsl:param name="from" select="@filename"/>
  <xsl:param name="to"   select="@filename"/>
  <xsl:variable name="path">
    <xsl:call-template name="__get-relative-path">
      <xsl:with-param name="from" select="$from"/>
      <xsl:with-param name="to"   select="$to"/>
    </xsl:call-template>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="substring($path, string-length($path) - 9) = 'index.html'">
      <xsl:choose>
        <xsl:when test="string-length($path) = string-length('index.html')">
	  <xsl:text>.</xsl:text>
	</xsl:when>
        <xsl:otherwise>
          <xsl:value-of
	      select="substring($path, 1, string-length($path) - 10)"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$path"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="get-relative-path">
  <!-- this just does error checking and selects default params
       before calling the real thing
  -->
  <xsl:param name="from" select="@filename"/>
  <xsl:param name="to"   select="@filename"/>
  <xsl:choose>
    <xsl:when test="starts-with($from, '/') != starts-with($to, '/')">
      <xsl:message>
	<xsl:text>Error: get-relative-path called with a mix of relative and absolute paths&#xA;</xsl:text>
	<xsl:text>&#x9;from="</xsl:text>
	<xsl:value-of select="$from"/>
	<xsl:text>"&#xA;&#x9;to="</xsl:text>
	<xsl:value-of select="$to"/>
	<xsl:text>"</xsl:text>
      </xsl:message>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="__get-relative-path">
	<xsl:with-param name="from" select="$from"/>
	<xsl:with-param name="to"   select="$to"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="__get-relative-path">
  <xsl:param name="from" select="''"/>
  <xsl:param name="to"   select="''"/>
  <xsl:choose>
    <!-- step 1: trim common ancestors -->
    <xsl:when test="substring-before($from, '/') = substring-before($to, '/')
		    and contains($from, '/') and contains($to, '/')">
      <xsl:call-template name="__get-relative-path">
	<xsl:with-param name="from" select="substring-after($from, '/')"/>
	<xsl:with-param name="to" select="substring-after($to, '/')"/>
      </xsl:call-template>
    </xsl:when>
    <!-- step 2: travel up the tree to the nearest common ancestor -->
    <xsl:otherwise>
      <xsl:if test="contains($from, '/')">
	<xsl:text>../</xsl:text>
	<xsl:call-template name="__get-relative-path">
	  <xsl:with-param name="from" select="substring-after($from, '/')"/>
	</xsl:call-template>
      </xsl:if>
      <!-- step 3: travel down from the nearest common ancestor
	   to the destination file.
	   This is also run when this template is called from step 2
	   after this step completes
	   but $to is empty then.
      -->
      <xsl:value-of select="$to"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>