}
//
// Scripting language invocation.
//
Interpreter interpreter = bridgeContext.getInterpreter(type);
if (interpreter == null) {
UserAgent ua = bridgeContext.getUserAgent();
if (ua != null) {
ua.displayError(new Exception("Unknown language: "+type));
}
return;
}
if (!languages.contains(type)) {
languages.add(type);
initializeEnvironment(interpreter, type);
}
try {
String href = XLinkSupport.getXLinkHref(script);
Reader reader;
if (href.length() > 0) {
// External script.
ParsedURL purl = new ParsedURL
(XMLBaseSupport.getCascadedXMLBase(script), href);
checkCompatibleScriptURL(type, purl);
reader = new InputStreamReader(purl.openStream());
} else {
// Inline script.
Node n = script.getFirstChild();
if (n != null) {
StringBuffer sb = new StringBuffer();
while (n != null) {
sb.append(n.getNodeValue());
n = n.getNextSibling();
}
reader = new StringReader(sb.toString());
} else {
continue;
}
}
interpreter.evaluate(reader);
} catch (IOException e) {
if (userAgent != null) {
userAgent.displayError(e);
}