Tecla XSLT () Función
❮ Referencia de funciones XSLTDefinición y uso
La función key() devuelve un conjunto de nodos del documento, utilizando el índice especificado por un elemento <xsl:key>.
Sintaxis
node-set key(string, object)
Parámetros
Parameter | Description |
---|---|
string | Required. Specifies the name of an xsl:key element |
object | Required. A string to search for |
Ejemplo 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>
Ver el archivo XML , Ver el archivo XSL y Ver el resultado .
❮ Referencia de funciones XSLT