ایکس ایس ایل ٹی <xsl:apply-templates> نیود

<xsl:apply-templates> ਐਲੀਮੈਂਟ ਇੱਕ ਟੈਮਪਲੇਟ ਨੂੰ ਮੌਜੂਦਾ ਐਲੀਮੈਂਟ ਜਾਂ ਮੌਜੂਦਾ ਐਲੀਮੈਂਟ ਦੇ ਉਪ-ਐਲੀਮੈਂਟਾਂ 'ਤੇ ਲਾਗੂ ਕਰ ਸਕਦਾ ਹੈ。

<xsl:apply-templates> ਐਲੀਮੈਂਟ

<xsl:apply-templates> ਐਲੀਮੈਂਟ ਇੱਕ ਟੈਮਪਲੇਟ ਨੂੰ ਮੌਜੂਦਾ ਐਲੀਮੈਂਟ ਜਾਂ ਮੌਜੂਦਾ ਐਲੀਮੈਂਟ ਦੇ ਉਪ-ਐਲੀਮੈਂਟਾਂ 'ਤੇ ਲਾਗੂ ਕਰ ਸਕਦਾ ਹੈ。

ਜੇਕਰ ਅਸੀਂ <xsl:apply-templates> ਐਲੀਮੈਂਟ ਵਿੱਚ ਇੱਕ select ਵਿਸ਼ੇਸ਼ਤਾ ਜੋੜੀਏ, ਤਾਂ ਇਹ ਸਿਰਫ਼ ਉਸ ਵਿਸ਼ੇਸ਼ਤਾ ਨਾਲ ਮੇਲ ਖਾਣ ਵਾਲੇ ਉਪ-ਐਲੀਮੈਂਟਾਂ ਨੂੰ ਹੀ ਪ੍ਰਬੰਧਿਤ ਕਰੇਗਾ। ਅਸੀਂ select ਵਿਸ਼ੇਸ਼ਤਾ ਨੂੰ ਉਪ-ਐਲੀਮੈਂਟਾਂ ਦੇ ਪ੍ਰਬੰਧਨ ਕਰਨ ਦੀ ਕਿਸਮ ਨਿਰਧਾਰਤ ਕਰ ਸਕਦੇ ਹਾਂ。

ਕੀਤੇ ਹੋਏ XSL ਸਟਾਈਲ ਸ਼ੇਅਰ ਕਰੋ:

<?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">
Title: <span style="color:#ff0000">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
<xsl:template match="artist">
Artist: <span style="color:#00ff00">艺术家: </span>
<xsl:value-of select="."/></span>
<br />
</xsl:template>
</xsl:stylesheet>

查看此XML文件查看此XSL文件查看结果