Debian Codegraph @

net/sf/saxon/trans/rules/FailRuleSet.java

raw symbols SCIP
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.XPathContext;
11 import net.sf.saxon.expr.instruct.ParameterSet;
12 import net.sf.saxon.expr.parser.Location;
13 import net.sf.saxon.om.Item;
14 import net.sf.saxon.om.NodeInfo;
15 import net.sf.saxon.trans.XPathException;
16 import net.sf.saxon.tree.util.Navigator;
17
18 /**
19 * The built-in rule set introduced in XSLT 3.0, which raises an error when there is no user-supplied
20 * template rule that matches a node.
21 */
22 public class FailRuleSet implements BuiltInRuleSet {
23
24 private static FailRuleSet THE_INSTANCE = new FailRuleSet();
25
26 /**
27 * Get the singleton instance of this class
28 *
29 * @return the singleton instance
30 */
31
32 public static FailRuleSet getInstance() {
33 return THE_INSTANCE;
34 }
35
36 private FailRuleSet() {
37 }
38
39 /**
40 * Perform the built-in template action for a given item.
41 * @param item the item to be processed
42 * @param parameters the parameters supplied to apply-templates
43 * @param tunnelParams the tunnel parameters to be passed through
44 * @param context the dynamic evaluation context
45 * @param locationId location of the instruction (apply-templates, apply-imports etc) that caused
46 * the built-in template to be invoked @throws net.sf.saxon.trans.XPathException
47 */
48
49 public void process(Item item, ParameterSet parameters,
50 ParameterSet tunnelParams, XPathContext context,
51 Location locationId) throws XPathException {
52 String id = (item instanceof NodeInfo ?
53 "the node " + Navigator.getPath((NodeInfo) item) :
54 "the atomic value " + item.getStringValue());
55 XPathException err = new XPathException("No user-defined template rule matches " + id, "XTDE0555");
56 err.setLocator(locationId.saveLocation());
57 throw err;
58 }
59
60
61 /**
62 * Identify this built-in rule set
63 *
64 * @return "fail"
65 */
66
67 @Override
68 public String getName() {
69 return "fail";
70 }
71
72 /**
73 * Get the default action for unmatched nodes
74 *
75 * @param nodeKind the node kind
76 * @return the default action for unmatched element nodes: one of DEEP_COPY, APPLY_TEMPLATES, DEEP_SKIP, FAIL
77 */
78 public int[] getActionForParentNodes(int nodeKind) {
79 return new int[]{FAIL};
80 }
81 }