
<!-- stylesheet that turns (modified) Trix into reified triples -->
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns="http://www.w3.org/1999/xhtml" 
  xmlns:html="http://www.w3.org/1999/xhtml" 
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
  xmlns:xa="http://www.w3.org/2003/g/xml-attributes#"
  exclude-result-prefixes="html">

<xsl:import href="http://www.w3.org/2003/g/xml-attributes" />

              
              
<!-- Output method XML -->
<xsl:output method="xml" 
  indent="yes"
  omit-xml-declaration="no" 
  encoding="utf-8"  />

  
<xsl:template match="graph">
 <rdf:RDF>
   <xsl:call-template name="xa:base" />
   <xsl:apply-templates />
 </rdf:RDF>
</xsl:template>

<xsl:template match="triple">
 <rdf:Description>
   <xsl:call-template name="xa:base">
     <xsl:with-param name="node-used-by-ancestor" select=".."/>
   </xsl:call-template>
   <rdf:subject>
     <xsl:apply-templates select="*[1]"/>
   </rdf:subject>
   <rdf:predicate>
     <xsl:apply-templates select="*[2]"/>
   </rdf:predicate>
   <rdf:object>
     <xsl:apply-templates select="*[3]"/>
   </rdf:object>
 </rdf:Description>
</xsl:template>


<xsl:template match="id">
  <xsl:attribute name="rdf:nodeID">
    <xsl:value-of select="text()"/>
  </xsl:attribute>
</xsl:template>

<xsl:template match="uri">
   <xsl:call-template name="xa:base">
     <xsl:with-param name="node-used-by-ancestor" select=".."/>
   </xsl:call-template>
  <xsl:attribute name="rdf:resource">
    <xsl:value-of select="text()"/>
  </xsl:attribute>
</xsl:template>

<xsl:template match="plainLiteral">
  <xsl:call-template name="xa:lang" />
  <xsl:value-of select="text()"/>
</xsl:template>


<xsl:template match="typedLiteral">
   <xsl:call-template name="xa:base">
     <xsl:with-param name="node-used-by-ancestor" select=".."/>
   </xsl:call-template>
  <xsl:attribute name="rdf:datatype">
    <xsl:value-of select="@datatype"/>
  </xsl:attribute>
  <xsl:value-of select="text()"/>
</xsl:template>

  
<!-- don't pass text through. -->
<xsl:template match="text()">
</xsl:template>

<!-- don't pass attributes through. -->
<xsl:template match="@*">
</xsl:template>


</xsl:stylesheet>

