Project

Profile

Help

Bug #5186

closed

Events received in XQuery Trace listener with Saxon 10

Added by Radu Coravu over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2021-12-15
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
10, 11, trunk
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

I'm working to make the Oxygen XML Debugger work with Saxon 10 exactly or close to how it worked with with Saxon 9. So there is an XML and an XQuery, I'm attaching them. The XQuery looks like this:

            <BigBoss_subordinates>
                {
                    for $person in doc("personal.xml")/personnel/person
                    let $link := $person/link
                    where (exists($link/@manager) and (compare($link/@manager, "Big.Boss") eq 0)) 
            		return
                        <person id="{$person/@id}">
                            <name>{$person/name/given/text(), " ", $person/name/family/text()}</name>
                        </person>
            	
                }
            </BigBoss_subordinates>

We add a net.sf.saxon.lib.TraceListener, with Saxon 10 by default I get on the "net.sf.saxon.lib.TraceListener.enter(Traceable, Map<String, Object>, XPathContext)" callbacks these three initial events:

ENTER class net.sf.saxon.query.XQueryExpression ENTER class net.sf.saxon.expr.flwor.ClauseInfo ENTER class net.sf.saxon.expr.flwor.ClauseInfo

which correspond to the "QUERY" body and to the "FOR" loop inside it, then to the "LET" clause.

With Saxon 9, the same callbacks were with TraceExpression objects, there were more callbacks and one of them was for the "BigBoss_subordinates" element for which with Saxon 10 I receive no callback.

So I started to try and receive more events on the trace listener. I went to patch the method "net.sf.saxon.Configuration.setCompileWithTracing(boolean)" and by default for XQuery it uses a "net.sf.saxon.trace.TraceCodeInjector" which on the method "net.sf.saxon.trace.TraceCodeInjector.isApplicable(Expression)" returns false all the time. What I tried to do for XQuery debugging was to apply a trace code injector like this:

                defaultStaticQueryContext.setCodeInjector(
                    new TraceCodeInjector() {
                      @Override
                      protected boolean isApplicable(Expression exp) {
                        boolean appl = exp.isInstruction() || exp instanceof LetExpression || exp instanceof FixedAttribute
                            || exp instanceof FixedElement || exp instanceof FunctionCall;
                        return appl;
                      }
                    });

After this I get more callbacks on the trace listener, I am called for the element "BigBoss_subordinates", I am called for the doc() function call but I no longer receive callbacks for the "FOR", "LET" expressions for which I received callbacks when I did not set the custom trace code injector.

So somehow I do not know why this happens and how to proceed.


Files

Personal.zip (860 Bytes) Personal.zip Radu Coravu, 2021-12-15 13:57
Screen Shot 2021-12-15 at 15.29.39.png (373 KB) Screen Shot 2021-12-15 at 15.29.39.png Radu Coravu, 2021-12-15 14:30
functions.zip (964 Bytes) functions.zip Radu Coravu, 2021-12-23 15:06

Please register to edit this issue

Also available in: Atom PDF