Project

Profile

Help

Revision 7464c22f

Added by Michael Kay almost 10 years ago

Add namespace context information to FLWOR expression tracing

View differences:

latest9.4/hej/net/sf/saxon/expr/flwor/ClauseInfo.java
1 1
package net.sf.saxon.expr.flwor;
2 2

  
3 3
import net.sf.saxon.expr.Container;
4
import net.sf.saxon.om.NamespaceResolver;
4 5
import net.sf.saxon.om.StructuredQName;
5 6
import net.sf.saxon.trace.InstructionInfo;
6 7
import net.sf.saxon.trace.Location;
......
16 17

  
17 18
    private Clause clause;
18 19
    private Container container;
20
    private NamespaceResolver nsResolver;
19 21

  
20 22
    public ClauseInfo(Clause clause, Container container) {
21 23
        this.clause = clause;
......
48 50
        }
49 51
    }
50 52

  
53
    /**
54
     * Get the namespace bindings from the static context of the clause
55
     * @return a namespace resolver that reflects the in scope namespaces of the clause
56
     */
57

  
58
    public NamespaceResolver getNamespaceResolver() {
59
        return nsResolver;
60
    }
61

  
62
    /**
63
     * Set the namespace bindings from the static context of the clause
64
     * @param nsResolver a namespace resolver that reflects the in scope namespaces of the clause
65
     */
66

  
67
    public void setNamespaceResolver(NamespaceResolver nsResolver) {
68
        this.nsResolver = nsResolver;
69
    }
70

  
51 71
    /**
52 72
     * Get the system identifier (URI) of the source stylesheet or query module containing
53 73
     * the instruction. This will generally be an absolute URI. If the system
latest9.4/hej/net/sf/saxon/expr/flwor/TraceClause.java
2 2

  
3 3
import net.sf.saxon.expr.Container;
4 4
import net.sf.saxon.expr.XPathContext;
5
import net.sf.saxon.om.NamespaceResolver;
5 6
import net.sf.saxon.trace.ExpressionPresenter;
6 7
import net.sf.saxon.trans.XPathException;
7 8

  
......
13 14

  
14 15
    private Clause target;
15 16
    private Container container;
17
    private NamespaceResolver nsResolver;
16 18

  
17 19
    /**
18 20
     * Create a traceClause
......
25 27
        this.container = container;
26 28
    }
27 29

  
30
    /**
31
     * Get the namespace bindings from the static context of the clause
32
     * @return a namespace resolver that reflects the in scope namespaces of the clause
33
     */
34

  
35
    public NamespaceResolver getNamespaceResolver() {
36
        return nsResolver;
37
    }
38

  
39
    /**
40
     * Set the namespace bindings from the static context of the clause
41
     * @param nsResolver a namespace resolver that reflects the in scope namespaces of the clause
42
     */
43

  
44
    public void setNamespaceResolver(NamespaceResolver nsResolver) {
45
        this.nsResolver = nsResolver;
46
    }
47

  
48

  
28 49
    @Override
29 50
    public int getClauseKey() {
30 51
        return TRACE;
......
43 64
     */
44 65
    @Override
45 66
    public TuplePull getPullStream(TuplePull base, XPathContext context) {
46
        return new TraceClausePull(base, target, container);
67
        return new TraceClausePull(base, this, target, container);
47 68
    }
48 69

  
49 70
    /**
......
57 78
     */
58 79
    @Override
59 80
    public TuplePush getPushStream(TuplePush destination, XPathContext context) {
60
        return new TraceClausePush(destination, target, container);
81
        return new TraceClausePush(destination, this, target, container);
61 82
    }
62 83

  
63 84
    /**
latest9.4/hej/net/sf/saxon/expr/flwor/TraceClausePull.java
14 14

  
15 15
    private TuplePull base;
16 16
    private Clause baseClause;
17
    private TraceClause traceClause;
17 18
    private Container container;
18 19

  
19
    public TraceClausePull(TuplePull base, Clause baseClause, Container container) {
20
    public TraceClausePull(TuplePull base, TraceClause traceClause, Clause baseClause, Container container) {
20 21
        this.base = base;
22
        this.traceClause = traceClause;
21 23
        this.baseClause = baseClause;
22 24
        this.container = container;
23 25
    }
......
36 38
        Controller controller = context.getController();
37 39
        if (controller.isTracing()) {
38 40
            ClauseInfo baseInfo = new ClauseInfo(baseClause, container);
41
            baseInfo.setNamespaceResolver(traceClause.getNamespaceResolver());
39 42
            controller.getTraceListener().enter(baseInfo, context);
40 43
            boolean b = base.nextTuple(context);
41 44
            controller.getTraceListener().leave(baseInfo);
latest9.4/hej/net/sf/saxon/expr/flwor/TraceClausePush.java
13 13
public class TraceClausePush extends TuplePush {
14 14

  
15 15
    private TuplePush destination;
16
    TraceClause traceClause;
16 17
    private Clause baseClause;
17 18
    private Container container;
18 19

  
19
    public TraceClausePush(TuplePush destination, Clause baseClause, Container container) {
20
    public TraceClausePush(TuplePush destination, TraceClause traceClause, Clause baseClause, Container container) {
20 21
        this.destination = destination;
22
        this.traceClause = traceClause;
21 23
        this.baseClause = baseClause;
22 24
        this.container = container;
23 25
    }
......
30 32
        Controller controller = context.getController();
31 33
        if (controller.isTracing()) {
32 34
            ClauseInfo baseInfo = new ClauseInfo(baseClause, container);
35
            baseInfo.setNamespaceResolver(traceClause.getNamespaceResolver());
33 36
            controller.getTraceListener().enter(baseInfo, context);
34 37
            destination.processTuple(context);
35 38
            controller.getTraceListener().leave(baseInfo);

Also available in: Unified diff