Debian Codegraph @

net/sf/saxon/style/XSLLocalVariable.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.om.StructuredQName;
11 import net.sf.saxon.trans.XPathException;
12 import net.sf.saxon.value.SequenceType;
13
14 /**
15 * Handler for xsl:variable elements acting as local variable declarations in a stylesheet. <br>
16 * The xsl:variable element has mandatory attribute name and optional attribute select
17 */
18
19 public class XSLLocalVariable extends XSLGeneralVariable {
20
21 private static int permittedAttributes =
22 SourceBinding.SELECT |
23 SourceBinding.AS;
24
25 /**
26 * Ask whether this element contains a binding for a variable with a given name; and if it does,
27 * return the source binding information
28 *
29 * @param name the variable name
30 * @return the binding information if this element binds a variable of this name; otherwise null
31 */
32
33 public SourceBinding getBindingInformation(StructuredQName name) {
34 if (name.equals(sourceBinding.getVariableQName())) {
35 return sourceBinding;
36 } else {
37 return null;
38 }
39 }
40
41 /**
42 * Determine whether this node is an instruction.
43 *
44 * @return true - it is an instruction (well, it can be, anyway)
45 */
46
47 public boolean isInstruction() {
48 return true;
49 }
50
51 @Override
52 public void prepareAttributes() throws XPathException {
53 sourceBinding.prepareAttributes(permittedAttributes);
54 }
55
56 /**
57 * Get the static type of the variable. This is the declared type, unless the value
58 * is statically known and constant, in which case it is the actual type of the value.
59 */
60
61 public SequenceType getRequiredType() {
62 return sourceBinding.getInferredType(true);
63 }
64
65 @Override
66 public void fixupReferences() throws XPathException {
67 sourceBinding.fixupReferences(null);
68 super.fixupReferences();
69 }
70
71 /**
72 * Process this local variable declaration by expanding any sequence constructor and setting
73 * the select expression to the result
74 *
75 * @param exec the executable
76 * @param decl the declaration being compiled
77 * @throws XPathException if an error occurs
78 */
79
80 public void compileLocalVariable(Compilation exec, ComponentDeclaration decl) throws XPathException {
81
82 //if (!sourceBinding.getReferences().isEmpty()) {
83 sourceBinding.handleSequenceConstructor(exec, decl);
84 //}
85
86 }
87
88
89 }
90