| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.trans.rules; |
| 9 | |
| 10 | import net.sf.saxon.expr.ContextOriginator; |
| 11 | import net.sf.saxon.expr.XPathContext; |
| 12 | import net.sf.saxon.expr.instruct.ParameterSet; |
| 13 | import net.sf.saxon.expr.parser.Location; |
| 14 | import net.sf.saxon.om.Item; |
| 15 | import net.sf.saxon.trans.XPathException; |
| 16 | |
| 17 | /** |
| 18 | * Defines a set of built-in template rules (rules for use when no user-defined template |
| 19 | * rules match a given node) |
| 20 | */ |
| 21 | public interface BuiltInRuleSet extends ContextOriginator { |
| 22 | |
| 23 | /** |
| 24 | * Perform the built-in template action for a given item. |
| 25 | * |
| 26 | * @param item the item to be processed |
| 27 | * @param parameters the parameters supplied to apply-templates |
| 28 | * @param tunnelParams the tunnel parameters to be passed through |
| 29 | * @param context the dynamic evaluation context |
| 30 | * @param locationId location of the instruction (apply-templates, apply-imports etc) that caused |
| 31 | * the built-in template to be invoked |
| 32 | * @throws XPathException if any dynamic error occurs |
| 33 | */ |
| 34 | |
| 35 | void process(Item item, |
| 36 | ParameterSet parameters, |
| 37 | ParameterSet tunnelParams, |
| 38 | XPathContext context, |
| 39 | Location locationId) throws XPathException; |
| 40 | |
| 41 | /** |
| 42 | * Identify this built-in rule set |
| 43 | * @return the XSLT keyword used to identify this rule-set, for example "deep-copy |
| 44 | */ |
| 45 | |
| 46 | String getName(); |
| 47 | |
| 48 | /** |
| 49 | * Get the action for unmatched element and document nodes (used when streaming) |
| 50 | * |
| 51 | * @param nodeKind the node kind: either Type.DOCUMENT or Type.ELEMENT |
| 52 | * @return the sequence of actions to be taken |
| 53 | */ |
| 54 | |
| 55 | int[] getActionForParentNodes(int nodeKind); |
| 56 | |
| 57 | int DEEP_COPY = 1; |
| 58 | int DEEP_SKIP = 3; |
| 59 | int FAIL = 4; |
| 60 | int SHALLOW_COPY = 5; |
| 61 | int APPLY_TEMPLATES_TO_ATTRIBUTES = 6; |
| 62 | int APPLY_TEMPLATES_TO_CHILDREN = 7; |
| 63 | |
| 64 | } |
| 65 |