XSLT Rules

<xsl:template match="/rdf:RDF/foaf:Person[@foaf:first and @foaf:surname]">
  <rdf:RDF>
    <foaf:Person>
      <!-- copy attributes -->
      <xsl:apply-templates mode="copy" select="@*"/>

      <!-- add inferred givenName and familyName -->
      <xsl:attribute name="pim:givenName">
        <xsl:value-of select="@foaf:first" />
      <xsl:attribute name="pim:givenName">
      <xsl:attribute name="pim:familyName">
        <xsl:value-of select="@foaf:family" />
      <xsl:attribute name="pim:familyName">

      <!-- copy children -->
      <xsl:apply-templates mode="copy" select="*"/>
    </foaf:Person>
  </rdf:RDF>
</xsl:template>

<xsl:template match="*">
  <xsl:apply-templates mode="copy" />
</xsl:template>

<xsl:template mode="copy" match="*|@*|comment()|text()">
  <xsl:copy>
    <xsl:apply-templates mode="copy" select="*|@*|comment()|text()"/>
  </xsl:copy>
</xsl:template>