<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns:h="http://www.w3.org/1999/xhtml"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  exclude-result-prefixes="h"
>
<!-- generates RDF schema form XMDP metadata profile. Cannot handle enumerated value lists for meta/content 
: dcterms:created "2004-03-05"; dcterms:modified "2004-03-05" .-->

 <xsl:output method="xml" indent="yes"/>
 <xsl:param name="xmlfile"/>

 <xsl:template match="/">
  <xsl:apply-templates select="h:html"/>
 </xsl:template>

 <xsl:template match="h:html">
  <rdf:RDF>
   <rdf:Description rdf:about="">
    <dc:title><xsl:value-of select="h:body//h:h1"/></dc:title>
    <dc:source rdf:resource="{$xmlfile}"/>
   </rdf:Description>
   <xsl:apply-templates select="h:body//h:dl[@class='profile']"/>
  </rdf:RDF>
 </xsl:template>

 <xsl:template match="h:dl">
  <xsl:for-each select="h:dt">
   <xsl:choose>
    <xsl:when test="@id='rel'">
    <!-- assums id="rel" represents linktype for link and a elements -->
     <xsl:apply-templates select="following-sibling::h:dd[position()=1]//h:dl/h:dt"/>
    </xsl:when>
    <xsl:otherwise>
    <!-- otherwise (property) names for lmeta elements -->
     <xsl:apply-templates select="."/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:for-each>
 </xsl:template>

 <xsl:template match="h:dt">
  <rdf:Property rdf:ID="{@id}">
   <rdfs:label><xsl:value-of select="."/></rdfs:label>
   <rdfs:comment><xsl:value-of select="following-sibling::h:dd[position()=1]"/></rdfs:comment>
  </rdf:Property>
 </xsl:template>

</xsl:stylesheet>
