XSLT <xsl:apply-templates> Element
Die <xsl:apply-templates> element pas 'n sjabloonreël toe op die huidige element of op die huidige element se kind nodusse.
Die <xsl:apply-templates> Element
Die <xsl:apply-templates> element pas 'n sjabloon toe op die huidige element of op die huidige element se kind nodusse.
As ons 'n "select"-kenmerk by die <xsl:apply-templates>-element voeg, sal dit slegs die kind-elemente verwerk wat ooreenstem met die waarde van die kenmerk. Ons kan die "kies" kenmerk gebruik om te spesifiseer in watter volgorde die kind nodusse verwerk moet word.
Kyk na die volgende XSL-stylblad:
Voorbeeld
<?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>