The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XsltMessageEncounteredEventArgs.Message Property


Gets the contents of the xsl:message element.

Namespace:   System.Xml.Xsl
Assembly:  System.Xml (in System.Xml.dll)

public abstract string Message { get; }

Property Value

Type: System.String

The contents of the xsl:message element.

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>.

using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;

public class Sample {

  public static void Main() {

    // Create the XslCompiledTransform object and load the style sheet.
    XslCompiledTransform xslt = new XslCompiledTransform();

    XsltArgumentList argList = new XsltArgumentList();
    argList.XsltMessageEncountered += new XsltMessageEncounteredEventHandler(MessageCallBack);

    // Load the file to transform.
    XPathDocument doc = new XPathDocument("books.xml");

    // Transform the file.
    xslt.Transform(doc, argList, XmlWriter.Create("output.xml"));


  private static void MessageCallBack(object sender, XsltMessageEncounteredEventArgs e) {
    Console.WriteLine("Message received: {0}", e.Message);


The example uses the following files as input:



.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft