| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.trans; |
| 9 |
|
| 10 |
import net.sf.saxon.Configuration; |
| 11 |
import net.sf.saxon.Controller; |
| 12 |
import net.sf.saxon.event.PipelineConfiguration; |
| 13 |
import net.sf.saxon.expr.Component; |
| 14 |
import net.sf.saxon.expr.XPathContext; |
| 15 |
import net.sf.saxon.expr.XPathContextMajor; |
| 16 |
import net.sf.saxon.expr.accum.Accumulator; |
| 17 |
import net.sf.saxon.expr.instruct.Actor; |
| 18 |
import net.sf.saxon.expr.instruct.ParameterSet; |
| 19 |
import net.sf.saxon.expr.instruct.TailCall; |
| 20 |
import net.sf.saxon.expr.instruct.TemplateRule; |
| 21 |
import net.sf.saxon.expr.parser.Location; |
| 22 |
import net.sf.saxon.lib.NamespaceConstant; |
| 23 |
import net.sf.saxon.lib.TraceListener; |
| 24 |
import net.sf.saxon.lib.TraceListener2; |
| 25 |
import net.sf.saxon.om.*; |
| 26 |
import net.sf.saxon.trace.ExpressionPresenter; |
| 27 |
import net.sf.saxon.trace.ModeTraceListener; |
| 28 |
import net.sf.saxon.trans.rules.*; |
| 29 |
import net.sf.saxon.tree.iter.LookaheadIterator; |
| 30 |
import net.sf.saxon.type.BuiltInAtomicType; |
| 31 |
import net.sf.saxon.type.SchemaType; |
| 32 |
import net.sf.saxon.type.Type; |
| 33 |
import net.sf.saxon.type.Untyped; |
| 34 |
|
| 35 |
import java.util.Collections; |
| 36 |
import java.util.Set; |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public abstract class Mode extends Actor { |
| 45 |
|
| 46 |
public static final StructuredQName OMNI_MODE = |
| 47 |
new StructuredQName("saxon", NamespaceConstant.SAXON, "_omniMode"); |
| 48 |
public static final StructuredQName UNNAMED_MODE_NAME = |
| 49 |
new StructuredQName("xsl", NamespaceConstant.XSLT, "unnamed"); |
| 50 |
public static final StructuredQName DEFAULT_MODE_NAME = |
| 51 |
new StructuredQName("xsl", NamespaceConstant.XSLT, "default"); |
| 52 |
|
| 53 |
|
| 54 |
protected StructuredQName modeName; |
| 55 |
private boolean streamable; |
| 56 |
private int recoveryPolicy = Configuration.RECOVER_WITH_WARNINGS; |
| 57 |
public boolean mustBeTyped = false; |
| 58 |
public boolean mustBeUntyped = false; |
| 59 |
boolean hasRules = false; |
| 60 |
boolean bindingSlotsAllocated = false; |
| 61 |
boolean modeTracing = false; |
| 62 |
|
| 63 |
private Set<? extends Accumulator> accumulators; |
| 64 |
|
| 65 |
|
| 66 |
public Mode(StructuredQName modeName) { |
| 67 |
this.modeName = modeName; |
| 68 |
} |
| 69 |
|
| 70 |
@Override |
| 71 |
public Component.M getDeclaringComponent() { |
| 72 |
return (Component.M)super.getDeclaringComponent(); |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
public abstract BuiltInRuleSet getBuiltInRuleSet(); |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
public boolean isUnnamedMode() { |
| 92 |
return modeName.equals(UNNAMED_MODE_NAME); |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
public StructuredQName getModeName() { |
| 102 |
return modeName; |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
public abstract SimpleMode getActivePart(); |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
public abstract int getMaxPrecedence(); |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
public abstract int getMaxRank(); |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
public abstract void computeRankings(int start) throws XPathException; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
public String getModeTitle() { |
| 144 |
return isUnnamedMode() ? "The unnamed mode" : "Mode " + getModeName().getDisplayName(); |
| 145 |
} |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
public void setModeTracing(boolean tracing) { |
| 152 |
this.modeTracing = tracing; |
| 153 |
} |
| 154 |
|
| 155 |
public boolean isModeTracing() { |
| 156 |
return modeTracing; |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
public Set<? extends Accumulator> getAccumulators() { |
| 165 |
return accumulators == null ? Collections.emptySet() : accumulators; |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
public void setAccumulators(Set<? extends Accumulator> accumulators) { |
| 175 |
this.accumulators = accumulators; |
| 176 |
} |
| 177 |
|
| 178 |
|
| 179 |
@Override |
| 180 |
public int getComponentKind() { |
| 181 |
return StandardNames.XSL_MODE; |
| 182 |
} |
| 183 |
|
| 184 |
@Override |
| 185 |
public SymbolicName getSymbolicName() { |
| 186 |
return new SymbolicName(StandardNames.XSL_MODE, getModeName()); |
| 187 |
} |
| 188 |
|
| 189 |
public int getConstructType() { |
| 190 |
return StandardNames.XSL_MODE; |
| 191 |
} |
| 192 |
|
| 193 |
public StructuredQName getObjectName() { |
| 194 |
return getModeName(); |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
public abstract boolean isEmpty(); |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
public void setRecoveryPolicy(int policy) { |
| 216 |
recoveryPolicy = policy; |
| 217 |
} |
| 218 |
|
| 219 |
public void setHasRules(boolean hasRules) { |
| 220 |
this.hasRules = hasRules; |
| 221 |
} |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
public int getRecoveryPolicy() { |
| 232 |
return recoveryPolicy; |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
public void setStreamable(boolean streamable) { |
| 242 |
this.streamable = streamable; |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
public boolean isDeclaredStreamable() { |
| 252 |
return streamable; |
| 253 |
} |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
public abstract Set<String> getExplicitNamespaces(NamePool pool); |
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
public abstract void processRules(RuleAction action) throws XPathException; |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
public XPathContext makeNewContext(XPathContext context) { |
| 286 |
XPathContextMajor c2 = context.newContext(); |
| 287 |
c2.setOrigin(context.getController()); |
| 288 |
c2.openStackFrame(getStackFrameSlotsNeeded()); |
| 289 |
if (!(context.getCurrentComponent().getActor() instanceof Accumulator)) { |
| 290 |
c2.setCurrentComponent(context.getCurrentMode()); |
| 291 |
} |
| 292 |
return c2; |
| 293 |
} |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
public abstract Rule getRule(Item item, XPathContext context) throws XPathException; |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
public abstract Rule getRule(Item item, XPathContext context, SimpleMode.RuleFilter filter) throws XPathException; |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
public Rule getRule(Item item, final int min, final int max, XPathContext context) throws XPathException { |
| 333 |
RuleFilter filter = r -> { |
| 334 |
int p = r.getPrecedence(); |
| 335 |
return p >= min && p <= max; |
| 336 |
}; |
| 337 |
return getRule(item, context, filter); |
| 338 |
} |
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
public Rule getNextMatchRule(Item item, final Rule currentRule, XPathContext context) throws XPathException { |
| 352 |
SimpleMode.RuleFilter filter = r -> { |
| 353 |
int comp = r.compareRank(currentRule); |
| 354 |
if (comp < 0) { |
| 355 |
|
| 356 |
return true; |
| 357 |
} else if (comp == 0) { |
| 358 |
int seqComp = Integer.compare(r.getSequence(), currentRule.getSequence()); |
| 359 |
if (seqComp < 0) { |
| 360 |
|
| 361 |
return true; |
| 362 |
} else if (seqComp == 0) { |
| 363 |
|
| 364 |
return r.getPartNumber() < currentRule.getPartNumber(); |
| 365 |
} |
| 366 |
} |
| 367 |
return false; |
| 368 |
}; |
| 369 |
return getRule(item, context, filter); |
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
public abstract void exportTemplateRules(ExpressionPresenter out) throws XPathException; |
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
public abstract void explainTemplateRules(ExpressionPresenter out) throws XPathException; |
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
public TailCall applyTemplates( |
| 414 |
ParameterSet parameters, |
| 415 |
ParameterSet tunnelParameters, |
| 416 |
XPathContextMajor context, |
| 417 |
Location locationId) |
| 418 |
throws XPathException { |
| 419 |
Controller controller = context.getController(); |
| 420 |
boolean tracing = modeTracing || controller.isTracing(); |
| 421 |
PipelineConfiguration pipe = context.getReceiver().getPipelineConfiguration(); |
| 422 |
SequenceIterator iterator = context.getCurrentIterator(); |
| 423 |
TailCall tc = null; |
| 424 |
TraceListener traceListener = null; |
| 425 |
if (tracing) { |
| 426 |
traceListener = controller.getTraceListener(); |
| 427 |
if (traceListener == null) { |
| 428 |
traceListener = new ModeTraceListener(); |
| 429 |
controller.setTraceListener(traceListener); |
| 430 |
traceListener.open(controller); |
| 431 |
} |
| 432 |
} |
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
boolean lookahead = (iterator.getProperties() & SequenceIterator.LOOKAHEAD) != 0; |
| 437 |
TemplateRule previousTemplate = null; |
| 438 |
while (true) { |
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
if (tc != null) { |
| 447 |
if (lookahead && !((LookaheadIterator) iterator).hasNext()) { |
| 448 |
break; |
| 449 |
} |
| 450 |
do { |
| 451 |
tc = tc.processLeavingTail(); |
| 452 |
} while (tc != null); |
| 453 |
} |
| 454 |
|
| 455 |
Item item = iterator.next(); |
| 456 |
if (item == null) { |
| 457 |
break; |
| 458 |
} |
| 459 |
|
| 460 |
if (mustBeTyped) { |
| 461 |
if (item instanceof NodeInfo) { |
| 462 |
int kind = ((NodeInfo) item).getNodeKind(); |
| 463 |
if (kind == Type.ELEMENT || kind == Type.ATTRIBUTE) { |
| 464 |
SchemaType annotation = ((NodeInfo) item).getSchemaType(); |
| 465 |
if (annotation == Untyped.getInstance() || annotation == BuiltInAtomicType.UNTYPED_ATOMIC) { |
| 466 |
throw new XPathException(getModeTitle() + " requires typed nodes, but the input is untyped", "XTTE3100"); |
| 467 |
} |
| 468 |
} |
| 469 |
} |
| 470 |
} else if (mustBeUntyped) { |
| 471 |
if (item instanceof NodeInfo) { |
| 472 |
int kind = ((NodeInfo) item).getNodeKind(); |
| 473 |
if (kind == Type.ELEMENT || kind == Type.ATTRIBUTE) { |
| 474 |
SchemaType annotation = ((NodeInfo) item).getSchemaType(); |
| 475 |
if (!(annotation == Untyped.getInstance() || annotation == BuiltInAtomicType.UNTYPED_ATOMIC)) { |
| 476 |
throw new XPathException(getModeTitle() + " requires untyped nodes, but the input is typed", "XTTE3110"); |
| 477 |
} |
| 478 |
} |
| 479 |
} |
| 480 |
} |
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
if (tracing && traceListener instanceof TraceListener2) { |
| 485 |
((TraceListener2)traceListener).startRuleSearch(); |
| 486 |
} |
| 487 |
|
| 488 |
Rule rule = getRule(item, context); |
| 489 |
if (tracing && traceListener instanceof TraceListener2) { |
| 490 |
((TraceListener2) traceListener).endRuleSearch((rule != null) ? rule : getBuiltInRuleSet(), this, item); |
| 491 |
} |
| 492 |
|
| 493 |
if (rule == null) { |
| 494 |
|
| 495 |
getBuiltInRuleSet().process(item, parameters, tunnelParameters, context, locationId); |
| 496 |
|
| 497 |
} else { |
| 498 |
|
| 499 |
TemplateRule template = (TemplateRule) rule.getAction(); |
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
if (template != previousTemplate) { |
| 507 |
|
| 508 |
previousTemplate = template; |
| 509 |
template.initialize(); |
| 510 |
context.openStackFrame(template.getStackFrameMap()); |
| 511 |
context.setLocalParameters(parameters); |
| 512 |
context.setTunnelParameters(tunnelParameters); |
| 513 |
} |
| 514 |
context.setCurrentTemplateRule(rule); |
| 515 |
if (tracing) { |
| 516 |
traceListener.startCurrentItem(item); |
| 517 |
if (modeTracing) { |
| 518 |
traceListener.enter(template, context); |
| 519 |
} |
| 520 |
tc = template.applyLeavingTail(context); |
| 521 |
if (tc != null) { |
| 522 |
|
| 523 |
do { |
| 524 |
tc = tc.processLeavingTail(); |
| 525 |
} while (tc != null); |
| 526 |
} |
| 527 |
if (modeTracing) { |
| 528 |
traceListener.leave(template); |
| 529 |
} |
| 530 |
traceListener.endCurrentItem(item); |
| 531 |
} else { |
| 532 |
tc = template.applyLeavingTail(context); |
| 533 |
} |
| 534 |
} |
| 535 |
} |
| 536 |
|
| 537 |
|
| 538 |
return tc; |
| 539 |
} |
| 540 |
|
| 541 |
public abstract int getStackFrameSlotsNeeded(); |
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
public String getCodeForBuiltInRuleSet(BuiltInRuleSet builtInRuleSet) { |
| 550 |
if (builtInRuleSet instanceof ShallowCopyRuleSet) { |
| 551 |
return "SC"; |
| 552 |
} else if (builtInRuleSet instanceof ShallowSkipRuleSet) { |
| 553 |
return "SS"; |
| 554 |
} else if (builtInRuleSet instanceof DeepCopyRuleSet) { |
| 555 |
return "DC"; |
| 556 |
} else if (builtInRuleSet instanceof DeepSkipRuleSet) { |
| 557 |
return "DS"; |
| 558 |
} else if (builtInRuleSet instanceof FailRuleSet) { |
| 559 |
return "FF"; |
| 560 |
} else if (builtInRuleSet instanceof TextOnlyCopyRuleSet) { |
| 561 |
return "TC"; |
| 562 |
} else if (builtInRuleSet instanceof RuleSetWithWarnings) { |
| 563 |
return getCodeForBuiltInRuleSet(((RuleSetWithWarnings) builtInRuleSet).getBaseRuleSet()) + "+W"; |
| 564 |
} else { |
| 565 |
return "???"; |
| 566 |
} |
| 567 |
} |
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
public BuiltInRuleSet getBuiltInRuleSetForCode(String code) { |
| 576 |
BuiltInRuleSet base; |
| 577 |
if (code.startsWith("SC")) { |
| 578 |
base = ShallowCopyRuleSet.getInstance(); |
| 579 |
} else if (code.startsWith("SS")) { |
| 580 |
base = ShallowSkipRuleSet.getInstance(); |
| 581 |
} else if (code.startsWith("DC")) { |
| 582 |
base = DeepCopyRuleSet.getInstance(); |
| 583 |
} else if (code.startsWith("DS")) { |
| 584 |
base = DeepSkipRuleSet.getInstance(); |
| 585 |
} else if (code.startsWith("FF")) { |
| 586 |
base = FailRuleSet.getInstance(); |
| 587 |
} else if (code.startsWith("TC")) { |
| 588 |
base = TextOnlyCopyRuleSet.getInstance(); |
| 589 |
} else { |
| 590 |
throw new IllegalArgumentException(code); |
| 591 |
} |
| 592 |
if (code.endsWith("+W")) { |
| 593 |
base = new RuleSetWithWarnings(base); |
| 594 |
} |
| 595 |
return base; |
| 596 |
} |
| 597 |
|
| 598 |
public final void export(ExpressionPresenter presenter) throws XPathException { |
| 599 |
int s = presenter.startElement("mode"); |
| 600 |
if (!isUnnamedMode()) { |
| 601 |
presenter.emitAttribute("name", getModeName()); |
| 602 |
} |
| 603 |
presenter.emitAttribute("onNo", getCodeForBuiltInRuleSet(getBuiltInRuleSet())); |
| 604 |
String flags = ""; |
| 605 |
if (isDeclaredStreamable()) { |
| 606 |
flags += "s"; |
| 607 |
} |
| 608 |
if (isUnnamedMode()) { |
| 609 |
flags += "d"; |
| 610 |
} |
| 611 |
if (mustBeTyped) { |
| 612 |
flags += "t"; |
| 613 |
} |
| 614 |
if (mustBeUntyped) { |
| 615 |
flags += "u"; |
| 616 |
} |
| 617 |
if (recoveryPolicy == Configuration.DO_NOT_RECOVER) { |
| 618 |
flags += "F"; |
| 619 |
} else if (recoveryPolicy == Configuration.RECOVER_WITH_WARNINGS) { |
| 620 |
flags += "W"; |
| 621 |
} |
| 622 |
if (!hasRules) { |
| 623 |
flags += "e"; |
| 624 |
} |
| 625 |
if (!flags.isEmpty()) { |
| 626 |
presenter.emitAttribute("flags", flags); |
| 627 |
} |
| 628 |
exportUseAccumulators(presenter); |
| 629 |
presenter.emitAttribute("patternSlots", getStackFrameSlotsNeeded() + ""); |
| 630 |
exportTemplateRules(presenter); |
| 631 |
int e = presenter.endElement(); |
| 632 |
if (s != e) { |
| 633 |
throw new IllegalStateException("Export tree unbalanced for mode " + getModeName()); |
| 634 |
} |
| 635 |
} |
| 636 |
|
| 637 |
protected void exportUseAccumulators(ExpressionPresenter presenter){} |
| 638 |
|
| 639 |
public boolean isMustBeTyped() { |
| 640 |
return mustBeTyped; |
| 641 |
} |
| 642 |
|
| 643 |
public void explain(ExpressionPresenter presenter) throws XPathException { |
| 644 |
int s = presenter.startElement("mode"); |
| 645 |
if (!isUnnamedMode()) { |
| 646 |
presenter.emitAttribute("name", getModeName()); |
| 647 |
} |
| 648 |
presenter.emitAttribute("onNo", getCodeForBuiltInRuleSet(getBuiltInRuleSet())); |
| 649 |
String flags = ""; |
| 650 |
if (isDeclaredStreamable()) { |
| 651 |
flags += "s"; |
| 652 |
} |
| 653 |
if (isUnnamedMode()) { |
| 654 |
flags += "d"; |
| 655 |
} |
| 656 |
if (mustBeTyped) { |
| 657 |
flags += "t"; |
| 658 |
} |
| 659 |
if (mustBeUntyped) { |
| 660 |
flags += "u"; |
| 661 |
} |
| 662 |
if (recoveryPolicy == Configuration.DO_NOT_RECOVER) { |
| 663 |
flags += "F"; |
| 664 |
} else if (recoveryPolicy == Configuration.RECOVER_WITH_WARNINGS) { |
| 665 |
flags += "W"; |
| 666 |
} |
| 667 |
if (!flags.isEmpty()) { |
| 668 |
presenter.emitAttribute("flags", flags); |
| 669 |
} |
| 670 |
|
| 671 |
presenter.emitAttribute("patternSlots", getStackFrameSlotsNeeded() + ""); |
| 672 |
explainTemplateRules(presenter); |
| 673 |
int e = presenter.endElement(); |
| 674 |
if (s != e) { |
| 675 |
throw new IllegalStateException("tree unbalanced"); |
| 676 |
} |
| 677 |
} |
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
protected interface RuleFilter { |
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
boolean testRule(Rule r); |
| 691 |
} |
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
public interface RuleAction { |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
void processRule(Rule r) throws XPathException; |
| 705 |
} |
| 706 |
|
| 707 |
} |