Latest web development tutorials

XSLT <xsl: message> element

XSLT Elements Reference Manual Complete XSLT Element Reference Manual

Definition and Usage

<Xsl: message> element to the output write a message. This element is primarily used to report errors.

This element can contain almost any other XSL elements (<xsl: text>, <xsl: value-of>, etc.).

terminate attribute allows you to select when an error occurs, the process is to exit or continue treatment.


grammar

<xsl:message terminate="yes|no">

<!-- Content:template -->

</xsl:message>

Attributes

属性 描述
terminate yes
no
可选。"yes":在消息写入输出后,终止处理。"no":在消息写入输出后,继续进行处理。默认是 "no"。

Example 1

Detecting whether the artist is an empty string. If yes, then quit XSL processor, and display a message:

<?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>


XSLT Elements Reference Manual Complete XSLT Element Reference Manual