only for RuBoard |
xsl:message raises a message in a way that's dependent on the XSLT processor. For MSXML 3.0 and higher, this causes a message to either be sent to the message buffer or a message dialog box, depending on the environment in which the element call is made.
For MSXML 3.0 and the preview release of MSXML 4.0, if the value of the terminate attribute is no , the call is ignored. If the value of the terminate attribute is yes , the message results in a trappable error.
For the .NET base classes, the xsl:message element does not cause a trappable error. Instead, the message is output to the default message handler. For a Windows application project, the default handler is the output window. For a Console application, the default handler is the console window. For web forms applications, the message is suppressed.
The default handler can be overridden in .NET. See the .NET SDK documentation for information on the DefaultTraceListener class.
Attribute Name | Enforced | Description | Values |
---|---|---|---|
terminate | Required | Specifies if the XSLT processor should halt processing | Either yes or no |
Consider the following XML document, links.xml :
<?xml version="1.0" encoding="UTF-8" ?> <links> <link name="NewRiders.com" URL="http://www.newriders.com/">"http:// www.newriders.com" /> <link name="Xmlandasp.net" URL="http://www.xmlandasp.net" /> <link name="MSDN Online Library" URL="http://msdn.microsoft.com/library" /> </links>
The following stylesheet fragment would act differently when parsed with MSXML 4.0 versus being parsed with the .NET base classes. The MSXML parser would generate an error, with the error text being, "The Xmlandasp.net node was reached," while the .NET classes would send the same message to the default trace listener.
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <table> <xsl:apply-templates /> </table> </xsl:template> <xsl:template match="links/link"> <tr> <td> <xsl:choose> <xsl:when test="@name='Xmlandasp.net'"> <xsl:message terminate="yes">The Xmlandasp.net node was reached</xsl:message> </xsl:when> <xsl:otherwise> <xsl:value-of select="@name" /> </xsl:otherwise> </xsl:choose> </td> </tr> </xsl:template> </xsl:stylesheet>
The MSXML Parser would not return any text as the result of the transformation. The .NET parser would return text up until the message was generated. If the terminate attribute is changed to have a value of no , the MSXML Parser would ignore the element. The .NET classes would emit the message to the default trace listener and continue processing past the message.
Any element where the content is a template.
Any element that can occur in a template.
only for RuBoard |