ฟังก์ชัน generate-id() ของ XSLT

การประกาศและการใช้งาน

generate-id() ฟังก์ชันคืนค่าของตัวว่างที่เป็นหลักการชื่อจุดเริ่มต้นที่กำหนด

ถ้ากลุ่มจุดเริ่มต้นที่กำหนดเป็นว่าง ก็จะคืนค่าตัวว่าง ถ้าละเลยประกาศ node-set ก็จะเป็นค่าเริ่มต้นในจุดเริ่มต้นปัจจุบัน

การใช้งาน

string generate-id(node-set?)

ประกาศ

ประกาศ คำอธิบาย
node-set ให้เลือกตามความต้องการ。กำหนด id แห่งกลุ่มจุดเริ่มต้นที่จะสร้าง

ตัวอย่าง

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h3>Artists:</h3>
<ul>
<xsl:for-each select="catalog/cd">
<li>
<a href="#{generate-id(artist)}
<xsl:value-of select="artist" /></a>
</li>
</xsl:for-each>
</ul>
<hr />
<xsl:for-each select="catalog/cd">
Artist: <a name="{generate-id(artist)}
<xsl:value-of select="artist" /></a>
<br />
Title: <xsl:value-of select="title" />
<br />
Price: <xsl:value-of select="price" />
<hr />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

ดูไฟล์ XSL,ดูไฟล์ XSL,ดูผลลัพธ์.