<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
    xmlns:foaf="http://xmlns.com/foaf/0.1/" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:doap="http://usefulinc.com/ns/doap#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    version="1.0">
    <xsl:output
              encoding="UTF-8"
              method="html"
              doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
              doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>    
    <xsl:template match="/">
        <xsl:apply-templates select="/rdf:RDF/doap:Project"/>
    </xsl:template>
    <xsl:template match="doap:programming-language">
        <em><xsl:value-of select="."/></em><xsl:if test="position() != last()">, </xsl:if>
    </xsl:template>
    <xsl:template match="doap:download-page">
        <p><b>Download</b>: <a href="{@rdf:resource}">link</a></p>
    </xsl:template>
    <xsl:template match="doap:license">
        <p><b>License</b>: <a href="{@rdf:resource}"><xsl:value-of select="@rdf:resource"/></a></p>
    </xsl:template>
    <xsl:template match="foaf:Person">
        <li>
            <xsl:choose>
                <xsl:when test="rdfs:seeAlso">
                    <a href="{rdfs:seeAlso/@rdf:resource}"><xsl:value-of select="foaf:name"/></a>
                </xsl:when>
                <xsl:when test="foaf:homepage">
                    <a href="{foaf:homepage/@rdf:resource}"><xsl:value-of select="foaf:name"/></a>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="foaf:name"/>
                </xsl:otherwise>
            </xsl:choose>            
        </li>
    </xsl:template>
    <xsl:template match="doap:Project">
        <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
                <title><xsl:value-of select="doap:name"/></title>
            </head>
            <body>
                <div class="head"><a href="/" title="W3C Home"><img
                    height="48" width="72" alt="W3C" src="/Icons/w3c_home" /></a></div>
                <h1><xsl:value-of select="doap:name"/></h1>
                <p>This is an RDF graph, a <b>D</b>escription <b>o</b>f <b>a</b> <b>P</b>roject (<b>DOAP</b>): See: <a href="http://usefulinc.com/ns/doap#">Description of a Project (DOAP) vocabulary</a> and <a href="http://usefulinc.com/doap/">DOAP home page</a>.  The graph describes <a href="{doap:download-page/@rdf:resource}"><xsl:value-of select="doap:name"/></a></p>
                <blockquote><em><xsl:value-of select="doap:shortdesc"/></em></blockquote>
                <p><b>Programming languages</b>: <xsl:apply-templates select="doap:programming-language"/></p>
                <xsl:apply-templates select="doap:license"/>                
                <h2>Developers:</h2>
                <ul>
                    <xsl:apply-templates select="doap:developer/foaf:Person"/>
                </ul>
                <h2>References:</h2>
                <ul>
                    <xsl:for-each select="rdfs:seeAlso/@rdf:resource">
                        <li><a href="{.}"><xsl:value-of select="."/></a></li>
                    </xsl:for-each>
                </ul>
                <hr/>
                <small><xsl:value-of select="rdfs:comment"/></small>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>