XSLT <xsl:apply-templates> Elemanı

<xsl:apply-templates> elementi, bir modeli mevcut element veya mevcut elementin alt nodlarına uygulamak için kullanılır.

<xsl:apply-templates> elementi

<xsl:apply-templates> elementi, bir modeli mevcut element veya mevcut elementin alt nodlarına uygulamak için kullanılır.

Eğer <xsl:apply-templates> elementine bir select özelliği eklersek, bu element sadece özellik değerine uyacak olan alt elementleri işlemek için kullanılır. Select özelliğini kullanarak alt düğümün işleme sırasını belirleyebiliriz.

Aşağıdaki XSL tarz tablosunu görün:

<?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>
<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">
Başlık: <span style="color:#ff0000">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
<xsl:template match="artist">
Sanatçı: <span style="color:#00ff00">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
</xsl:stylesheet>

Bu XML dosyasını gör,Bu XSL dosyasını gör,Sonuçları Gör.