<?xml version="1.0"?>
<composition>
<chanson>
<titre>3 nuits par semaine</titre>
<artiste>Indochine </artiste>
</chanson>
<chanson>
<titre>The living daylights</titre>
<artiste>A-Ha</artiste>
</chanson>
<chanson>
<titre>Ceremonia</titre>
<artiste>Indochine</artiste>
</chanson>
<chanson>
<titre>20 years</titre>
<artiste>Placebo</artiste>
</chanson>
</composition>
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="2" cellspacing="2">
<tr>
<td>Titre</td>
<td>Artiste</td>
</tr>
<tr>
<td><xsl:value-of select="composition/chanson/titre"/></td>
<td><xsl:value-of select="composition/chanson/artiste"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<?xml-stylesheet type="text/xsl" href="fichier.xsl"?>

Mais ??? Je voulais que toutes les chansons s'affichent moi ! Il doit y avoir un problème quelque part !
En effet, vous avez demander à ce que soit affiché le contenu d'une balise or il y en avait plusieurs. Votre navigateur n'a pas su laquelle afficher et il n'en a pas affiché ou a indiqué une erreur.Mais comment afficher toutes les chansons?
Pour ce faire, on va utiliser une autre balise "for-each select". Ce qui signifie "pour chaque sélection". Voici le fichier XSL un peu modifié:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="2" cellspacing="2">
<tr>
<td>Titre</td>
<td>Artiste</td>
</tr>
<xsl:for-each select="composition/chanson">
<tr>
<td><xsl:value-of select="titre"/></td>
<td><xsl:value-of select="artiste"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

: Il est évident que l'on peut faire beaucoup plus esthétique en rajoutant de la couleur dans le fond de la cellule mais ce ne sont que des détails.
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="2" cellspacing="2">
<tr>
<td>Titre</td>
<td>Artiste</td>
</tr>
<xsl:for-each select="composition/chanson" order-by="+titre">
<tr>
<td><xsl:value-of select="titre"/></td>
<td><xsl:value-of select="artiste"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
