XSLT key() Funzione
❮ Riferimento alla funzione XSLTDefinizione e utilizzo
La funzione key() restituisce un set di nodi dal documento, utilizzando l'indice specificato da un elemento <xsl:key>.
Sintassi
node-set key(string, object)
Parametri
Parameter | Description |
---|---|
string | Required. Specifies the name of an xsl:key element |
object | Required. A string to search for |
Esempio 1
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="cdlist" match="cd" use="title" />
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="key('cdlist', 'Empire Burlesque')">
<p>
Title: <xsl:value-of select="title" />
<br />
Artist: <xsl:value-of select="artist" />
<br />
Price: <xsl:value-of select="price" />
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Visualizza il file XML , Visualizza il file XSL e Visualizza il risultato .
❮ Riferimento alla funzione XSLT