XSLT <xsl:message>要素
完全な XSLT 要素リファレンスマニュアル
定義と使い方
<xsl:message> 要素は出力にメッセージを書き込みます。この要素は主にエラーを報告するために使用されます。
この要素は、他のほぼすべての XSL 要素(<xsl:text>、<xsl:value-of> など)を含むことができます。
terminate 属性を使用すると、エラー発生時に処理を終了するか、続行するかを選択できます。
構文
<xsl:message terminate="yes|no">
<!-- Content:template -->
</xsl:message>
<!-- Content:template -->
</xsl:message>
属性
| 属性 | 值 | 説明 |
|---|---|---|
| terminate | yes no |
任意。"yes": メッセージが出力に書き込まれた後、処理を終了します。"no": メッセージが出力に書き込まれた後、処理を続行します。既定値は "no" です。 |
例 1
artist が空文字列かどうかを確認します。空文字列の場合は、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 要素リファレンスマニュアル その他の拡張