<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fx="http://simonstl.com/foaf-xml/0.1/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:foaf="http://xmlns.com/foaf/0.1/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:wot="http://xmlns.com/wot/0.1/"
    xmlns:rss="http://purl.org/rss/1.0/"

    exclude-result-prefixes="fx"
    >
    
<!--XSLT stylesheet for transforming FOAF RDF to FOAF XML
   Donated to the public domain by Simon St.Laurent, http://simonstl.com -->

<xsl:strip-space elements="fx:person fx:foafParts" />
<xsl:output indent="yes" encoding="UTF-8"/>

<xsl:template match="/">
<rdf:RDF>
  <xsl:apply-templates />
</rdf:RDF>
</xsl:template>


<xsl:template match="fx:foafParts">
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="fx:person">
<foaf:person>
  <xsl:apply-templates />
</foaf:person>
</xsl:template>


<xsl:template match="fx:currentProject"><foaf:currentProject><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:currentProject></xsl:template>

<xsl:template match="fx:depiction"><foaf:depiction><xsl:call-template name="srcAtts"/><xsl:apply-templates /></foaf:depiction></xsl:template>

<xsl:template match="fx:name"><foaf:name><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:name></xsl:template>

<xsl:template match="fx:mbox"><foaf:mbox><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:mbox></xsl:template>

<xsl:template match="fx:pastProject"><foaf:pastProject><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:pastProject></xsl:template>

<xsl:template match="fx:depicts" /> <!--dunno how this works-->

<xsl:template match="fx:firstName"><foaf:givenName><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:givenName></xsl:template>

<xsl:template match="fx:mbox_sha1sum"><foaf:mbox_sha1sum><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:mbox_sha1sum></xsl:template>

<xsl:template match="fx:fundedBy"><foaf:fundedBy><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:fundedBy></xsl:template>

<xsl:template match="fx:thumbnail"><foaf:thumbnail><xsl:call-template name="srcAtts"/><xsl:apply-templates /></foaf:thumbnail ></xsl:template>

<xsl:template match="fx:givenName"><foaf:givenname><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:givenname></xsl:template>

<xsl:template match="fx:geekcode"><foaf:geekcode><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:geekcode></xsl:template>

<xsl:template match="fx:linkedWith" /> <!--dunno how this works-->

<xsl:template match="fx:myersBriggs"><foaf:myersBriggs><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:myersBriggs></xsl:template>

<xsl:template match="fx:familyName"><foaf:family_name><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:family_name></xsl:template>

<xsl:template match="fx:dnaChecksum"><foaf:dnaChecksum><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:dnaChecksum></xsl:template>
<!--support even the jokes, yes-->

<xsl:template match="fx:logo" /> <!--dunno how this works-->

<xsl:template match="fx:workplaceHomepage"><foaf:workplaceHomepage><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:workplaceHomepage></xsl:template>

<xsl:template match="fx:sha1" /> <!--dunno how this works-->

<xsl:template match="fx:topic"><foaf:topic><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:topic></xsl:template>

<xsl:template match="fx:workInfoHomepage"><foaf:workInfoHomepage><xsl:call-template name="srcAtts"/><xsl:apply-templates /></foaf:workInfoHomepage></xsl:template>

<xsl:template match="fx:phone"><foaf:phone><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:phone></xsl:template>

<xsl:template match="fx:title"><foaf:title><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:title></xsl:template>

<xsl:template match="fx:page"><foaf:page><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:page></xsl:template>

<xsl:template match="fx:schoolHomepage"><foaf:schoolHomepage><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:schoolHomepage></xsl:template>

<xsl:template match="fx:homepage"><foaf:homepage><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:homepage></xsl:template>

<xsl:template match="fx:nick"><foaf:nick><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:nick></xsl:template>

<xsl:template match="fx:theme"><foaf:theme><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:theme></xsl:template>


<xsl:template match="fx:knows" >

<xsl:for-each select="*">
<foaf:knows>
<xsl:apply-templates />
</foaf:knows>
</xsl:for-each>

</xsl:template>

<xsl:template match="fx:weblog"><foaf:weblog><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:weblog></xsl:template>

<xsl:template match="fx:jabberID"><foaf:jabberID><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:jabberID></xsl:template>

<xsl:template match="fx:interest"><foaf:interest><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:interest></xsl:template>

<xsl:template match="fx:plan"><foaf:plan><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:plan></xsl:template>

<xsl:template match="fx:aimChatID"><foaf:aimChatID><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:aimChatID></xsl:template>

<xsl:template match="fx:topic_interest"><foaf:topicInterest><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:topicInterest></xsl:template>

<xsl:template match="fx:made"><foaf:made><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:made></xsl:template>

<xsl:template match="fx:msnChatID"><foaf:msnChatID><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:msnChatID></xsl:template>

<xsl:template match="fx:publications"><foaf:publications><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:publications></xsl:template>

<xsl:template match="fx:iChatID"><foaf:iChatID><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></foaf:iChatID></xsl:template>

<xsl:template match="fx:img"><foaf:img><xsl:call-template name="srcAtts"/><xsl:apply-templates /></foaf:img></xsl:template>


