XsltMessageEncounteredEventArgs Class
.NET Framework 3.0
Provides data for the XsltMessageEncountered event.
Namespace: System.Xml.Xsl
Assembly: System.Xml (in system.xml.dll)
Assembly: System.Xml (in system.xml.dll)
'Declaration Public MustInherit Class XsltMessageEncounteredEventArgs Inherits EventArgs 'Usage Dim instance As XsltMessageEncounteredEventArgs
public abstract class XsltMessageEncounteredEventArgs extends EventArgs
public abstract class XsltMessageEncounteredEventArgs extends EventArgs
Not applicable.
The following example uses the XsltMessageEncounteredEventArgs to display xsl:message content to the console. The sample writes the following message to the console: Message received: Author name is not in the correct format <author><name>Plato</name></author>.
Imports System Imports System.IO Imports System.Xml Imports System.Xml.Xsl Imports System.Xml.XPath Public Class Sample Public Shared Sub Main() ' Create the XslCompiledTransform object and load the style sheet. Dim xslt As New XslCompiledTransform() xslt.Load("message.xsl") Dim argList As New XsltArgumentList() AddHandler argList.XsltMessageEncountered, AddressOf MessageCallBack ' Load the file to transform. Dim doc As New XPathDocument("books.xml") ' Transform the file. xslt.Transform(doc, argList, XmlWriter.Create("output.xml")) End Sub 'Main Private Shared Sub MessageCallBack(ByVal sender As Object, ByVal e As XsltMessageEncounteredEventArgs) Console.WriteLine("Message received: {0}", e.Message) End Sub 'MessageCallBack End Class 'Sample
The example uses the following files as input.
books.xml
<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
message.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="*"/>
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="//author"/>
</xsl:template>
<xsl:template match="author">
<xsl:if test="not (last-name)">
<xsl:message terminate="no">Author name is not in the correct format <xsl:copy-of select="."/>
</xsl:message>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show:
Note: