Project

Profile

Help

Fetching Verbose Messages

Added by Anonymous about 14 years ago

Legacy ID: #8166799 Legacy Poster: tg (pilger81)

First off, sorry for my bad english. How do I collect Messages that occur, when the user activates the -explain option. And how do I collect Warnings and Validation Errors? I program a tool with C# and want to put out these messages in a Textfield for the user. Maybe this is very easy ... but I cant find or see the solution. greetings


Replies (13)

Please register to reply

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

Legacy ID: #8166862 Legacy Poster: tg (pilger81)

what I forgot to say is, that i already catch errors. thats no problem with try/catch. but I have no idea what to do, to get the stuff that occurs, after setting these values here to true: processor.SetProperty("http://saxon.sf.net/feature/compile-with-tracing", "true"); processor.SetProperty("http://saxon.sf.net/feature/trace-optimizer-decisions", "true"); processor.SetProperty("http://saxon.sf.net/feature/trace-external-functions", "true"); processor.SetProperty("http://saxon.sf.net/feature/validation-warnings", "true"); processor.SetProperty("http://saxon.sf.net/feature/version-warning", "true");

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

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

There are a number of different facilities here for the different kinds of diagnostic output, and it's a bit more complex on .NET because the interfaces are really optimized for Java. The optimizer tracing messages (tracing decisions made by the optimizer) always go to System.err, and the only control available is to capture System.err output or redirect it to a file. The same is true of tracing extension function calls, and of the single "version-warning" message produced by XSLT when running a 1.0 stylesheet. The output produced by -explain on the command line can't currently be produced using the API on .NET, as far as I can see. If you want this programmatically, it might be easiest to compile the query/stylesheet and generate the explain output using Java interfaces. I'll see if I can improve this situation. For validation errors the situation is rather better; you can set the ErrorList property on the SchemaValidator, and the validation errors will then be written as items in this list, which you can inspect from your application when validation is finished; if you prefer, you can create an implementation of List in which you intercept the Add() method calls that add items to the list.

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

Legacy ID: #8170941 Legacy Poster: tg (pilger81)

thank you for your answer. that already helped alot. :) but I have some problems with redirecting the error output to a file. as I said I code with c#, and as far as I can see the system errors go to Console.Error here. c# doesnt know System.err, because its the standard error output for java. so I wrote this litte code here: string meinlog = @"c:\log.log"; TextWriter outputStream = new StreamWriter(meinlog); Console.SetError(outputStream); this should redirect the error output to the file log.log. but when I start a transformation with processor.SetProperty("http://saxon.sf.net/feature/trace-optimizer-decisions", "true"); - the file leaves empty. Maybe you have a suggestion here? catching the validatior errors works fine. thank you :) cheers

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

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

It may be that the trace of optimizer decisions was empty because no optimizations were applied. Only the more significant optimizations get logged: typically only those performed in Saxon-EE, such as replacing a filter expression x[@a=$c] by an index lookup. You're write that Java's System.err and C#'s Console.Error are essentially the same thing once mapped to underlying .NET facilities.

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

Legacy ID: #8171062 Legacy Poster: tg (pilger81)

but when I have processor.SetProperty("http://saxon.sf.net/feature/validation-warnings", "true"); and processor.SetProperty("http://saxon.sf.net/feature/version-warning", "true"). and then transform with a xslt 1.0 stylesheet. shouldnt there be a warning on the error stream? because my redirected file also stays empty here.

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

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

With some trial and error, I've found that you can redirect the error output using string meinlog = @"e:\temp\log.log"; java.lang.System.setErr(new java.io.PrintStream(meinlog)); You will probably need to add a reference to IKVM.OpenJDK.Core.dll to your project. I will look into improving this for a future release.

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

Legacy ID: #8171376 Legacy Poster: tg (pilger81)

when I put a reference to IKVM.OpenJDK.Core.dll ,the programm throws an exception when I start a transformation: failed unexpectedly: The type initializer for 'net.sf.saxon.sort.StandardCollationURIResolver' threw an exception. at net.sf.saxon.sort.StandardCollationURIResolver.getInstance() at net.sf.saxon.Configuration..ctor() at Saxon.Api.Processor..ctor() at myTool.transformer.starteProzessor() in C:\Dokumente und Einstellungen\tg\Eigene Dateien\Visual Studio 2008\Projects\myTool\SaxonTest_1\transformer.cs:line 45 on line 45 in the code stands: Processor processor = new Processor(); --- anyway I really want to thank you for taking the time. if there are some things that are not finally implemented yet for the dotNet version, I can wait for the next release.

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

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

Strange. What version of Saxon is this, and on what .NET version?

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

Legacy ID: #8171462 Legacy Poster: tg (pilger81)

its saxon 9.1.0.8 and 3.5

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

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

Could you try again with Saxon 9.2.0.6?

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

Legacy ID: #8171573 Legacy Poster: tg (pilger81)

oki now it works. it was my fault, because I didnt use the IKVM.OpenJDK.Core.dll from your bin folder. I downloaded it from http://www.ikvm.net/ that didnt work... when I use your file, the exception doesnt appear. sorry didnt see that. but the log file is still empty.

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

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

but the log file is still empty. In my test I did processor.SetProperty("http://saxon.sf.net/feature/timing", "true"); to ensure that something was written to System.err

RE: Fetching Verbose Messages - Added by Anonymous about 14 years ago

Legacy ID: #8171621 Legacy Poster: tg (pilger81)

I just tried it again with 9.1.0.8. when I use your IKVM.OpenJDK.ClassLibrary.dll it works. it writes to the log file. but with 9.2.0.6 it doesnt work. the file stays empty.

    (1-13/13)

    Please register to reply