<xsl:template name="hrefAtts">
<xsl:if test="@href"><xsl:attribute name="rdf:resource"><xsl:value-of select="@href"/></xsl:attribute></xsl:if>
<xsl:if test="@ID"><xsl:attribute name="rdf:ID"><xsl:value-of select="@ID"/></xsl:attribute></xsl:if>
</xsl:template>

<xsl:template name="srcAtts">
<xsl:if test="@href"><xsl:attribute name="rdf:resource"><xsl:value-of select="@href"/></xsl:attribute></xsl:if>
<xsl:if test="@ID"><xsl:attribute name="rdf:ID"><xsl:value-of select="@ID"/></xsl:attribute></xsl:if>
</xsl:template>


<!--RDF bits-->

<xsl:template match="fx:description"><rdf:Description><xsl:call-template name="rdfAtts"/><xsl:apply-templates /></rdf:Description></xsl:template>

<xsl:template match="fx:isDefinedBy"><rdf:isDefinedBy><xsl:call-template name="rdfAtts"/><xsl:apply-templates /></rdf:isDefinedBy></xsl:template>

<xsl:template match="fx:seeAlso"><rdfs:seeAlso><xsl:call-template name="rdfAtts"/><xsl:apply-templates /></rdfs:seeAlso></xsl:template>

<xsl:template name="rdfAtts">
<xsl:if test="@href"><xsl:attribute name="rdf:resource"><xsl:value-of select="@href"/></xsl:attribute></xsl:if>
<xsl:if test="@ID"><xsl:attribute name="rdf:ID"><xsl:value-of select="@ID"/></xsl:attribute></xsl:if>
</xsl:template>

<!--RSS bits-->

<xsl:template match="rss:channel"><rss:channel><xsl:call-template name="hrefAtts"/><xsl:apply-templates /></rss:channel></xsl:template>



<!--Dublin Core bits-->

<xsl:template match="dc:title"><dc:title><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:title></xsl:template>

<xsl:template match="dc:creator"><dc:creator><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:creator></xsl:template>

<xsl:template match="dc:subject"><dc:subject><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:subject></xsl:template>

<xsl:template match="dc:description"><dc:description><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:description></xsl:template>

<xsl:template match="dc:publisher"><dc:publisher><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:publisher></xsl:template>

<xsl:template match="dc:contributor"><dc:contributor><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:contributor></xsl:template>

<xsl:template match="dc:date"><dc:date><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:date></xsl:template>

<xsl:template match="dc:type"><dc:type><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:type></xsl:template>

<xsl:template match="dc:format"><dc:format><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:format></xsl:template>

<xsl:template match="dc:identifier"><dc:identifier><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:identifier></xsl:template>

<xsl:template match="dc:source"><dc:source><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:source></xsl:template>

<xsl:template match="dc:language"><dc:language><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:language></xsl:template>

<xsl:template match="dc:relation"><dc:relation><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:relation></xsl:template>

<xsl:template match="dc:coverage"><dc:coverage><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:coverage></xsl:template>

<xsl:template match="dc:rights"><dc:rights><xsl:call-template name="dcAtts"/><xsl:apply-templates /></dc:rights></xsl:template>

<xsl:template name="dcAtts">
<xsl:if test="@rdf:resource"><xsl:attribute name="href"><xsl:value-of select="@rdf:resource"/></xsl:attribute></xsl:if>
<xsl:if test="@rdf:ID"><xsl:attribute name="ID"><xsl:value-of select="@rdf:ID"/></xsl:attribute></xsl:if>
</xsl:template>


<!--WOT bits-->

<xsl:template match="wot:PubKey"><wot:PubKey><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:PubKey></xsl:template>

<xsl:template match="wot:User"><wot:User><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:User></xsl:template>

<xsl:template match="wot:SigEvent"><wot:SigEvent><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:SigEvent></xsl:template>

<xsl:template match="wot:Endorsement"><wot:Endorsement><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:Endorsement></xsl:template>

<xsl:template match="wot:hex_id"><wot:hex_id><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:hex_id></xsl:template>

<xsl:template match="wot:length"><wot:length><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:length></xsl:template>

<xsl:template match="wot:fingerprint"><wot:fingerprint><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:fingerprint></xsl:template>

<xsl:template match="wot:identity"><wot:identity><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:identity></xsl:template>

<xsl:template match="wot:signed"><wot:signed><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:signed></xsl:template>

<xsl:template match="wot:sigdate"><wot:sigdate><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:sigdate></xsl:template>

<xsl:template match="wot:signerLongHexID"><wot:signerLongHexID><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:signerLongHexID></xsl:template>

<xsl:template match="wot:pubkeyAddress"><wot:pubkeyAddress><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:pubkeyAddress></xsl:template>

<xsl:template match="wot:assurance"><wot:assurance><xsl:call-template name="wotAtts"/><xsl:apply-templates /></wot:assurance></xsl:template>

<xsl:template name="wotAtts">
<xsl:if test="@rdf:resource"><xsl:attribute name="href"><xsl:value-of select="@rdf:resource"/></xsl:attribute></xsl:if>
<xsl:if test="@rdf:ID"><xsl:attribute name="ID"><xsl:value-of select="@rdf:ID"/></xsl:attribute></xsl:if>
</xsl:template>






<xsl:template match="*">      <!--preserve unknown components-->    
  <xsl:copy-of select="."/>
</xsl:template>




</xsl:stylesheet>
    