عنصر <xsl:attribute> في XSLT
التعريف والاستخدام
يستخدم عنصر <xsl:attribute> لإضافة خاصية إلى العنصر.
ملاحظة:عنصر <xsl:attribute> سيحل محل الخاصية التي تحمل نفس الاسم.
القواعد
<xsl:attribute name="attributename" namespace="uri"> <!-- Content:template --> </xsl:attribute>
خصائص
خصائص | القيمة | وصف |
---|---|---|
name | attributename | مطلوب. تحديد اسم الخاصية. |
namespace | URI | اختياري. تحديد URI لمساحة الاسم للخصائص. |
مثال
مثال 1
إضافة خاصية source إلى عنصر picture:
<picture> <xsl:attribute name="source"/> </picture>
مثال 2
إضافة خاصية source إلى عنصر picture واستخدام القيمة من "images/name" لتعيينها:
<picture> <xsl:attribute name="source"> <xsl:value-of select="images/name" /> </xsl:attribute> </picture>
مثال 3
إنشاء مجموعة خصائص يمكن تطبيقها على أي عنصر输出来:
<xsl:attribute-set name="font"> <xsl:attribute name="fname">Arial</xsl:attribute> <xsl:attribute name="size">14px</xsl:attribute> <xsl:attribute name="color">red</xsl:attribute> </xsl:attribute-set>