Elemento XSLT <xsl:apply-templates>
L'elemento <xsl:apply-templates> applica una regola del modello all'elemento corrente o ai nodi figlio dell'elemento corrente.
L'elemento <xsl:apply-templates>
L'elemento <xsl:apply-templates> applica un modello all'elemento corrente o ai nodi figlio dell'elemento corrente.
Se aggiungiamo un attributo "select" all'elemento <xsl:apply-templates>, elaborerà solo gli elementi figlio che corrispondono al valore dell'attributo. Possiamo usare l'attributo "select" per specificare in quale ordine devono essere elaborati i nodi figli.
Guarda il seguente foglio di stile XSL:
Esempio
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="cd">
<p>
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="artist"/>
</p>
</xsl:template>
<xsl:template match="title">
Title: <span style="color:#ff0000">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
<xsl:template match="artist">
Artist: <span style="color:#00ff00">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
</xsl:stylesheet>