XSLT <XSL: ข้อความ> องค์ประกอบ
ความหมายและการใช้งาน
<xsl: ข้อความ> องค์ประกอบการส่งออกเขียนข้อความ องค์ประกอบนี้ถูกนำมาใช้เป็นหลักในการรายงานข้อผิดพลาด
องค์ประกอบนี้สามารถมีเกือบทุกองค์ประกอบ XSL อื่น ๆ (<XSL: ข้อความ>, <XSL: ค่าของ> อื่น ๆ )
ยุติแอตทริบิวต์ช่วยให้คุณสามารถเลือกเมื่อเกิดความผิดพลาดกระบวนการคือการออกหรือยังคงรักษา
ไวยากรณ์
<xsl:message terminate="yes|no">
<!-- Content:template -->
</xsl:message>
<!-- Content:template -->
</xsl:message>
คุณสมบัติ
属性 | 值 | 描述 |
---|---|---|
terminate | yes no |
可选。"yes":在消息写入输出后,终止处理。"no":在消息写入输出后,继续进行处理。默认是 "no"。 |
ตัวอย่างที่ 1
ตรวจหาว่าศิลปินเป็นสตริงที่ว่างเปล่า ถ้าใช่แล้วออกจากหน่วยประมวลผล XSL และแสดงข้อความ:
<?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>
<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>
คู่มือการใช้งาน XSLT ธาตุอ้างอิงที่สมบูรณ์