01: package net.sf.saxon.style;
02:
03: import net.sf.saxon.expr.Expression;
04: import net.sf.saxon.expr.ExpressionTool;
05: import net.sf.saxon.instruct.Executable;
06: import net.sf.saxon.instruct.WithParam;
07: import net.sf.saxon.om.Axis;
08: import net.sf.saxon.om.AxisIterator;
09: import net.sf.saxon.om.Item;
10: import net.sf.saxon.trans.XPathException;
11:
12: /**
13: * An xsl:with-param element in the stylesheet. <br>
14: * The xsl:with-param element has mandatory attribute name and optional attribute select
15: */
16:
17: public class XSLWithParam extends XSLGeneralVariable {
18:
19: protected boolean allowsAsAttribute() {
20: return true;
21: }
22:
23: protected boolean allowsTunnelAttribute() {
24: return true;
25: }
26:
27: public void validate() throws XPathException {
28: super .validate();
29:
30: // Check for duplicate parameter names
31:
32: AxisIterator iter = iterateAxis(Axis.PRECEDING_SIBLING);
33: while (true) {
34: Item prev = iter.next();
35: if (prev == null) {
36: break;
37: }
38: if (prev instanceof XSLWithParam) {
39: if (this .getVariableFingerprint() == ((XSLWithParam) prev)
40: .getVariableFingerprint()) {
41: compileError("Duplicate parameter name", "XTSE0670");
42: }
43: }
44: }
45:
46: }
47:
48: public Expression compile(Executable exec) throws XPathException {
49: WithParam inst = new WithParam();
50: inst.adoptChildExpression(select);
51: initializeInstruction(exec, inst);
52: ExpressionTool.makeParentReferences(inst);
53: return inst;
54: }
55:
56: }
57:
58: //
59: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
60: // you may not use this file except in compliance with the License. You may obtain a copy of the
61: // License at http://www.mozilla.org/MPL/
62: //
63: // Software distributed under the License is distributed on an "AS IS" basis,
64: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
65: // See the License for the specific language governing rights and limitations under the License.
66: //
67: // The Original Code is: all this file.
68: //
69: // The Initial Developer of the Original Code is Michael H. Kay.
70: //
71: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
72: //
73: // Contributor(s): none.
74: //
|