public Expression preEvaluate(ExpressionVisitor visitor) throws XPathException {
String lexicalQName = ((Literal)argument[0]).getValue().getStringValue();
StaticContext env = visitor.getStaticContext();
boolean b = false;
Configuration config = visitor.getConfiguration();
switch(operation) {
case ELEMENT_AVAILABLE:
b = ((XSLTStaticContext)env).isElementAvailable(lexicalQName);
break;
case FUNCTION_AVAILABLE:
long arity = -1;
if (argument.length == 2) {
arity = ((NumericValue)argument[1].evaluateItem(env.makeEarlyEvaluationContext())).longValue();
}
try {
String[] parts = config.getNameChecker().getQNameParts(lexicalQName);
String prefix = parts[0];
String uri;
if (prefix.length() == 0) {
uri = env.getDefaultFunctionNamespace();
} else {
uri = env.getURIForPrefix(prefix);
}
StructuredQName functionName = new StructuredQName(prefix, uri, parts[1]);
b = env.getFunctionLibrary().isAvailable(functionName, (int)arity);
} catch (QNameException e) {
XPathException err = new XPathException(e.getMessage());
err.setErrorCode("XTDE1400");
throw err;
}
break;
case TYPE_AVAILABLE:
try {
String[] parts = config.getNameChecker().getQNameParts(lexicalQName);
String prefix = parts[0];
String uri;
if (prefix.length() == 0) {
uri = env.getDefaultElementNamespace();
} else {
uri = env.getURIForPrefix(prefix);
}
if (uri.equals(NamespaceConstant.JAVA_TYPE)) {
try {
config.getClass(parts[1], false, null);
b = true;
} catch (XPathException err) {
b = false;
}
} else {
int fingerprint = config.getNamePool().allocate(prefix, uri, parts[1]) & 0xfffff;
SchemaType type = config.getSchemaType(fingerprint);
if (type instanceof BuiltInAtomicType) {
b = env.isAllowedBuiltInType((BuiltInAtomicType)type);
} else if (type instanceof BuiltInListType) {
b = config.isSchemaAware(Configuration.XSLT);
} else {
b = (type != null && (uri.equals(NamespaceConstant.SCHEMA) || env.isImportedSchema(uri)));
}
}
} catch (QNameException e) {