Project

Profile

Help

Revision d2022f3e

Added by Michael Kay about 3 years ago

Fix bug 3998 (context path in validation reports)

View differences:

latest9.9/hej/net/sf/saxon/event/PipelineConfiguration.java
9 9

  
10 10
import net.sf.saxon.Configuration;
11 11
import net.sf.saxon.Controller;
12
import net.sf.saxon.expr.XPathContext;
12 13
import net.sf.saxon.lib.ParseOptions;
13 14
import net.sf.saxon.lib.SchemaURIResolver;
14 15
import net.sf.saxon.lib.UnfailingErrorListener;
15
import net.sf.saxon.om.Item;
16 16

  
17 17
import javax.xml.transform.ErrorListener;
18 18
import javax.xml.transform.URIResolver;
19 19
import java.util.HashMap;
20 20
import java.util.Map;
21
import java.util.Stack;
22 21

  
23 22
/**
24 23
 * A PipelineConfiguration sets options that apply to all the operations in a pipeline.
......
31 30
    private URIResolver uriResolver;
32 31
    private SchemaURIResolver schemaURIResolver;
33 32
    private Controller controller;
34
    private Stack<Item> currentApplyStack;
35 33
    private ParseOptions parseOptions;
36 34
    private int hostLanguage = Configuration.XSLT;
37 35
    private Map<String, Object> components;
36
    private XPathContext context;
38 37

  
39 38
    /**
40 39
     * Create a PipelineConfiguration. Note: the normal way to create
......
68 67
        if (p.components != null) {
69 68
            components = new HashMap<>(p.components);
70 69
        }
71
        currentApplyStack = null;
70
        context = p.context;
72 71
    }
73 72

  
74 73
    /**
......
242 241
        return controller;
243 242
    }
244 243

  
245
    /**
246
     * Set the context item. Used only for diagnostics, to indicate
247
     * what part of the source document is being processed. Maintained
248
     * only by xsl:apply-templates
249
     *
250
     * @param item the context item
251
     */
252

  
253
    public void pushCurrentAppliedItem(Item item) {
254
        // TODO: this stack is only used by ValidatingFilter, and it's not clear that it's useful there.
255
        if (currentApplyStack == null) {
256
            currentApplyStack = new Stack<>();
257
        }
258
        currentApplyStack.push(item);
259
    }
260

  
261

  
262
    public void popCurrentAppliedItem() {
263
        currentApplyStack.pop();
264
    }
265

  
266
    public Item peekCurrentAppliedItem() {
267
        if (currentApplyStack != null && !currentApplyStack.isEmpty()) {
268
            return currentApplyStack.peek();
269
        } else {
270
            return null;
271
        }
272
    }
273

  
274
    public Stack<Item> getAppliedItemStack() {
275
        return currentApplyStack;
276
    }
277

  
278 244
    /**
279 245
     * Set the Controller associated with this pipelineConfiguration
280 246
     *
......
346 312
        }
347 313
    }
348 314

  
315
    /**
316
     * Set the XPathContext. Used during validation, for diagnostics, to identify the source node that was
317
     * being processed at the time a validation error in the result document was found
318
     * @param context the XPath dynamic context.
319
     */
320

  
321
    public void setXPathContext(XPathContext context) {
322
        this.context = context;
323
    }
324

  
325
    /**
326
     * Get the XPathContext. Used during validation, for diagnostics, to identify the source node that was
327
     * being processed at the time a validation error in the result document was found
328
     *
329
     * @return the XPath dynamic context.
330
     */
331

  
332
    public XPathContext getXPathContext() {
333
        return context;
334
    }
335

  
349 336
}
350 337

  
latest9.9/hej/net/sf/saxon/expr/instruct/AnalyzeString.java
8 8
package net.sf.saxon.expr.instruct;
9 9

  
10 10
import net.sf.saxon.Configuration;
11
import net.sf.saxon.event.PipelineConfiguration;
11 12
import net.sf.saxon.expr.*;
12 13
import net.sf.saxon.expr.parser.*;
13 14
import net.sf.saxon.om.FocusIterator;
......
383 384
        FocusIterator focusIter = c2.trackFocus(iter);
