<xsl:stylesheet 
    xmlns:xsl  ="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:rdf  ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:xlink="http://www.w3.org/1999/xlink">

<!-- $Id: xlink2rdf.xsl,v 1.1 2000/06/28 03:43:31 connolly Exp $ -->

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

<xsl:variable name='rdfNS'
	      select='"http://www.w3.org/1999/02/22-rdf-syntax-ns#"'/>

<!-- wrap rdf:RDF around the output -->
<xsl:template match='/'>
 <rdf:RDF>
     <xsl:apply-templates/>
 </rdf:RDF>
</xsl:template>


<!-- simple links, per 4.2 Simple linking elements -->

<xsl:template match='*[@xlink:type="simple"]'>
	      <!-- @@ this doesn't handle the special case for http://www.w3.org/1999/xlink/properties/linkbase -->
  <xsl:variable name='subject'
		select='concat("#xpointer-for-", generate-id())'/>

		<!-- "Note that the starting Resource of a simple link
		is the linking element itself." May? what other cases
		are there? @@ -->

  <xsl:variable name='predicate'
		select='@xlink:arcrole'/> <!-- if it's not there, we MAY use the element name. @@ -->

  <xsl:variable name='object'
		select='@xlink:href'/>

  <xsl:variable name='objType'
		select='@xlink:role'/>

  <!-- how the heck do we split the predicate into a localname and a namespace name? -->
  <xsl:element name='oops-predicate' namespace='{$predicate}'>
    <xsl:attribute name='rdf:about'><xsl:value-of
     select='$subject'/></xsl:attribute>
    <xsl:attribute name='rdf:resource'><xsl:value-of
     select='$object'/></xsl:attribute>
  </xsl:element>

  <xsl:if test="$objType">
    <xsl:element name='rdf:type'>
      <xsl:attribute name='rdf:about'><xsl:value-of
         select='$object'/></xsl:attribute>
      <xsl:attribute name='rdf:resource'><xsl:value-of
       select='$objType'/></xsl:attribute>
    </xsl:element>
    <rdf:Class rdf:about='{$objType}'/>
  </xsl:if>

</xsl:template>

<!-- @@ extended links not done -->

<!-- @@ linkbases not done -->

<!-- don't pass text thru -->
<xsl:template match="text()|@*">
</xsl:template>


</xsl:stylesheet>
