<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 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:harry="http://www.owl-ontologies.com/harrypotter.owl#" version="1.0">
    <xsl:output method="html" encoding="UTF-8" indent="no"/>
    <xsl:template match="/">
        <html>
            <head>
                <title>Ontologie du monde de Harry Potter</title>
                <meta content="Ontologie du monde de Harry Potter" name="DC.title"/>
                <meta content="Gautier Poupeau" name="DC.creator"/>
                <meta content="2005-11-05" name="DC.date"/>
                <meta content="Ontologie du monde de Harry Potter réalisée pour apprendre à utiliser
                    OWL et protégé; Réalisée en grande partie grâce aux informations du site
                    http://www.poudlard.org." name="DC.description"/>
            </head>
            <body>
                <h1>Ontologie du monde de Harry Potter</h1>
                <!-- <form action="recherche.php" method="get">
                    <p>
                        <label for="nom">Vous cherchez un personnage précis :</label>
                    </p>
                    <p>
                        <input name="nom" id="nom" type="text" size="20"/> (Attention, recherche
                        sensible à la casse)</p>
                    <p>
                        <input name="Chercher le personnage" type="submit"/>
                    </p>
                </form> -->
                <xsl:call-template name="classe">
                    <xsl:with-param name="type">#humain</xsl:with-param>
                </xsl:call-template>
            </body>
        </html>
    </xsl:template>
    <xsl:template name="humain">
        <ul>
            <xsl:variable name="classe" select="ancestor::rdf:Description/@rdf:about"/>
            <xsl:for-each select="//rdf:type[@rdf:resource=$classe]">
                <xsl:if test="preceding-sibling::rdfs:label">
                    <li>
                        <a
                            href="personne.php?personne={substring-after(ancestor::rdf:Description/@rdf:about,'#')}">
                            <xsl:value-of select="preceding-sibling::rdfs:label"/>
                        </a>
                    </li>
                </xsl:if>
                <xsl:if test="following-sibling::rdfs:label">
                    <li>
                        <a
                            href="personne.php?personne={substring-after(ancestor::rdf:Description/@rdf:about,'#')}">
                            <xsl:value-of select="following-sibling::rdfs:label"/>
                        </a>
                    </li>
                </xsl:if>
            </xsl:for-each>
        </ul>
    </xsl:template>
    <xsl:template name="classe">
        <xsl:param name="type"/>
        <ul>
            <xsl:for-each select="//rdfs:subClassOf[@rdf:resource=$type]">
                <xsl:sort select="ancestor::rdf:Description/rdfs:label"/>
                <li>
                    <xsl:value-of select="ancestor::rdf:Description/rdfs:label"/>
                    <xsl:call-template name="humain"/>
                    <xsl:call-template name="classe">
                        <xsl:with-param name="type" select="ancestor::rdf:Description/@rdf:about"/>
                    </xsl:call-template>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:template>
</xsl:stylesheet>
