<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <xsl:strip-space elements="*"/>
  <xsl:output indent="yes"/>
  <xsl:template match="rdfcat">
	 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  xmlns:owl="http://www.w3.org/2002/07/owl#">
		<xsl:apply-templates/>
	 </rdf:RDF>
  </xsl:template>
  <xsl:template match="rdf:RDF">
		<xsl:apply-templates select="*"/>
	 <xsl:for-each select="//@rdf:resource">
		<!-- But don't bother with the ones in OWL, RDF, or RDFS elements. -->
		<xsl:if test="namespace-uri(..) != 'http://www.w3.org/2002/07/owl#' and  namespace-uri(..) != 'http://www.w3.org/2000/01/rdf-schema#' and namespace-uri(..) != 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' ">
		<owl:Thing rdf:about="{.}"/>
		</xsl:if>
	 </xsl:for-each>
  </xsl:template>
  <xsl:template match="*[@rdf:about]">
	 <rdf:Description rdf:about="{@rdf:about}">
		<rdf:type>
		  <owl:Class rdf:about="{namespace-uri(.)}{local-name()}"/>
		</rdf:type>
		<xsl:apply-templates select="@*|node()"/>
	 </rdf:Description>
  </xsl:template>

  <xsl:template match="@*|node()">
	 <xsl:copy>
        	<xsl:apply-templates select="@*|node()"/>
	 </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
