当前位置: 首页 > 网络学院 > XML相关教程 > XSL/XSLT > XSLT <xsl:message> 元素

XSL/XSLT
XSL 语言
XSLT 介绍
XSLT 浏览器
XSLT 转换
<xsl:template>
<xsl:value-of>
<xsl:for-each>
<xsl:sort>
<xsl:if>
<xsl:choose>
<xsl:apply-templates>
XSLT - 客户端
XSLT - 服务器端
XSLT - 编辑XML
XSLT 摘要
XSLT 元素参考
XSLT 函数
XSL 编辑器

XSL/XSLT 中的 XSLT <xsl:message> 元素


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 217 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The <xsl:message> element writes a message to the output. This element is primarily used to report errors.
<xsl:message>元素的作用是:向输出结果中写入一段消息。该元素主要是用来进行错误报告的。

This element can contain almost any other XSL element (<xsl:text>, <xsl:value-of>, etc.).
这个元素可以包含所有其它的XSL元素(如:<xsl:text>、<xsl:value-of>等等)

The terminate attribute gives you the choice to either quit or continue the processing when an error occurs.
当出现错误时,terminate[终止]属性可以提供给你可选择的操作:1、放弃执行程序;2、继续执行程序。


Syntax
语法

<xsl:message terminate="yes|no">
 <!-- Content:template -->
</xsl:message>

Attributes
属性

属性 描述
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".
可选参数。如果设置为"yes",那么在消息写入输出框之后终止运行程序;如果设置为“no”,那么将在消息写入输出框之后继续执行程序。默认为“no”。

Example 1
案例1

Check if artist is an empty string. If yes, we quit the XSL processor and display a message:
检查artist是否为一个空字符串。如果是“yes”,我们将放弃执行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>

评论 (0) All

登陆 | 还没注册?