XSLT <xsl:message>
❮完全なXSLT要素リファレンス
定義と使用法
<xsl:message>要素は、出力にメッセージを書き込みます。この要素は、主にエラーを報告するために使用されます。
この要素には、他のほとんどすべてのXSL要素(<xsl:text>、<xsl:value-of>など)を含めることができます。
終了属性を使用すると、エラーが発生したときに処理を終了するか続行するかを選択できます。
構文
<xsl:message terminate="yes|no">
<!-- Content:template -->
</xsl:message>
属性
Attribute | Value | Description |
---|---|---|
terminate | yes no |
Optional. "yes" terminates the processing after the message is written to the output. "no" continues the processing after the message is written to the output. Default is "no". |
例1
アーティストが空の文字列かどうかを確認します。はいの場合、XSLプロセッサーを終了し、メッセージを表示します。
<?xml version="1.0" encoding="UTF-8"?>
<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要素リファレンス