Debian Codegraph @

net/sf/saxon/style/XSLWhen.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.style;
9
10 import net.sf.saxon.expr.Expression;
11 import net.sf.saxon.trans.XPathException;
12
13
14 /**
15 * Handler for xsl:when elements in stylesheet. <br>
16 * The xsl:while element has a mandatory attribute test, a boolean expression.
17 */
18
19 public class XSLWhen extends StyleElement {
20
21 private Expression test;
22
23 public Expression getCondition() {
24 return test;
25 }
26
27
28 public void prepareAttributes() throws XPathException {
29 test = XSLIf.prepareTestAttribute(this);
30 if (test == null) {
31 reportAbsence("test");
32 }
33 }
34
35 /**
36 * Determine whether this type of element is allowed to contain a template-body
37 *
38 * @return true: yes, it may contain a template-body
39 */
40
41 public boolean mayContainSequenceConstructor() {
42 return true;
43 }
44
45 public void validate(ComponentDeclaration decl) throws XPathException {
46 if (!(getParent() instanceof XSLChoose)) {
47 compileError("xsl:when must be immediately within xsl:choose", "XTSE0010");
48 }
49 test = typeCheck("test", test);
50 }
51
52 /**
53 * Mark tail-recursive calls on stylesheet functions. For most instructions, this does nothing.
54 */
55
56 public boolean markTailCalls() {
57 StyleElement last = getLastChildInstruction();
58 return last != null && last.markTailCalls();
59 }
60
61 /*@Nullable*/
62 public Expression compile(Compilation exec, ComponentDeclaration decl) throws XPathException {
63 return null;
64 // compilation is handled from the xsl:choose element
65 }
66
67 }