<?xml version='1.0'?><!-- -*- mode: indented-text;-*- -->
<xsl:transform
    xmlns:xsl  ="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:r    ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdf  ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    >

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

<div xmlns="http://www.w3.org/1999/xhtml">

<p>get rid of RDF aboutEach syntax</p>

<p>@@SPEC REVIEW: this mixes levels:</p>

<blockquote>
The value of an aboutEach attribute must be a container.
<address><a href="http://www.w3.org/TR/REC-rdf-syntax/#containers">3.3. Distributive Referents: Statements about Members of a
Container</a></address>
</blockquote>

<p>The value of the attribute is a URI reference;
it's what that URI <em>denotes</em> that must be
a container. i.e. aboutEach has rdfs:range rdfs:Container.
@@ is this already on the issues list?</p>

<p>Hmm...</p>

<blockquote>
No explicit graph representation of distributive referents is defined.
</blockquote>

<p>Hard to see how that works across syntactically-separated things.</p>


<hr />
<address>Dan Connolly <br class=""/>
$Id: aboutEachSugar.xsl,v 1.1 2001/05/18 20:52:52 connolly Exp $</address>
</div>

<!-- we assume typenode sugar has been eliminated -->
<xsl:template match='r:Description[@r:aboutEach]'>
  <xsl:variable name="object" select='@r:aboutEach'/>

  <r:Description>
    <r:type r:resource='{concat($RDF_ns, "Bag")}'/>
    <r:aboutEach r:resource='{$object}'/>

    <xsl:call-template name="properties">
      <xsl:with-param name="i" select='1'/>
    </xsl:call-template>

  </r:Description>
</xsl:template>

<xsl:template name="properties">
  <xsl:param name="i"/>

  <xsl:variable name="prop" select='*[$i]'/>

  <xsl:if test='$prop'>
    <xsl:element name='{concat("r:_", string($i))}' namespace='{$RDF_ns}'>
      <r:Description>
        <r:type r:resource='{concat($RDF_ns, "Statement")}'/>
        <r:predicate r:resource='{concat(namespace-uri($prop), local-name($prop))}'/>
        <xsl:choose>
          <xsl:when test='$prop/@r:resource'>
            <r:object r:resource='{$prop/@r:resource}'/>
          </xsl:when>

          <xsl:when test='$prop/* and not( $prop/text() )'> <!-- description child -->
            <xsl:message>this is probably buggy@@</xsl:message>
            <r:object>
              <xsl:apply-templates/>
            </r:object>
          </xsl:when>

          <xsl:otherwise> <!-- literal -->
            <r:object><xsl:value-of select='$prop'/></r:object>
          </xsl:otherwise>
        </xsl:choose>
      </r:Description>
    </xsl:element>

    <xsl:call-template name="properties">
      <xsl:with-param name="i" select='$i + 1'/>
    </xsl:call-template>

  </xsl:if>
</xsl:template>


<!-- identity transformation, taken from 
     http://www.w3.org/TR/xslt#copying
  -->
<xsl:template match="*">
  <xsl:element name="{name()}" namespace="{namespace-uri()}">
    <xsl:for-each select="@*">
      <xsl:attribute name="{name()}" namespace="{namespace-uri()}">
        <xsl:value-of select="."/>
      </xsl:attribute>
    </xsl:for-each>
    <xsl:apply-templates/>
  </xsl:element>
</xsl:template>

<xsl:template match="text()">
  <xsl:value-of select="."/>
</xsl:template>

<xsl:template match="comment()">
  <xsl:copy/>
</xsl:template>

</xsl:transform>
