KickJava   Java API By Example, From Geeks To Geeks.

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


1 package net.sf.saxon.style;
2 import net.sf.saxon.expr.Expression;
3 import net.sf.saxon.instruct.Executable;
4 import net.sf.saxon.om.AttributeCollection;
5 import net.sf.saxon.trans.XPathException;
6 import net.sf.saxon.type.ItemType;
7
8
9
10 /**
11 * Handler for xsl:otherwise elements in stylesheet. <br>
12 */

13
14 public class XSLOtherwise extends StyleElement {
15
16     /**
17      * Determine the type of item returned by this instruction (only relevant if
18      * it is an instruction).
19      * @return the item type returned
20      */

21
22     protected ItemType getReturnedItemType() {
23         return getCommonChildItemType();
24     }
25
26     public void prepareAttributes() throws XPathException {
27         AttributeCollection atts = getAttributeList();
28         for (int a=0; a<atts.getLength(); a++) {
29             int nc = atts.getNameCode(a);
30             checkUnknownAttribute(nc);
31         }
32     }
33
34     /**
35     * Determine whether this type of element is allowed to contain a template-body
36     * @return true: yes, it may contain a template-body
37     */

38
39     public boolean mayContainSequenceConstructor() {
40         return true;
41     }
42
43     public void validate() throws XPathException {
44         if (!(getParent() instanceof XSLChoose)) {
45             compileError("xsl:otherwise must be immediately within xsl:choose", "XTSE0010");
46         }
47     }
48
49     /**
50     * Mark tail-recursive calls on stylesheet functions. For most instructions, this does nothing.
51     */

52
53     public void markTailCalls() {
54         StyleElement last = getLastChildInstruction();
55         if (last != null) {
56             last.markTailCalls();
57         }
58     }
59
60     public Expression compile(Executable exec) throws XPathException {
61         throw new UnsupportedOperationException JavaDoc("XSLOtherwise#compile() should not be called");
62     }
63
64 }
65
66 //
67
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
68
// you may not use this file except in compliance with the License. You may obtain a copy of the
69
// License at http://www.mozilla.org/MPL/
70
//
71
// Software distributed under the License is distributed on an "AS IS" basis,
72
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
73
// See the License for the specific language governing rights and limitations under the License.
74
//
75
// The Original Code is: all this file.
76
//
77
// The Initial Developer of the Original Code is Michael H. Kay.
78
//
79
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
80
//
81
// Contributor(s): none.
82
//
83
Popular Tags