384 385
        c2.setCurrentRegexIterator(iter);
385 386

  
387
        PipelineConfiguration pipe = c2.getReceiver().getPipelineConfiguration();
388
        pipe.setXPathContext(c2);
389

  
386 390
        Item it;
387 391
        while ((it = focusIter.next()) != null) {
388 392
            if (iter.isMatching()) {
......
396 400
            }
397 401
        }
398 402

  
403
        pipe.setXPathContext(context);
399 404
        return null;
400 405

  
401 406
    }
latest9.9/hej/net/sf/saxon/expr/instruct/ApplyTemplates.java
7 7

  
8 8
package net.sf.saxon.expr.instruct;
9 9

  
10
import net.sf.saxon.event.PipelineConfiguration;
10 11
import net.sf.saxon.expr.*;
11 12
import net.sf.saxon.expr.parser.*;
12 13
import net.sf.saxon.om.*;
......
292 293
        if (inStreamableConstruct) {
293 294
            c2.setCurrentGroupIterator(null);
294 295
        }
296
        PipelineConfiguration pipe = c2.getReceiver().getPipelineConfiguration();
297
        pipe.setXPathContext(c2);
295 298

  
296 299
        try {
297 300
            TailCall tc = thisMode.applyTemplates(params, tunnels, c2, getLocation());
......
305 308
            err.setXPathContext(context);
306 309
            throw err;
307 310
        }
308

  
311
        pipe.setXPathContext(context);
309 312
        return null;
310 313

  
311 314
    }
