Source de coloration.xsl
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0">
<xsl:output method="xml" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="yes" />
<!-- Le cadre HTML -->
<xsl:template match="/">
<html>
</xsl:template><head>
<title>Coloration</title>
<meta name="robots" content="noindex" />
<link rel="stylesheet" type="text/css" href="coloration.css" />
</head><body>
</html><div class="encart">
<p>
Cette page est produite dans le cadre d'exercices sur XSLT. Son contenu n'est peut-être pas pertinent.
</p><ul>
</div><li>
retour aux <a href="https://fabien-torre.fr/Enseignement/tp/XML/Corrections/">solutions des exercices XML</a>
</li><li>
retour aux <a href="https://fabien-torre.fr/Enseignement/tp/XML/XSLT/">exercices XSLT</a>
</li><li>
</ul>retour à la page de <a href="https://fabien-torre.fr/">Fabien Torre</a>
</li><div class="instruction">
<?xml version="1.0" ?>
</div>
<xsl:apply-templates />
</body>
<!-- Tranformation des éléments -->
<xsl:template name="baliseouvrante">
<xsl:param name="noeud" />
<span class="langagexml">
<<xsl:value-of select="name($noeud)" />
</span><xsl:apply-templates select="$noeud/@*" />
<span class="langagexml">></span>
</xsl:template><xsl:template name="balisefermante">
<xsl:param name="noeud" />
<span class="langagexml">
</xsl:template></<xsl:value-of select="name($noeud)" />>
</span><xsl:template name="baliseouvrantefermante">
<xsl:param name="noeud" />
<span class="langagexml">
<<xsl:value-of select="name($noeud)" />
</span><xsl:apply-templates select="$noeud/@*" />
<xsl:text disable-output-escaping="yes"> /</xsl:text>
<span class="langagexml">></span>
</xsl:template><xsl:template match="*">
<xsl:variable name="fils" select="node()" />
<div class="blocelement">
</xsl:template><xsl:choose>
</div><xsl:when test="count($fils)>0">
<xsl:variable name="nbtextes" select="count(text()[normalize-space(.) != ''])" />
<xsl:call-template name="baliseouvrante">
<xsl:with-param name="noeud" select="." />
</xsl:call-template><xsl:choose>
<xsl:when test="(count($fils)>=2) and ($nbtextes>=1)">
<div class="contenumixte">
</xsl:when><xsl:apply-templates mode="mixte" />
</div><xsl:otherwise>
</xsl:choose><xsl:apply-templates />
</xsl:otherwise><xsl:call-template name="balisefermante">
</xsl:when><xsl:with-param name="noeud" select="." />
</xsl:call-template><xsl:otherwise>
</xsl:choose><xsl:call-template name="baliseouvrantefermante">
</xsl:otherwise><xsl:with-param name="noeud" select="." />
</xsl:call-template><xsl:template match="*" mode="mixte">
<xsl:variable name="fils" select="node()" />
<xsl:choose>
</xsl:template><xsl:when test="count($fils)>0">
<xsl:call-template name="baliseouvrante">
<xsl:with-param name="noeud" select="." />
</xsl:call-template><xsl:apply-templates mode="mixte" />
<xsl:call-template name="balisefermante">
</xsl:when><xsl:with-param name="noeud" select="." />
</xsl:call-template><xsl:otherwise>
</xsl:choose><xsl:call-template name="baliseouvrantefermante">
</xsl:otherwise><xsl:with-param name="noeud" select="." />
</xsl:call-template>
<!-- Sortie des attributs -->
<xsl:template match="@*">
<xsl:text disable-output-escaping="yes"> </xsl:text>
<xsl:value-of select="name()" />=<span class="valeur">"<xsl:value-of select="." />"</span>
</xsl:template>
<!-- Sortie des commentaires -->
<xsl:template match="comment()">
<div class="commentaire">
</xsl:template>
<!-- <xsl:value-of select="." /> -->
</div>
<!-- Sortie des instructions -->
<xsl:template match="processing-instruction()">
<div class="instruction">
</xsl:template>
<?<xsl:value-of select="name() " />
<xsl:text disable-output-escaping="yes"> </xsl:text>
<xsl:value-of select="." />?>
</div>
<!-- Sortie des noeuds textuels -->
<xsl:template match="text()">
<xsl:choose>
</xsl:template><xsl:when test="string-length(.)>60">
<div class="texte">
</xsl:when><xsl:value-of select="." />
</div><xsl:otherwise>
</xsl:choose><span class="texte">
</xsl:otherwise><xsl:value-of select="." />
</span><xsl:template match="text()" mode="mixte">
</xsl:stylesheet><span class="texte">
</xsl:template><xsl:value-of select="." />
</span>