<xsl:transform
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://www.w3.org/1999/xhtml"
    xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
    xmlns:s    ="http://www.w3.org/2000/01/rdf-schema#"
    >

<!-- contbl.xsl: extract formal version of connection table

 A connection table is a 3-column table where the middle
 column shows the relationship between the first and third.
 @@document more specifics about markup.
 -->
<!-- $Id: contbl.xsl,v 1.1 2005/08/09 05:18:44 connolly Exp $ -->
<!-- initial test data: http://dm93.org/2005/0504av/homeav.html@@to-appear
-->
<xsl:output method="xml" indent="yes" />

<xsl:template match="/">
  <rdf:RDF>
    <xsl:apply-templates />
  </rdf:RDF>
</xsl:template>

<!-- @@ support class="foo connections bar" -->
<xsl:template match='*[@class="connections"]'>
  <xsl:for-each select=".//h:tr">
    <xsl:variable name="subjID"
		  select="h:td[1]/descendant-or-self::*[@id]/@id" />
    <xsl:variable name="predID"
		  select="normalize-space(h:td[2])" />
    <xsl:variable name="objElt"
		  select="h:td[3]//h:a" />
    <xsl:variable name="objRef"
		  select="$objElt/@href" />

    <xsl:message>
      subj: <xsl:value-of select="$subjID" />
      pred: <xsl:value-of select="$predID" />
      obj: <xsl:value-of select="$objRef" />
    </xsl:message>

    <xsl:if test="$subjID">

      <rdf:Description rdf:about='{concat("#", $subjID)}'>
	<xsl:element name='{$predID}'> <!-- @@ namespace! -->
	  <rdf:Description rdf:about="{$objRef}">
	    <s:label><xsl:value-of select="$objElt" /></s:label>
	  </rdf:Description>
	</xsl:element>
      </rdf:Description>
    </xsl:if>
  </xsl:for-each>
</xsl:template>



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


</xsl:transform>
