Phím XSLT () Hàm
❮ Tham chiếu chức năng XSLTĐịnh nghĩa và Cách sử dụng
Hàm key () trả về một tập hợp nút từ tài liệu, sử dụng chỉ mục được chỉ định bởi phần tử <xsl: key>.
Cú pháp
node-set key(string, object)
Thông số
Parameter | Description |
---|---|
string | Required. Specifies the name of an xsl:key element |
object | Required. A string to search for |
ví dụ 1
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="cdlist" match="cd" use="title" />
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="key('cdlist', 'Empire Burlesque')">
<p>
Title: <xsl:value-of select="title" />
<br />
Artist: <xsl:value-of select="artist" />
<br />
Price: <xsl:value-of select="price" />
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Xem tệp XML , Xem tệp XSL và Xem kết quả .
❮ Tham chiếu chức năng XSLT