KickJava   Java API By Example, From Geeks To Geeks.

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


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
6 import com.icl.saxon.om.NodeInfo;
7 import com.icl.saxon.expr.*;
8
9 import javax.xml.transform.*;
10 import java.util.*;
11 import java.io.*;
12
13 /**
14 * An xsl:apply-imports element in the stylesheet
15 */

16
17 public class XSLApplyImports extends StyleElement {
18
19
20     /**
21     * Determine whether this node is an instruction.
22     * @return true - it is an instruction
23     */

24
25     public boolean isInstruction() {
26         return true;
27     }
28
29     public void prepareAttributes() throws TransformerConfigurationException {
30
31         AttributeCollection atts = getAttributeList();
32         
33         String JavaDoc selectAtt = null;
34         
35         for (int a=0; a<atts.getLength(); a++) {
36             int nc = atts.getNameCode(a);
37             checkUnknownAttribute(nc);
38         }
39
40     }
41
42     public void validate() throws TransformerConfigurationException {
43         checkWithinTemplate();
44     }
45         
46     public void process(Context context) throws TransformerException {
47
48         // handle parameters if any
49

50         ParameterSet params = null;
51         
52         if (hasChildNodes()) {
53             NodeImpl child = (NodeImpl)getFirstChild();
54             params = new ParameterSet();
55             while (child != null) {
56                 if (child instanceof XSLWithParam) { // currently always true
57
XSLWithParam param = (XSLWithParam)child;
58                     params.put(param.getVariableFingerprint(), param.getParamValue(context));
59                 }
60                 child = (NodeImpl)child.getNextSibling();
61             }
62         }
63
64         XSLTemplate currentTemplate = context.getCurrentTemplate();
65         if (currentTemplate==null) {
66             throw new TransformerException("There is no current template");
67         }
68
69         int min = currentTemplate.getMinImportPrecedence();
70         int max = currentTemplate.getPrecedence()-1;
71         context.getController().applyImports( context,
72                                                 context.getMode(),
73                                                 min,
74                                                 max,
75                                                 params);
76         context.setCurrentTemplate(currentTemplate);
77     }
78
79
80 }
81
82 //
83
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
84
// you may not use this file except in compliance with the License. You may obtain a copy of the
85
// License at http://www.mozilla.org/MPL/
86
//
87
// Software distributed under the License is distributed on an "AS IS" basis,
88
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
89
// See the License for the specific language governing rights and limitations under the License.
90
//
91
// The Original Code is: all this file.
92
//
93
// The Initial Developer of the Original Code is
94
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
95
//
96
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
97
//
98
// Contributor(s): none.
99
//
100
Popular Tags