latest9.9/hej/net/sf/saxon/expr/instruct/CopyOf.java
831 831
        if (schemaType == null /*&& copyNamespaces*/ && !copyForUpdate) {
832 832
            if (validation == Validation.PRESERVE) {
833 833
                // create a virtual copy of the underlying nodes
834
                ItemMappingFunction copier = new ItemMappingFunction() {
835
                    public Item mapItem(Item item) throws XPathException {
836
                        if (item instanceof NodeInfo) {
837
                            if (((NodeInfo) item).getTreeInfo().isTyped()) {
838
                                if (!copyNamespaces && ((NodeInfo) item).getNodeKind() == Type.ELEMENT) {
839
                                    // A lot of extra work here just to check for error XTTE0950, but the conditions are rare
840
                                    Sink sink = new Sink(controller.makePipelineConfiguration());
841
                                    ((NodeInfo) item).copy(sink, CopyOptions.TYPE_ANNOTATIONS, getLocation());
842
                                }
843
                                if (((NodeInfo) item).getNodeKind() == Type.ATTRIBUTE &&
844
                                        ((SimpleType) ((NodeInfo) item).getSchemaType()).isNamespaceSensitive()) {
845
                                    throw new XPathException("Cannot copy an attribute with namespace-sensitive content except as part of its containing element", "XTTE0950");
846
                                }
834
                ItemMappingFunction<Item<?>, Item<?>> copier = item -> {
835
                    if (item instanceof NodeInfo) {
836
                        if (((NodeInfo) item).getTreeInfo().isTyped()) {
837
                            if (!copyNamespaces && ((NodeInfo) item).getNodeKind() == Type.ELEMENT) {
838
                                // A lot of extra work here just to check for error XTTE0950, but the conditions are rare
839
                                Sink sink = new Sink(controller.makePipelineConfiguration());
840
                                ((NodeInfo) item).copy(sink, CopyOptions.TYPE_ANNOTATIONS, getLocation());
847 841
                            }
848
                            VirtualCopy vc = VirtualCopy.makeVirtualCopy((NodeInfo) item);
849
                            vc.setDropNamespaces(!copyNamespaces);
850
                            vc.getTreeInfo().setCopyAccumulators(copyAccumulators);
851
                            if (((NodeInfo) item).getNodeKind() == Type.ELEMENT) {
852
                                vc.setSystemId(computeNewBaseUri((NodeInfo) item, getStaticBaseURIString()));
842
                            if (((NodeInfo) item).getNodeKind() == Type.ATTRIBUTE &&
843
                                    ((SimpleType) ((NodeInfo) item).getSchemaType()).isNamespaceSensitive()) {
844
                                throw new XPathException("Cannot copy an attribute with namespace-sensitive content except as part of its containing element", "XTTE0950");
853 845
                            }
854
                            return vc;
855
                        } else {
856
                            return item;
857
                        }
858
                    }
859
                };
860
                return new ItemMappingIterator(getSelect().iterate(context), copier, true);
861
            } else if (validation == Validation.STRIP) {
862
                // create a virtual copy of the underlying nodes
863
                ItemMappingFunction copier = new ItemMappingFunction() {
864
                    public Item mapItem(Item item) {
865
                        if (!(item instanceof NodeInfo)) {
866
                            return item;
867 846
                        }
868
                        VirtualCopy vc = VirtualUntypedCopy.makeVirtualUntypedTree((NodeInfo) item, (NodeInfo) item);
869
                        vc.getTreeInfo().setCopyAccumulators(copyAccumulators);
847
                        VirtualCopy vc = VirtualCopy.makeVirtualCopy((NodeInfo) item);
870 848
                        vc.setDropNamespaces(!copyNamespaces);
849
                        vc.getTreeInfo().setCopyAccumulators(copyAccumulators);
871 850
                        if (((NodeInfo) item).getNodeKind() == Type.ELEMENT) {
872 851
                            vc.setSystemId(computeNewBaseUri((NodeInfo) item, getStaticBaseURIString()));
873 852
                        }
874 853
                        return vc;
854
                    } else {
855
                        return item;
856
                    }
857
                };
858
                return new ItemMappingIterator<>(getSelect().iterate(context), copier, true);
859
            } else if (validation == Validation.STRIP) {
860
                // create a virtual copy of the underlying nodes
861
                ItemMappingFunction<Item<?>, Item<?>> copier = item -> {
862
                    if (!(item instanceof NodeInfo)) {
863
                        return item;
864
                    }
865
                    VirtualCopy vc = VirtualUntypedCopy.makeVirtualUntypedTree((NodeInfo) item, (NodeInfo) item);
866
                    vc.getTreeInfo().setCopyAccumulators(copyAccumulators);
867
                    vc.setDropNamespaces(!copyNamespaces);
868
                    if (((NodeInfo) item).getNodeKind() == Type.ELEMENT) {
869
                        vc.setSystemId(computeNewBaseUri((NodeInfo) item, getStaticBaseURIString()));
875 870
                    }
871
                    return vc;
876 872
                };
877
                return new ItemMappingIterator(getSelect().iterate(context), copier, true);
873
                return new ItemMappingIterator<>(getSelect().iterate(context), copier, true);
878 874
            }
879 875
        }
880 876
        Receiver saved = context.getReceiver();
881 877
        PipelineConfiguration pipe = controller.makePipelineConfiguration();
878
        pipe.setXPathContext(context);
882 879
        SequenceOutputter out = new SequenceOutputter(pipe);
883 880
        if (copyForUpdate) {
884 881
            out.setTreeModel(TreeModel.LINKED_TREE);
latest9.9/hej/net/sf/saxon/expr/instruct/Doctype.java
85 85

  
86 86
        Receiver out = context.getReceiver();
87 87
        PipelineConfiguration pipe = controller.makePipelineConfiguration();
88
        pipe.setXPathContext(context);
88 89
        pipe.setHostLanguage(getPackageData().getHostLanguage());
89 90
        TinyBuilder builder = new TinyBuilder(pipe);
90 91
        builder.setStatistics(Statistics.RESULT_TREE_STATISTICS);
latest9.9/hej/net/sf/saxon/expr/instruct/DocumentInstr.java
276 276
            try {
277 277
                Receiver saved = context.getReceiver();
278 278
                PipelineConfiguration pipe = controller.makePipelineConfiguration();
279
                pipe.setXPathContext(context);
279 280

  
280 281
                Builder builder;
281 282
                builder = controller.makeBuilder();
latest9.9/hej/net/sf/saxon/expr/instruct/ForEach.java
8 8
package net.sf.saxon.expr.instruct;
9 9

  
10 10
import net.sf.saxon.Controller;
11
import net.sf.saxon.event.PipelineConfiguration;
11 12
import net.sf.saxon.expr.*;
12 13
import net.sf.saxon.expr.parser.*;
13 14
import net.sf.saxon.lib.TraceListener;
14
import net.sf.saxon.om.*;
15
import net.sf.saxon.om.FocusIterator;
16
import net.sf.saxon.om.Item;
17
import net.sf.saxon.om.SequenceIterator;
18
import net.sf.saxon.om.StandardNames;
15 19
import net.sf.saxon.trace.ExpressionPresenter;
16 20
import net.sf.saxon.trans.XPathException;
17 21
import net.sf.saxon.type.ErrorType;
......
465 469
                return ((TailCallReturner) action).processLeavingTail(c2);
466 470
            }
467 471
        } else {
472
            PipelineConfiguration pipe = c2.getReceiver().getPipelineConfiguration();
473
            pipe.setXPathContext(c2);
468 474
            if (controller.isTracing()) {
469 475
                TraceListener listener = controller.getTraceListener();
470 476
                assert listener != null;
......
477 483
            } else {
478 484
                iter.forEachOrFail(item -> action.process(c2));
479 485
            }
486
            pipe.setXPathContext(context);
480 487
        }
481 488
        return null;
482 489
    }
latest9.9/hej/net/sf/saxon/expr/instruct/ForEachGroup.java
8 8
package net.sf.saxon.expr.instruct;
9 9

  
10 10
import net.sf.saxon.Controller;
11
import net.sf.saxon.event.PipelineConfiguration;
11 12
import net.sf.saxon.expr.*;
12 13
import net.sf.saxon.expr.parser.*;
13 14
import net.sf.saxon.expr.sort.*;
......
575 576
    public TailCall processLeavingTail(XPathContext context) throws XPathException {
576 577
        Controller controller = context.getController();
577 578
        assert controller != null;
579
        PipelineConfiguration pipe = context.getReceiver().getPipelineConfiguration();
578 580

  
579 581
        GroupIterator groupIterator = getGroupIterator(context);
580 582
        XPathContextMajor c2 = context.newContext();
......
582 584
        FocusIterator focusIterator = c2.trackFocus(groupIterator);
583 585
        c2.setCurrentGroupIterator(groupIterator);
584 586
        c2.setCurrentTemplateRule(null);
587
        pipe.setXPathContext(c2);
585 588

  
586 589
        if (controller.isTracing()) {
587 590
            TraceListener listener = controller.getTraceListener();
......
598 601
            }
599 602
        }
600 603

  
604
        pipe.setXPathContext(context);
601 605
        return null;
602 606
    }
603 607

  
latest9.9/hej/net/sf/saxon/expr/instruct/IterateInstr.java
7 7

  
8 8
package net.sf.saxon.expr.instruct;
9 9

  
10
import net.sf.saxon.event.PipelineConfiguration;
10 11
import net.sf.saxon.expr.*;
11 12
import net.sf.saxon.expr.parser.*;
12 13
import net.sf.saxon.lib.TraceListener;
......
366 367
        c2.setOrigin(this);
367 368
        FocusIterator iter = c2.trackFocus(getSelectExpression().iterate(context));
368 369
        c2.setCurrentTemplateRule(null);
370
        PipelineConfiguration pipe = c2.getReceiver().getPipelineConfiguration();
371
        pipe.setXPathContext(c2);
369 372

  
370 373
        boolean tracing = context.getController().isTracing();
371 374
        TraceListener listener = tracing ? context.getController().getTraceListener() : null;
......
402 405
                break;
403 406
            }
404 407
        }
408
        pipe.setXPathContext(context);
405 409
        return null;
406 410
    }
