| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.trans.rules; |
| 9 |
|
| 10 |
import net.sf.saxon.expr.XPathContext; |
| 11 |
import net.sf.saxon.expr.XPathContextMajor; |
| 12 |
import net.sf.saxon.expr.instruct.ParameterSet; |
| 13 |
import net.sf.saxon.expr.instruct.TailCall; |
| 14 |
import net.sf.saxon.expr.parser.Location; |
| 15 |
import net.sf.saxon.om.*; |
| 16 |
import net.sf.saxon.trans.XPathException; |
| 17 |
import net.sf.saxon.type.Type; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
public class DeepSkipRuleSet implements BuiltInRuleSet { |
| 24 |
|
| 25 |
private static DeepSkipRuleSet THE_INSTANCE = new DeepSkipRuleSet(); |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public static DeepSkipRuleSet getInstance() { |
| 34 |
return THE_INSTANCE; |
| 35 |
} |
| 36 |
|
| 37 |
private DeepSkipRuleSet() { |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
public void process(Item item, ParameterSet parameters, |
| 51 |
ParameterSet tunnelParams, XPathContext context, |
| 52 |
Location locationId) throws XPathException { |
| 53 |
if (item instanceof NodeInfo && ((NodeInfo) item).getNodeKind() == Type.DOCUMENT) { |
| 54 |
XPathContextMajor c2 = context.newContext(); |
| 55 |
c2.setOrigin(this); |
| 56 |
c2.trackFocus(((NodeInfo) item).iterateAxis(AxisInfo.CHILD)); |
| 57 |
c2.setCurrentComponent(c2.getCurrentMode()); |
| 58 |
TailCall tc = c2.getCurrentMode().getActor().applyTemplates(parameters, tunnelParams, c2, locationId); |
| 59 |
while (tc != null) { |
| 60 |
tc = tc.processLeavingTail(); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
@Override |
| 74 |
public String getName() { |
| 75 |
return "deep-skip"; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
public int[] getActionForParentNodes(int nodeKind) { |
| 85 |
if (nodeKind == Type.DOCUMENT) { |
| 86 |
return new int[]{APPLY_TEMPLATES_TO_CHILDREN}; |
| 87 |
} else { |
| 88 |
return new int[]{DEEP_SKIP}; |
| 89 |
} |
| 90 |
} |
| 91 |
} |