views:

40

answers:

1

I know about Console.SetOut, but can't figure out what I should pass to this method.

+1  A: 

Console.SetOut will set stream for console outputs. Use XsltMessageEncountered event of XsltArgumentList class and write the message to Trace listenres using Trace.Write.

void TestTransform()
{
    XsltArgumentList xsltargs = new XsltArgumentList();
    xsltargs.XsltMessageEncountered += new XsltMessageEncounteredEventHandler(OnXsltMessageEncountered);

    XslCompiledTransform transform = new XslCompiledTransform();
    //....some code to load xslt and other stuffs. Pass the xsltargs to transform
}

void OnXsltMessageEncountered(object sender, XsltMessageEncounteredEventArgs e)
{
    //write the message to Trace.
    Trace.Write(e.Message);
}
gp
Yeah, I've already found this solution. This is supported by XslCompiledTransform only. Console.SetOut is the only way to do this with XslTransform.
thorn