407 411

  
latest9.9/hej/net/sf/saxon/expr/instruct/Message.java
185 185
            return null;
186 186
        }
187 187
        Receiver emitter = controller.makeMessageReceiver();
188
        emitter.setPipelineConfiguration(controller.makePipelineConfiguration());
188
        PipelineConfiguration pipe = controller.makePipelineConfiguration();
189
        pipe.setHostLanguage(Configuration.XSLT);
190
        pipe.setXPathContext(context);
191
        emitter.setPipelineConfiguration(pipe);
192

  
189 193
        String code;
190 194
        try {
191 195
            code = getErrorCode().evaluateAsString(context).toString();
......
213 217
        SerializationProperties props = new SerializationProperties();
214 218
        props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
215 219
        SerializerFactory sf = context.getConfiguration().getSerializerFactory();
216
        PipelineConfiguration pipe = controller.makePipelineConfiguration();
217
        pipe.setHostLanguage(Configuration.XSLT);
220

  
218 221
        Receiver receiver = sf.getReceiver(rec, props, pipe);
219 222
        context.setReceiver(receiver);
220 223

  
latest9.9/hej/net/sf/saxon/functions/DocumentFn.java
630 630
        PipelineConfiguration pipe = out.getPipelineConfiguration();
631 631
        if (pipe == null) {
632 632
            pipe = c.getController().makePipelineConfiguration();
633
            pipe.setXPathContext(c);
633 634
            out.setPipelineConfiguration(pipe);
634 635
        }
635 636

  
latest9.9/hej/net/sf/saxon/lib/OutputURIResolverWrapper.java
68 68
            } else {
69 69
                SerializerFactory factory = context.getConfiguration().getSerializerFactory();
70 70
                PipelineConfiguration pipe = context.getController().makePipelineConfiguration();
71
                pipe.setXPathContext(context);
71 72
                out = factory.getReceiver(result, properties, pipe);
72 73
            }
