KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > style > XSLWithParam


1 package com.icl.saxon.style;
2 import com.icl.saxon.tree.AttributeCollection;
3 import com.icl.saxon.tree.NodeImpl;
4 import com.icl.saxon.*;
5 import com.icl.saxon.om.NodeInfo;
6 import com.icl.saxon.handlers.*;
7 import com.icl.saxon.expr.*;
8
9 import javax.xml.transform.*;
10 import java.io.*;
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     public void validate() throws TransformerConfigurationException {
20         super.validate();
21
22         NodeInfo parent = (NodeInfo)getParent();
23         if (!((parent instanceof XSLApplyTemplates) ||
24                  (parent instanceof XSLCallTemplate) ||
25                  (parent instanceof XSLApplyImports))) {
26             compileError("xsl:with-param cannot appear as a child of " + parent.getDisplayName());
27         }
28         
29         // Check for duplicate parameter names
30

31         NodeImpl prev = (NodeImpl)getPreviousSibling();
32         while (prev!=null) {
33             if (prev instanceof XSLWithParam) {
34                 if (this.variableFingerprint == ((XSLWithParam)prev).variableFingerprint) {
35                     compileError("Duplicate parameter name");
36                 }
37             }
38             prev = (NodeImpl)prev.getPreviousSibling();
39         }
40     }
41
42     public void process(Context context) throws TransformerException
43     {}
44
45
46     public Value getParamValue( Context context ) throws TransformerException
47     {
48         return getSelectValue(context);
49     }
50
51 }
52
53 //
54
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
55
// you may not use this file except in compliance with the License. You may obtain a copy of the
56
// License at http://www.mozilla.org/MPL/
57
//
58
// Software distributed under the License is distributed on an "AS IS" basis,
59
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
60
// See the License for the specific language governing rights and limitations under the License.
61
//
62
// The Original Code is: all this file.
63
//
64
// The Initial Developer of the Original Code is
65
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
66
//
67
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
68
//
69
// Contributor(s): none.
70
//
71
Popular Tags