| 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.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 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public class RuleSetWithWarnings implements BuiltInRuleSet { |
| 25 |
|
| 26 |
|
| 27 |
private BuiltInRuleSet baseRuleSet; |
| 28 |
|
| 29 |
public RuleSetWithWarnings(BuiltInRuleSet baseRuleSet) { |
| 30 |
this.baseRuleSet = baseRuleSet; |
| 31 |
} |
| 32 |
|
| 33 |
public BuiltInRuleSet getBaseRuleSet() { |
| 34 |
return baseRuleSet; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
public void process(Item item, ParameterSet parameters, |
| 48 |
ParameterSet tunnelParams, XPathContext context, |
| 49 |
Location locationId) throws XPathException { |
| 50 |
|
| 51 |
outputWarning(item, context); |
| 52 |
baseRuleSet.process(item, parameters, tunnelParams, context, locationId); |
| 53 |
|
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
@Override |
| 64 |
public String getName() { |
| 65 |
return baseRuleSet + " with warnings"; |
| 66 |
} |
| 67 |
|
| 68 |
public void outputWarning(Item item, XPathContext context) { |
| 69 |
String id = item instanceof NodeInfo ? |
| 70 |
"the node " + Navigator.getPath((NodeInfo) item) : |
| 71 |
"the atomic value " + item.getStringValue(); |
| 72 |
XPathException warning = new XPathException("No user-defined template rule matches " + id, "XTDE0555"); |
| 73 |
context.getController().getErrorListener().warning(warning); |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
public int[] getActionForParentNodes(int nodeKind) { |
| 83 |
return baseRuleSet.getActionForParentNodes(nodeKind); |
| 84 |
} |
| 85 |
} |