73 74
            List<Action> actions = new ArrayList<>();
latest9.9/hej/net/sf/saxon/ma/json/XMLToJsonFn.java
16 16
import net.sf.saxon.functions.OptionsParameter;
17 17
import net.sf.saxon.functions.SystemFunction;
18 18
import net.sf.saxon.ma.map.MapItem;
19
import net.sf.saxon.om.Item;
20 19
import net.sf.saxon.om.NodeInfo;
21 20
import net.sf.saxon.om.Sequence;
22 21
import net.sf.saxon.trans.XPathException;
......
53 52
        }
54 53

  
55 54
        PipelineConfiguration pipe = context.getController().makePipelineConfiguration();
55
        pipe.setXPathContext(context);
56 56
        JsonReceiver receiver = new JsonReceiver(pipe);
57 57
        receiver.setIndenting(indent);
58 58
        Receiver r = receiver;
latest9.9/hej/net/sf/saxon/om/AbsolutePath.java
150 150
         *
151 151
         * @param nodeKind the kind of node
152 152
         * @param name     the name of the node
153
         * @param index    the position of the node relative to siblings of the same node kind and name
153
         * @param index    the position of the node relative to siblings of the same node kind and name.
154
         *                 The value -1 indicates "not known", which will typically be the case for streamed nodes.
154 155
         */
