/*
  Compile a script as provided by the script url
 */
 private CompiledScript loadFileScript(String scriptFilePath) throws IOException, ScriptException {
   if (scriptFilePath.startsWith("http://") || scriptFilePath.startsWith("https://")) {
     // Looks like we got ourselves an absolute url
     URLConnection connection = new URL(scriptFilePath).openConnection();
     InputStream stream = connection.getInputStream();
     return engine.compile(new InputStreamReader(stream));
   } else if (scriptFilePath.startsWith("/")) {
     File file = new File(documentRoot, scriptFilePath);
     return engine.compile(new FileReader(file));
   } else {
     File file = new File(basePath, scriptFilePath);
     return engine.compile(new FileReader(file));
   }
 }
  /* Compile a script as a text element provided as a text node or a cdata section
    or a combination
  */
  private CompiledScript loadTextScript(HTMLElement scriptElement) throws ScriptException {
    StringBuilder scriptText = new StringBuilder();
    for (HTMLNode node : scriptElement.getChildNodes()) {
      // only allowed are text nodes or cdata section
      assert (node.isText() || node.isCdataSection());

      scriptText.append(node.getNodeValue());
    }

    return engine.compile(scriptText.toString());
  }