XSLT <xsl: application-Templates>
❮ استكمال مرجع عنصر XSLT
التعريف والاستخدام
يطبق العنصر <xsl: application-template> قالبًا على العنصر الحالي أو على العقد الفرعية للعنصر الحالي.
إذا أضفنا سمة تحديد إلى عنصر <xsl: application-Templates> ، فستعالج فقط العنصر الفرعي الذي يتطابق مع قيمة السمة. يمكننا استخدام سمة التحديد لتحديد ترتيب معالجة العقد الفرعية.
بناء الجملة
<xsl:apply-templates select="expression" mode="name">
<!-- Content:(xsl:sort|xsl:with-param)* -->
</xsl:apply-templates>
صفات
Attribute | Value | Description |
---|---|---|
select | expression | Optional. Specifies the nodes to be processed. An asterisk selects the entire node-set. If this attribute is omitted, all child nodes of the current node will be selected |
mode | name | Optional. If there are multiple ways of processing defined for the same element, distinguishes among them |
مثال 1
قم بلف عنصر h1 واحد حول كل عنصر عنوان في المستند:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="title">
<h1><xsl:apply-templates/></h1>
</xsl:template>
</xsl:stylesheet>
مثال 2
قم بلف عنصر h1 واحد حول جميع عناصر العنوان التي هي عناصر فرعية للرسالة:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="message">
<h1><xsl:apply-templates select="title"/></h1>
</xsl:template>
</xsl:stylesheet>
مثال 3
قم بلف عنصر h1 واحد حول جميع العقد الفرعية للرسالة التي تم تعيين سمة الوضع لها على "كبير":
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="message">
<h1><xsl:apply-templates select="*" mode="big"/></h1>
</xsl:template>
</xsl:stylesheet>
❮ استكمال مرجع عنصر XSLT