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.ApplyImports;
06: import net.sf.saxon.instruct.Executable;
07: import net.sf.saxon.om.*;
08: import net.sf.saxon.trans.XPathException;
09: import net.sf.saxon.type.Type;
10: import net.sf.saxon.value.Whitespace;
11:
12: /**
13: * An xsl:apply-imports element in the stylesheet
14: */
15:
16: public class XSLApplyImports extends StyleElement {
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(
51: "No character data is allowed within xsl:apply-imports",
52: "XTSE0010");
53: }
54: } else {
55: compileError("Child element " + child.getDisplayName()
56: + " is not allowed within xsl:apply-imports",
57: "XTSE0010");
58: }
59: }
60: }
61:
62: public Expression compile(Executable exec) throws XPathException {
63: ApplyImports inst = new ApplyImports(
64: backwardsCompatibleModeIsEnabled());
65: inst.setActualParameters(getWithParamInstructions(exec, false,
66: inst), getWithParamInstructions(exec, true, inst));
67: ExpressionTool.makeParentReferences(inst);
68: return inst;
69: }
70:
71: }
72:
73: //
74: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
75: // you may not use this file except in compliance with the License. You may obtain a copy of the
76: // License at http://www.mozilla.org/MPL/
77: //
78: // Software distributed under the License is distributed on an "AS IS" basis,
79: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
80: // See the License for the specific language governing rights and limitations under the License.
81: //
82: // The Original Code is: all this file.
83: //
84: // The Initial Developer of the Original Code is Michael H. Kay.
85: //
86: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
87: //
88: // Contributor(s): none.
89: //
|