* is statically known and constant, in which case it is the actual type of the value.
*/
public SequenceType getRequiredType() {
// System.err.println("Get required type of $" + getVariableName());
SequenceType defaultType = (requiredType==null ? SequenceType.ANY_SEQUENCE : requiredType);
if (assignable) {
return defaultType;
} else if (requiredType != null) {
return requiredType;
} else if (select!=null) {
if (select instanceof EmptySequence) {
// returning Type.EMPTY gives problems with static type checking
return defaultType;
} else {
try {
// try to infer the type from the select expression
return new SequenceType(select.getItemType(), select.getCardinality());
} catch (Exception err) {
// this may fail because the select expression references a variable or function
// whose type is not yet known, because of forwards (perhaps recursive) references.
return defaultType;
}
}
} else if (hasChildNodes()) {
return new SequenceType(NodeKindTest.DOCUMENT, StaticProperty.EXACTLY_ONE);
} else {
// no select attribute or content: value is an empty string
return SequenceType.SINGLE_STRING;
}
}