155 156
        public PathElement(int nodeKind, NodeName name, int index) {
156 157
            this.nodeKind = nodeKind;
......
180 181
        /**
181 182
         * Get the position of the node
182 183
         *
183
         * @return relative to siblings of the same node kind and name
184
         * @return the position relative to siblings of the same node kind and name.
185
         * The value -1 indicates "not known", which will typically be the case for streamed nodes.
184 186
         */
185 187

  
186 188
        public int getIndex() {
......
209 211
                            fsb.append("}");
210 212
                        } else if (option == 'p') {
211 213
                            String prefix = name.getPrefix();
212
                            if (prefix.length() != 0) {
214
                            if (!prefix.isEmpty()) {
213 215
                                fsb.append(prefix);
214 216
                                fsb.append(':');
215 217
                            }
......
228 230
                        fsb.append("}");
229 231
                    } else if (option == 'p') {
230 232
                        String prefix = name.getPrefix();
231
                        if (prefix.length() != 0) {
233
                        if (!prefix.isEmpty()) {
232 234
                            fsb.append(prefix);
233 235
                            fsb.append(':');
234 236
                        }
235 237
                    } else if (option == 's') {
236
                        if (name.getURI().length() != 0) {
238
                        if (!name.getURI().isEmpty()) {
237 239
                            fsb.append("Q{");
238 240
                            fsb.append(Err.abbreviateURI(name.getURI()));
239 241
                            fsb.append("}");
240 242
                        }
241 243
                    }
242 244
                    fsb.append(name.getLocalPart());
243
                    fsb.append('[');
244
                    fsb.append(getIndex() + "");
245
                    fsb.append(']');
245
                    appendPredicate(fsb);
246 246
                    break;
247 247
                case Type.TEXT:
248 248
                    fsb.append("text()");
249 249
                    break;
250 250
                case Type.COMMENT:
251 251
                    fsb.append("comment()");
252
                    fsb.append('[');
253
                    fsb.append(getIndex() + "");
254
                    fsb.append(']');
252
                    appendPredicate(fsb);
255 253
                    break;
256 254
                case Type.PROCESSING_INSTRUCTION:
257 255
                    fsb.append("processing-instruction(");
258 256
                    fsb.append(name.getLocalPart());
259
                    fsb.append(")[");
260
                    fsb.append(getIndex() + "");
261
                    fsb.append(']');
257
                    fsb.append(")");
258
                    appendPredicate(fsb);
262 259
                    break;
263 260
                case Type.NAMESPACE:
264 261
                    fsb.append("namespace::");
......
271 268
                default:
272 269
            }
273 270
        }
271

  
272
        private void appendPredicate(FastStringBuffer fsb) {
273
            int index = getIndex();
274
            if (index != -1) {
275
                fsb.append('[');
276
                fsb.append(getIndex() + "");
277
                fsb.append(']');
278
            }
279
        }
274 280
    }
275 281

  
276 282

  
283

  
284

  
277 285
}
278 286

  
latest9.9/hej/net/sf/saxon/trans/Mode.java
445 445
                }
446 446
            }
447 447

  
448
            pipe.pushCurrentAppliedItem(item);
449

  
450 448
            // find the template rule for this node
451 449

  
452 450
            if (tracing && traceListener instanceof TraceListener2) {
......
487 485
                    tc = template.applyLeavingTail(context);
488 486
                }
489 487
            }
490

  
491
            pipe.popCurrentAppliedItem();
492 488
        }
493 489

  
494 490
        // return the TailCall returned from the last node processed
