if (parentNodes.contains(node)) {
return reportCircularity(node);
}
parentNodes.add(node);
try {
Source htmlSource = htmlElement.getSource();
XmlAttributeNode scriptAttribute = getScriptSourcePath(node);
String scriptSourcePath = scriptAttribute == null ? null : scriptAttribute.getText();
if (node.getAttributeEnd().getType() == TokenType.GT && scriptSourcePath == null) {
EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementImpl(node);
try {
LibraryResolver resolver = new LibraryResolver(context);
LibraryElementImpl library = (LibraryElementImpl) resolver.resolveEmbeddedLibrary(
htmlSource,
modificationStamp,
node.getScript(),
true);
script.setScriptLibrary(library);
resolvedLibraries.addAll(resolver.getResolvedLibraries());
errorListener.addAll(resolver.getErrorListener());
} catch (AnalysisException exception) {
//TODO (danrubel): Handle or forward the exception
AnalysisEngine.getInstance().getLogger().logError(
"Could not resolve script tag",
exception);
}
node.setScriptElement(script);
scripts.add(script);
} else {
ExternalHtmlScriptElementImpl script = new ExternalHtmlScriptElementImpl(node);
if (scriptSourcePath != null) {
try {
scriptSourcePath = UriUtilities.encode(scriptSourcePath);
// Force an exception to be thrown if the URI is invalid so that we can report the
// problem.
new URI(scriptSourcePath);
Source scriptSource = context.getSourceFactory().resolveUri(
htmlSource,
scriptSourcePath);
script.setScriptSource(scriptSource);
if (!context.exists(scriptSource)) {
reportValueError(