<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:rec="http://www.w3.org/2001/02pd/rec54#"
  xmlns:contact="http://www.w3.org/2000/10/swap/pim/contact#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:doc="http://www.w3.org/2000/10/swap/pim/doc#"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:trd="http://www.w3.org/2001/10/trdoc-data.xsl"
  xmlns='http://www.w3.org/2002/05/matrix/vocab#'
  xmlns:str="http://www.w3.org/2001/10/str-util.xsl"
  exclude-result-prefixes="str"
  version="1.0">
  <!-- $Id: MatriXmltoRdf.xsl,v 1.7 2003/01/15 16:10:47 dom Exp $ -->

  <xsl:import href="http://www.w3.org/2001/10/str-util.xsl"/>

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

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

  <xsl:template match="spec">
    <Work rdf:about='{uri}'>
      <!-- @@@ Means that LCWD must be added to mat schema -->
      <!-- @@@ would it be OK to use the rec schema instead of mat for this? -->
      <status rdf:resource='http://www.w3.org/2002/05/matrix/vocab#{translate(history/status[1]/@name,$str:lc,$str:uc)}'/>
      <xsl:if test="accronym">
        <hasAcronym><xsl:value-of select="accronym"/></hasAcronym>
      </xsl:if>
      <xsl:if test="validator/@status='yes'">
        <hasValidator rdf:resource='{validator/uri}'/>
      </xsl:if>
      <xsl:if test="not(ts/@origin='no') and ts">
        <!-- origin=out or origin=w3c is implied by the start of the URI I guess -->
        <hasTestSuite rdf:resource='{ts/uri}'/>
      </xsl:if>
      <xsl:apply-templates select="related/info"/>
      <xsl:if test="not(conf/@status='no') and conf">
        <hasConformanceSection rdf:resource="{conf/uri}"/>
      </xsl:if>
    </Work>
  </xsl:template>

  <xsl:template match="info">
    <xsl:choose>
      <xsl:when test="text='Errata'">
        <hasErrata rdf:resource="{uri}"/>
      </xsl:when>
      <xsl:when test="contains(text,'Interoperability')">
        <hasInteropReport rdf:resource="{uri}"/>
      </xsl:when>
      <xsl:when test="normalize-space(text)='Comments on the CR'">
        <hasCRComments rdf:resource="{uri}"/>
      </xsl:when>
      <xsl:when test="contains(text,'Requirements')">
        <hasRequirements rdf:resource="{uri}"/>
      </xsl:when>
      <xsl:when test="normalize-space(text)='Patents disclosure' or normalize-space(text)='Patent Disclosure' or normalize-space(text)='Public Statements on Patents' or normalize-space(text)='Patent disclosures'">
        <hasPatentDisclosure rdf:resource="{uri}"/>
      </xsl:when>
      <xsl:otherwise>
        <isRelatedTo>
          <rdf:Description rdf:about='{uri}'>
            <dc:title><xsl:value-of select="text"/></dc:title>
        </rdf:Description>
        </isRelatedTo>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>