องค์ประกอบ <xsl:message> ของ XSLT
การระบุและการใช้งาน
องค์ประกอบ <xsl:message> สามารถเขียนข้อความไปยังออกโดยตรง
องค์ประกอบนี้สามารถรวมองค์ประกอบ XSL อื่นๆ ของทุกประเภทเกือบทั้งหมด (<xsl:text> 、<xsl:value-of> และอื่นๆ)
คุณสมบัติ terminate อนุญาตให้คุณเลือกว่าควรหยุดการแปลงเมื่อเกิดข้อผิดพลาดหรือไม่
ภาษาที่ใช้
<xsl:message terminate="yes|no"> <!-- Content:template --> </xsl:message>
คุณสมบัติ
คุณสมบัติ | ค่า | คำอธิบาย |
---|---|---|
terminate |
|
ตัวเลือกต่อไป |
ตัวอย่าง
ตัวอย่าง 1
ตรวจสอบว่า artist คือข้อความว่างหรือไม่
<?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:for-each select="catalog/cd"> <p>Title: <xsl:value-of select="title"/><br /> Artist: <xsl:if test="artist=''"> <xsl:message terminate="yes"> Error: Artist is an empty string! </xsl:message> </xsl:if> <xsl:value-of select="artist"/> </p> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>