template
XSLT <xsl:template> elementi
❮ To‘liq XSLT elementlari ma’lumotnomasi
Ta’rif va qo‘llanilishi
<xsl:template> elementi ko‘rsatilgan tugun mos kelganda qo‘llaniladigan qoidalarni o‘z ichiga oladi.
match atributi shablonni XML elementi bilan bog‘lash uchun ishlatiladi. match atributidan XML hujjatning butun bir tarmog‘i uchun shablon belgilashda ham foydalanish mumkin (ya’ni match="/" butun hujjatni belgilaydi).
Eslatma: <xsl:template> yuqori darajadagi elementdir.
Sintaksis
<xsl:template
name="name"
match="pattern"
mode="mode"
priority="number">
<!-- Content:(<xsl:param>*,template) -->
</xsl:template>Atributlar
| Atribut | Qiymat | Tavsif |
|---|---|---|
| name | name | Ixtiyoriy. Shablon uchun nom belgilaydi. Eslatma: Agar bu atribut ko‘rsatilmasa, match atributi bo‘lishi shart |
| match | pattern | Ixtiyoriy. Shablon uchun moslik andozasi (match pattern). Eslatma: Agar bu atribut ko‘rsatilmasa, name atributi bo‘lishi shart |
| mode | mode | Ixtiyoriy. Ushbu shablon uchun rejimni (mode) belgilaydi |
| priority | number | Ixtiyoriy. Shablonning sonli ustuvorligini bildiruvchi son |
Misol
<?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>XML faylni ko‘rish, XSL faylni ko‘rish va Natijani ko‘rish.
❮ To‘liq XSLT elementlari ma’lumotnomasi
W3Schools Pathfinder
Yutuqlaringizni kuzating – bu bepul!
