﻿<?xml version="1.0"?>
<xsl:stylesheet
   version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:mux="http://www.w3.org/1999/xhtml"
   exclude-result-prefixes="mux">

<xsl:output
   method="xml"
   indent="yes"
   encoding="UTF-8"
   omit-xml-declaration="no"
   media-type="text/xml"
   cdata-section-elements="N3"/>

   <!-- Linked Data -->

<xsl:strip-space elements="*" />

<xsl:key
   name="ok-ns"
   match="mux:link[substring-before(./@rel, '.') = 'schema']"
   use="substring-after(./@rel, '.')" />

<xsl:template match="/">
<xsl:comment>

Meta Data Validation for Linked Datasets in HTML
================================================

   Linking Meta Data from HTML depends upon three assumptions.

1. The GRDDL Assumption
2. Other People's Data
3. The Fourier Assumption (Redaction)

For more information see &lt;http://www.rustprivacy.org/2010/meta/linked-data.pdf&gt;
</xsl:comment>
<N3 xml:space="preserve">
<xsl:text>
</xsl:text>&lt;#head@profile&gt; owl:sameAs &lt;<xsl:value-of select="//mux:head/@profile" />&gt;
&lt;#head@profile&gt; owl:sameAs &lt;http://www.w3.org/2004/02/skos/core#Collection&gt;

<xsl:apply-templates select="//mux:meta"/>

&lt;#abbr&gt; owl:sameAs &lt;http://purl.org/dc/terms/bibliographicCitation&gt;
&lt;#acronym&gt; owl:sameAs &lt;http://purl.org/dc/terms/bibliographicCitation&gt;
&lt;#address&gt; owl:sameAs &lt;http://purl.org/dc/terms/bibliographicCitation&gt;
&lt;#cite&gt; owl:sameAs &lt;http://purl.org/dc/terms/bibliographicCitation&gt;
&lt;#dfn&gt; owl:sameAs &lt;http://purl.org/dc/terms/bibliographicCitation&gt;
&lt;#rust&gt; owl:sameAs &lt;http://purl.org/dc/terms/bibliographicCitation&gt;
</N3>
</xsl:template>



<xsl:template match="mux:meta">
<xsl:text>
</xsl:text>
<xsl:choose>
<xsl:when test="./@http-equiv">

<xsl:value-of select="concat('&lt;#',./@http-equiv,'&gt; owl:sameAs &lt;',./@content,'&gt;')" /><xsl:text>
</xsl:text><xsl:value-of select="concat('&lt;#',./@http-equiv,'&gt; owl:sameAs &lt;','application/xml+rdf; charset=utf-8','&gt;')" />
<xsl:text>
</xsl:text>
</xsl:when>
<xsl:when test="./@name and key('ok-ns', substring-before(./@name,'.'))">

<xsl:value-of select="concat('&lt;#',./@name,'&gt; owl:sameAs &lt;',key('ok-ns', substring-before(./@name,'.'))/@href, substring-after(./@name,'.'),'&gt;')" />

</xsl:when>

<xsl:otherwise />
</xsl:choose>

</xsl:template>

<xsl:template match="mux:head" />
<xsl:template match="mux:body" />
<xsl:template match="comment()" />
<xsl:template match="text()" />
 
</xsl:stylesheet>
