KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > style > XSLWithParam


1 package net.sf.saxon.style;
2 import net.sf.saxon.expr.Expression;
3 import net.sf.saxon.expr.ExpressionTool;
4 import net.sf.saxon.instruct.Executable;
5 import net.sf.saxon.instruct.WithParam;
6 import net.sf.saxon.om.Axis;
7 import net.sf.saxon.om.AxisIterator;
8 import net.sf.saxon.om.Item;
9 import net.sf.saxon.trans.XPathException;
10
11 /**
12 * An xsl:with-param element in the stylesheet. <br>
13 * The xsl:with-param element has mandatory attribute name and optional attribute select
14 */

15
16 public class XSLWithParam extends XSLGeneralVariable {
17
18     protected boolean allowsAsAttribute() {
19         return true;
20     }
21
22     protected boolean allowsTunnelAttribute() {
23         return true;
24     }
25
26     public void validate() throws XPathException {
27         super.validate();
28
29         // Check for duplicate parameter names
30

31         AxisIterator iter = iterateAxis(Axis.PRECEDING_SIBLING);
32         while (true) {
33             Item prev = iter.next();
34             if (prev == null) {
35                 break;
36             }
37             if (prev instanceof XSLWithParam) {
38                 if (this.getVariableFingerprint() == ((XSLWithParam)prev).getVariableFingerprint()) {
39                     compileError("Duplicate parameter name", "XTSE0670");
40                 }
41             }
42         }
43
44     }
45
46     public Expression compile(Executable exec) throws XPathException {
47         WithParam inst = new WithParam();
48         inst.adoptChildExpression(select);
49         initializeInstruction(exec, inst);
50         ExpressionTool.makeParentReferences(inst);
51         return inst;
52     }
53
54 }
55
56 //
57
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
58
// you may not use this file except in compliance with the License. You may obtain a copy of the
59
// License at http://www.mozilla.org/MPL/
60
//
61
// Software distributed under the License is distributed on an "AS IS" basis,
62
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
63
// See the License for the specific language governing rights and limitations under the License.
64
//
65
// The Original Code is: all this file.
66
//
67
// The Initial Developer of the Original Code is Michael H. Kay.
68
//
69
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
70
//
71
// Contributor(s): none.
72
//
73
Popular Tags