Project

Profile

Help

Capture errors using Saxon9b .net

Added by Anonymous over 16 years ago

Legacy ID: #4623030 Legacy Poster: pvallone (pvallone)

Hi, I am using SAXON 9.0 b .net. I currently pass the XML, XSLT arguements from a VB.net program. How can I pass any errors back to my code? When executing from another program, if there are any errors in the XSLT they are printed to the command prompt, however the command prompt terminates automaticly. I can not view the errors. I would like to be able to capture the errors and display in my app or keep the command prompt open. Can this be done? Thanks, Phil


Replies (3)

Please register to reply

RE: Capture errors using Saxon9b .net - Added by Anonymous over 16 years ago

Legacy ID: #4623117 Legacy Poster: Michael Kay (mhkay)

The XsltCompiler object has an ErrorList property. The following snippet is from the XsltExamples.cs example in the saxon-resources distribution: // Attempt to compile the stylesheet and display the errors try { compiler.BaseUri = new Uri("http://localhost/stylesheet"); compiler.Compile(new XmlTextReader(new StringReader(stylesheet))); Console.WriteLine("Stylesheet compilation succeeded"); } catch (Exception) { Console.WriteLine("Stylesheet compilation failed with " + compiler.ErrorList.Count + " errors"); foreach (StaticError error in compiler.ErrorList) { Console.WriteLine("At line " + error.LineNumber + ": " + error.Message); } } And of course you don't have to output the errors to the Console, they can go anywhere. For run-time errors there's usually enough information in the exception object. However, it sounds as if you've got a rather primitive debugging environment. I'm sure if you use Visual Studio then the errors don't disappear off the screen in this way.

RE: Capture errors using Saxon9b .net - Added by Anonymous over 16 years ago

Legacy ID: #4623132 Legacy Poster: Michael Kay (mhkay)

I snipped a bit too much, I should have left these lines in, which precede those shown: // Create the XSLT Compiler XsltCompiler compiler = processor.NewXsltCompiler(); // Create a list to hold the error information compiler.ErrorList = new ArrayList();

RE: Capture errors using Saxon9b .net - Added by Anonymous over 16 years ago

Legacy ID: #4623807 Legacy Poster: pvallone (pvallone)

Thanks, This is a great help. Regards, Phil

    (1-3/3)

    Please register to reply