XSLT <XSL: แอตทริบิวต์> องค์ประกอบ
ความหมายและการใช้งาน
<xsl: แอตทริบิวต์> องค์ประกอบที่จะใช้ในการเพิ่มแอตทริบิวต์องค์ประกอบ
หมายเหตุ: <XSL: แอตทริบิวต์> องค์ประกอบแทนที่แอตทริบิวต์ที่มีอยู่ที่มีชื่อเดียวกัน
ไวยากรณ์
<xsl:attribute name="attributename" namespace="uri">
<!-- Content:template -->
</xsl:attribute>
<!-- Content:template -->
</xsl:attribute>
คุณสมบัติ
属性 | 值 | 描述 |
---|---|---|
name | attributename | 必需。规定属性的名称。 |
namespace | URI | 可选。为属性定义命名空间的 URI。 |
ตัวอย่างที่ 1
การเพิ่มคุณลักษณะองค์ประกอบที่มาภาพ:
<picture>
<xsl:attribute name="source"/>
</picture>
<xsl:attribute name="source"/>
</picture>
ตัวอย่างที่ 2
การเพิ่มองค์ประกอบภาพแอตทริบิวต์ของแหล่งที่มาและใช้ "images / ชื่อ" มูลค่าของงานของพวกเขา:
<picture>
<xsl:attribute name="source">
<xsl:value-of select="images/name" />
</xsl:attribute>
</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>
<xsl:attribute name="fname">Arial</xsl:attribute>
<xsl:attribute name="size">14px</xsl:attribute>
<xsl:attribute name="color">red</xsl:attribute>
</xsl:attribute-set>
คู่มือการใช้งาน XSLT ธาตุอ้างอิงที่สมบูรณ์