<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:foaf="http://xmlns.com/foaf/0.1/"
  xmlns:wn="http://xmlns.com/wordnet/1.6/"
  xmlns:pet="http://purl.org/stuff/pets/"
  exclude-result-prefixes="rdf rdfs dc foaf wn">
  <xsl:output
    method="xml"
    version="1.0"
    omit-xml-declaration="no"
    doctype-public="-//W3C//DTD XHTML 1.1//EN"
    doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
    indent="yes"
    encoding="utf-8"/>
  <xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
      <head>
        <meta http-equiv="Content-Language" content="ja" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <link rel="stylesheet" href="css/foaf.css" type="text/css" media="screen,tv,projection" />
        <link rel="index" href="index.html" />
        <link rev="made" href="{rdf:RDF/foaf:Person/foaf:mbox/@rdf:resource}" />
        <title><xsl:value-of select="rdf:RDF/foaf:Person/foaf:nick"/> の FoaF メタデータの HTML によるレンダリング</title>
      </head>
      <body>
        <h1>FoaF of <xsl:value-of select="rdf:RDF/foaf:Person/foaf:nick"/></h1>
        <h2><xsl:value-of select="rdf:RDF/foaf:Person/foaf:nick"/> について</h2>
        <xsl:apply-templates select="rdf:RDF/foaf:Person" />
        <h2><xsl:value-of select="rdf:RDF/foaf:Person/foaf:nick"/> の知ってる人</h2>
        <table summary="知り合い一覧">
          <thead>
            <tr>
              <th scope="col">名前</th>
              <th scope="col">こんな人 / FoaF</th>
              <th scope="col">日記とか blog とか</th>
            </tr>
          </thead>
          <tbody>
            <xsl:apply-templates select="rdf:RDF/foaf:Person/foaf:knows" />
          </tbody>
        </table>
        <address>This is a metadata about the owner of <a href="/">朝顔日記</a>. <a href="/about.html">&#x00A9;2002-2006 by のり</a>.</address>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="rdf:RDF/foaf:Person">
    <div class="photo"><img src="{foaf:depiction/@rdf:resource}" alt="関連画像" title="{foaf:depiction/@dc:title}"/></div>
    <table summary="プロフィールを記述した表">
      <thead>
        <tr><th scope="col">項目</th><th scope="col">値</th></tr>
      </thead>
      <tbody>
        <xsl:for-each select="foaf:nick">
          <tr><th scope="row">nick</th><td><xsl:value-of select="."/></td></tr>
        </xsl:for-each>
        <tr><th scope="row">title</th><td><xsl:value-of select="foaf:title"/></td></tr>
        <tr><th scope="row">mbox</th><td><a href="{foaf:mbox/@rdf:resource}"><xsl:value-of select="foaf:mbox/@rdf:resource"/></a></td></tr>
        <tr><th scope="row">mbox_sha1sum</th><td><xsl:value-of select="foaf:mbox_sha1sum"/></td></tr>
        <tr><th scope="row">homepage</th><td><a href="{foaf:homepage/@rdf:resource}" ><xsl:value-of select="foaf:homepage/@rdf:resource"/></a></td></tr>
        <xsl:for-each select="foaf:weblog">
          <tr><th scope="row">weblog</th><td><a href="{@rdf:resource}"><xsl:value-of select="@dc:title"/></a></td></tr>
        </xsl:for-each>
        <xsl:for-each select="foaf:interest">
          <tr><th scope="row">interest</th><td><a href="{@rdf:resource}"><xsl:value-of select="@dc:title"/></a></td></tr>
        </xsl:for-each>
        <xsl:for-each select="foaf:currentProject">
          <tr><th scope="row">currentProject</th><td><a href="{@rdf:resource}"><xsl:value-of select="@dc:title"/></a></td></tr>
        </xsl:for-each>
        <xsl:for-each select="foaf:workplaceHomepage">
					<tr><th scope="row">workplaceHomepage</th><td><a href="{@rdf:resource}"><xsl:value-of select="@dc:title"/></a></td></tr>
				</xsl:for-each>
        <xsl:for-each select="pet:hasPet/pet:Pet">
				<tr><th scope="row">pet</th><td><a href="{pet:hasProfile/@rdf:resource}"><xsl:value-of select="pet:breed"/><xsl:value-of select="foaf:name" /></a></td></tr>
			</xsl:for-each>
      </tbody>
    </table>
  </xsl:template>

  <xsl:template match="foaf:knows/foaf:Person">
    <tr>
      <th scope="row"><a href="{foaf:homepage/@rdf:resource}" title="{foaf:homepage/@dc:title}"><xsl:value-of select="foaf:nick" /></a> さん</th>
      <td><xsl:value-of select="dc:description"/> <xsl:if test="rdfs:seeAlso/@rdf:resource[not(.='')]"><a href="{rdfs:seeAlso/@rdf:resource}"><img src="img/foaftiny.gif" alt="{foaf:nick}さんのFoaF" title="{foaf:nick}さんのFoaF" /></a></xsl:if></td>
      <td>
        <ul>
          <xsl:for-each select="foaf:weblog">
            <li><a href="{@rdf:resource}"><xsl:value-of select="@dc:title" /></a></li>
          </xsl:for-each>
        </ul>
      </td>


    </tr>
  </xsl:template>
</xsl:stylesheet>
