ล่าสุดการพัฒนาเว็บบทเรียน
 

XSLT <xsl:attribute> Element


<สมบูรณ์ XSLT ธาตุอ้างอิง

ความหมายและการใช้งาน

<xsl:attribute> องค์ประกอบที่จะใช้ในการเพิ่มแอตทริบิวต์องค์ประกอบ

หมายเหตุ: <xsl:attribute> องค์ประกอบแทนที่คุณลักษณะที่มีอยู่กับชื่อเทียบเท่า


วากยสัมพันธ์

<xsl:attribute name="attributename" namespace="uri">

  <!-- Content:template -->

</xsl:attribute>

แอตทริบิวต์

คุณลักษณะ ความคุ้มค่า ลักษณะ
nameattributename จำเป็นต้องใช้ ระบุชื่อของแอตทริบิวต์
namespaceURI ไม่จำเป็น. กำหนด namespace URI สำหรับแอตทริบิวต์

ตัวอย่างที่ 1

เพิ่มแอตทริบิวต์ที่มาองค์ประกอบภาพ:

<picture>
  <xsl:attribute name="source"/>
</picture>

ตัวอย่างที่ 2

เพิ่มแอตทริบิวต์ที่มากับองค์ประกอบภาพและเติมด้วยค่าจาก "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>

<สมบูรณ์ XSLT ธาตุอ้างอิง