<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  xmlns:h="http://www.w3.org/1999/xhtml"
  xmlns:nsfw="http://rdf.opiumfield.com/nsfw/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <xsl:output method="xml" indent="yes" />
  <xsl:param name="url">
    <xsl:choose>
      <xsl:when test="//h:base[@href]">
        <xsl:value-of select="//h:base/@href" />
      </xsl:when>
    </xsl:choose>
  </xsl:param>
  <xsl:template match="text()" />
  <xsl:template match="h:html">
    <rdf:RDF>
      <rdf:Description rdf:about="{$url}">
        <xsl:apply-templates select="//h:a" />
      </rdf:Description>
    </rdf:RDF>
  </xsl:template>
  <xsl:template match="h:a[@href][contains(concat(' ', @rel, ' '), ' nsfw ')] | h:a[@href][contains(concat(' ', @class, ' '), ' nsfw ')]">
    <nsfw:nsfw rdf:resource="{@href}" />
  </xsl:template>
	<!-- 2007-11-18 by TM: fixed the object - was turning out string literal, now turning out resource URI. -->
	<!-- 2007-10-09 by TM: added support for xfolk tagged with NSFW -->
	<xsl:template match="h:*[contains(concat(' ', @class, ' '), ' xfolkentry ')][contains(concat(' ', h:*/@class, ' '), ' meta ')]">
		<xsl:if test="h:*[contains(concat(' ', @class, ' '), ' meta ')]/a[contains(concat(' ', @rel, ' '), ' tag ')][contains(concat(translate(@href, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'), ' '), 'nsfw ')]">
			<nsfw:nsfw rdf:resource="h:a/@href" />
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
