KickJava   Java API By Example, From Geeks To Geeks.

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


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.ApplyImports;
5 import net.sf.saxon.instruct.Executable;
6 import net.sf.saxon.om.*;
7 import net.sf.saxon.trans.XPathException;
8 import net.sf.saxon.type.Type;
9 import net.sf.saxon.value.Whitespace;
10
11 /**
12 * An xsl:apply-imports element in the stylesheet
13 */

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

22
23     public boolean isInstruction() {
24         return true;
25     }
26
27     public void prepareAttributes() throws XPathException {
28
29         AttributeCollection atts = getAttributeList();
30
31         for (int a=0; a<atts.getLength(); a++) {
32             int nc = atts.getNameCode(a);
33             checkUnknownAttribute(nc);
34         }
35     }
36
37     public void validate() throws XPathException {
38         checkWithinTemplate();
39         AxisIterator kids = iterateAxis(Axis.CHILD);
40         while (true) {
41             NodeInfo child = (NodeInfo)kids.next();
42             if (child == null) {
43                 break;
44             }
45             if (child instanceof XSLWithParam) {
46                 // OK;
47
} else if (child.getNodeKind() == Type.TEXT) {
48                     // with xml:space=preserve, white space nodes may still be there
49
if (!Whitespace.isWhite(child.getStringValueCS())) {
50                     compileError("No character data is allowed within xsl:apply-imports", "XTSE0010");
51                 }
52             } else {
53                 compileError("Child element " + child.getDisplayName() +
54                         " is not allowed within xsl:apply-imports", "XTSE0010");
55             }
56         }
57     }
58
59     public Expression compile(Executable exec) throws XPathException {
60         ApplyImports inst = new ApplyImports(backwardsCompatibleModeIsEnabled());
61         inst.setActualParameters(getWithParamInstructions(exec, false, inst),
62                                  getWithParamInstructions(exec, true, inst));
63         ExpressionTool.makeParentReferences(inst);
64         return inst;
65     }
66
67 }
68
69 //
70
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
71
// you may not use this file except in compliance with the License. You may obtain a copy of the
72
// License at http://www.mozilla.org/MPL/
73
//
74
// Software distributed under the License is distributed on an "AS IS" basis,
75
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
76
// See the License for the specific language governing rights and limitations under the License.
77
//
78
// The Original Code is: all this file.
79
//
80
// The Initial Developer of the Original Code is Michael H. Kay.
81
//
82
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
83
//
84
// Contributor(s): none.
85
//
86
Popular Tags