<?xml version="1.0"?>
<!-- $Id: hyperdaml.xsl,v 1.11 2001/04/05 20:54:46 mdean Exp $ --> 
<!-- produce a hypertext version of a DAML/RDF document. -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:output method="html"/>

  <xsl:template match="*" mode="recurse">
    &lt;<xsl:value-of select="name()"/>
    <xsl:for-each select="@*">
      <xsl:text space="preserve"> </xsl:text>
      <xsl:choose>
        <xsl:when test="name()='rdf:ID'"><a><xsl:attribute name="name"><xsl:value-of select="."/></xsl:attribute></a><xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</xsl:when>
        <xsl:when test="name()='rdf:resource' or name()='rdf:about'"><xsl:value-of select="name()"/>="<a><xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute><xsl:value-of select="."/></a>"</xsl:when>
        <xsl:otherwise><xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>&gt;

    <xsl:apply-templates select="node()" mode="recurse"/>

    &lt;/<xsl:value-of select="name()"/>&gt;
  </xsl:template>

  <!-- copy text -->
  <xsl:template match="text()" mode="recurse">
    <xsl:copy/>
  </xsl:template>

  <!-- escape comments -->	
  <xsl:template match="comment()" mode="recurse">
    &lt;--<xsl:value-of select="."/>--&gt;
  </xsl:template>

  <xsl:template match="/">
    <html>
      <body>
        <code>
          <pre>
            <xsl:apply-templates select="." mode="recurse"/>
          </pre>
        </code>

        <hr />
        <address>
          Produced using
          <a>
            <xsl:attribute name="href">http://www.daml.org/2001/04/hyperdaml/</xsl:attribute>
            hyperdaml
          </a>.xsl
        </address> 
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>
