Project

Profile

Help

TraceListener for tracing executed xslt instruction on Saxon for .NET

Added by jimpa pedar over 10 years ago

Hello, I'm using c#.Net4 to create a low latency app and wanted to try the Saxon-api 9.4 HE. I would like to know if there is a way for tracing each xsl instruction that has been called. It's for log purpose, it's important for me to keep these traces. Thank you in advance. Jimpa


Replies (1)

RE: TraceListener for tracing executed xslt instruction on Saxon for .NET - Added by O'Neil Delpratt over 10 years ago

Hi Jimpa,

Yes it is possible to override the Java TimedTraceListener within .NET when working with the Saxon API with some user defined class. I am currently looking at producing an example code. As a workaround you can reuse the Saxon Java @TimingTraceListener@ quite easily by calling it in your C# code. See example below:


 Processor processor = new Processor();
            processor.Implementation.setCompileWithTracing(true);

            XsltCompiler xsltCompiler = processor.NewXsltCompiler();
            XsltTransformer transformer;
            
                         
                XmlTextReader xslt = new XmlTextReader("C:\\xmark\\q12.xsl");
                XsltExecutable exec = xsltCompiler.Compile(xslt);
                
                transformer = exec.Load();
                transformer.SetInputStream(new FileStream("C:\\xmark\\xmark1.xml", FileMode.Open), new Uri("C:\\xmark\\"));

                net.sf.saxon.trace.TimingTraceListener trace1 = new net.sf.saxon.trace.TimingTraceListener();
                
                java.io.PrintStream stream1 = new java.io.PrintStream("c:\\test\\output.html");
              
               trace1.setOutputDestination(stream1);
                transformer.Implementation.addTraceListener(trace1);
                Serializer serializer = new Serializer();
                MemoryStream os = new MemoryStream();
                serializer.SetOutputStream(os);
                transformer.Run(serializer);
               
          ...

As mentioned above you can override the TimingTracingListener as follows:

As you probably know you can do it from the command line by using the -TP option. See the documentation for details:

http://www.saxonica.com/documentation9.4-demo/index.html#!using-xsl/commandline

    (1-1/1)

    Please register to reply