01: package net.sf.saxon.style;
02:
03: import net.sf.saxon.expr.Expression;
04: import net.sf.saxon.instruct.Executable;
05: import net.sf.saxon.om.AttributeCollection;
06: import net.sf.saxon.trans.XPathException;
07: import net.sf.saxon.type.ItemType;
08:
09: /**
10: * Handler for xsl:otherwise elements in stylesheet. <br>
11: */
12:
13: public class XSLOtherwise extends StyleElement {
14:
15: /**
16: * Determine the type of item returned by this instruction (only relevant if
17: * it is an instruction).
18: * @return the item type returned
19: */
20:
21: protected ItemType getReturnedItemType() {
22: return getCommonChildItemType();
23: }
24:
25: public void prepareAttributes() throws XPathException {
26: AttributeCollection atts = getAttributeList();
27: for (int a = 0; a < atts.getLength(); a++) {
28: int nc = atts.getNameCode(a);
29: checkUnknownAttribute(nc);
30: }
31: }
32:
33: /**
34: * Determine whether this type of element is allowed to contain a template-body
35: * @return true: yes, it may contain a template-body
36: */
37:
38: public boolean mayContainSequenceConstructor() {
39: return true;
40: }
41:
42: public void validate() throws XPathException {
43: if (!(getParent() instanceof XSLChoose)) {
44: compileError(
45: "xsl:otherwise must be immediately within xsl:choose",
46: "XTSE0010");
47: }
48: }
49:
50: /**
51: * Mark tail-recursive calls on stylesheet functions. For most instructions, this does nothing.
52: */
53:
54: public void markTailCalls() {
55: StyleElement last = getLastChildInstruction();
56: if (last != null) {
57: last.markTailCalls();
58: }
59: }
60:
61: public Expression compile(Executable exec) throws XPathException {
62: throw new UnsupportedOperationException(
63: "XSLOtherwise#compile() should not be called");
64: }
65:
66: }
67:
68: //
69: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
70: // you may not use this file except in compliance with the License. You may obtain a copy of the
71: // License at http://www.mozilla.org/MPL/
72: //
73: // Software distributed under the License is distributed on an "AS IS" basis,
74: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
75: // See the License for the specific language governing rights and limitations under the License.
76: //
77: // The Original Code is: all this file.
78: //
79: // The Initial Developer of the Original Code is Michael H. Kay.
80: //
81: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
82: //
83: // Contributor(s): none.
84: //
|