XSLT generate-id()Fonction
Référence complète des fonctions XSLT
Définition et utilisation
La fonction generate-id() renvoie une valeur de chaîne qui identifie de manière unique le nœud spécifié.
Si l'ensemble de nœuds spécifié est vide, une chaîne vide est renvoyée. Si le paramètre node-set est omis, il prend par défaut le nœud courant.
Syntaxe
string generate-id(node-set?)
Parameters
| Parameters | Description |
|---|---|
| node-set | Facultatif. Spécifie l'ensemble de nœuds pour lequel générer un identifiant unique. |
Exemple 1
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h3>Artistes :</h3>
<ul>
<xsl:for-each select="catalog/cd">
<li>
<a href="../index.html">
<xsl:value-of select="artist" /></a>
</li>
</xsl:for-each>
</ul>
<hr />
<xsl:for-each select="catalog/cd">
Artiste : <a name="{generate-id(artist)}">
<xsl:value-of select="artist" /></a>
<br />
Titre : <xsl:value-of select="title" />
<br />
Prix : <xsl:value-of select="price" />
<hr />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h3>Artistes :</h3>
<ul>
<xsl:for-each select="catalog/cd">
<li>
<a href="../index.html">
<xsl:value-of select="artist" /></a>
</li>
</xsl:for-each>
</ul>
<hr />
<xsl:for-each select="catalog/cd">
Artiste : <a name="{generate-id(artist)}">
<xsl:value-of select="artist" /></a>
<br />
Titre : <xsl:value-of select="title" />
<br />
Prix : <xsl:value-of select="price" />
<hr />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
、 、 。
Référence complète des fonctions XSLT Autres extensions