latest9.9/hej/net/sf/saxon/trans/rules/ShallowCopyRuleSet.java
7 7

  
8 8
package net.sf.saxon.trans.rules;
9 9

  
10
import net.sf.saxon.event.PipelineConfiguration;
10 11
import net.sf.saxon.event.Receiver;
11 12
import net.sf.saxon.expr.XPathContext;
12 13
import net.sf.saxon.expr.XPathContextMajor;
......
58 59
            switch (node.getNodeKind()) {
59 60
                case Type.DOCUMENT: {
60 61
                    Receiver out = context.getReceiver();
62
                    PipelineConfiguration pipe = out.getPipelineConfiguration();
61 63
                    out.startDocument(0);
62 64
                    XPathContextMajor c2 = context.newContext();
63 65
                    c2.setOrigin(this);
64 66
                    c2.trackFocus(node.iterateAxis(AxisInfo.CHILD));
65 67
                    c2.setCurrentComponent(c2.getCurrentMode());  // Bug 3508
68
                    pipe.setXPathContext(c2);
66 69
                    TailCall tc = context.getCurrentMode().getActor().applyTemplates(parameters, tunnelParams, c2, locationId);
67 70
                    while (tc != null) {
68 71
                        tc = tc.processLeavingTail();
69 72
                    }
70 73
                    out.endDocument();
74
                    pipe.setXPathContext(context);
71 75
                    return;
72 76
                }
73 77
                case Type.ELEMENT: {
74 78
                    Receiver out = context.getReceiver();
79
                    PipelineConfiguration pipe = out.getPipelineConfiguration();
75 80
                    NodeName fqn = NameOfNode.makeName(node);
76 81
                    out.startElement(fqn, node.getSchemaType(), locationId, 0);
77 82
                    NamespaceIterator.sendNamespaces(node, out);
78 83

  
79 84
                    XPathContextMajor c2 = context.newContext();
80 85
                    c2.setCurrentComponent(c2.getCurrentMode());  // Bug 3508
86
                    pipe.setXPathContext(c2);
81 87

  
82 88
                    // apply-templates to all attributes
83 89
                    AxisIterator attributes = node.iterateAxis(AxisInfo.ATTRIBUTE);
......
99 105
                        }
100 106
                    }
101 107
                    out.endElement();
108
                    pipe.setXPathContext(context);
102 109
                    return;
103 110
                }
104 111
                case Type.TEXT:
latest9.9/hej/net/sf/saxon/trans/rules/TextOnlyCopyRuleSet.java
7 7

  
8 8
package net.sf.saxon.trans.rules;
9 9

  
10
import net.sf.saxon.event.PipelineConfiguration;
10 11
import net.sf.saxon.expr.XPathContext;
11 12
import net.sf.saxon.expr.XPathContextMajor;
12 13
import net.sf.saxon.expr.instruct.ParameterSet;
......
61 62
            switch (node.getNodeKind()) {
62 63
                case Type.DOCUMENT:
63 64
                case Type.ELEMENT:
65
                    PipelineConfiguration pipe = context.getReceiver().getPipelineConfiguration();
64 66
                    XPathContextMajor c2 = context.newContext();
65 67
                    c2.setOrigin(this);
66 68
                    c2.trackFocus(node.iterateAxis(AxisInfo.CHILD));
67 69
                    c2.setCurrentComponent(c2.getCurrentMode());  // Bug 3508
70
                    pipe.setXPathContext(c2);
68 71
                    TailCall tc = c2.getCurrentMode().getActor().applyTemplates(parameters, tunnelParams, c2, locationId);
69 72
                    while (tc != null) {
70 73
                        tc = tc.processLeavingTail();
71 74
                    }
75
                    pipe.setXPathContext(context);
72 76
                    return;
73 77
                case Type.TEXT:
74 78
                    // NOTE: I tried changing this to use the text node's copy() method, but
latest9.9/hej/net/sf/saxon/tree/util/Navigator.java
290 290
     */
291 291

  
292 292
    public static AbsolutePath getAbsolutePath(NodeInfo node) {
293
        boolean streamed = node.getConfiguration().isStreamedNode(node);
293 294
        List<AbsolutePath.PathElement> path = new LinkedList<>();
294 295
        String sysId = node.getSystemId();
295 296
        while (node != null && node.getNodeKind() != Type.DOCUMENT) {
296
            path.add(0, new AbsolutePath.PathElement(node.getNodeKind(), NameOfNode.makeName(node), getNumberSimple(node, null)));
297
            path.add(0, new AbsolutePath.PathElement(node.getNodeKind(),
298
                                                     NameOfNode.makeName(node),
299
                                                     streamed ? -1 : getNumberSimple(node, null)));
297 300
            node = node.getParent();
298 301
        }
299 302
        AbsolutePath a = new AbsolutePath(path);

Also available in: Unified diff