ฟังก์ชัน function-available() ใน XSLT
คำอธิบายและการใช้งาน
ฟังก์ชัน function-available() คืนค่า boolean ที่บอกว่ามี XSLT ฮานด์ลอร์เละสนับสนุนฟังก์ชันที่กำหนด
คุณสามารถทดสอบฟังก์ชัน XSLT และ XPath ที่สืบทอดมาได้
ศัพท์คำ
boolean function-available(string)
ประกาศ
ประกาศ | รายละเอียด |
---|---|
string | จำเป็นต้องกำหนดฟังก์ชันที่ต้องการทดสอบ |
ตัวอย่าง
<?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> <xsl:choose> <xsl:when test="function-available('sum')"> <p>sum() สนับสนุน。</p> </xsl:when> <xsl:otherwise> <p>sum() ไม่สนับสนุน。</p> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="function-available('current')"> <p>current() สนับสนุน。</p> </xsl:when> <xsl:otherwise> <p>current() is not supported.</p> </xsl:otherwise> </xsl:choose> </body> </html> </xsl:template> </xsl:stylesheet>