title: Cannot use document javascript object when running from Java
body: <p>I have the following javascript code that runs from java:</p>
  
  <pre><code>var doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html',  null);
  doc.documentElement.innerHTML = xmlResponse;
  </code></pre>
  
  <p>And I get the following error:</p>
  
  <pre><code>Caused by: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "document" is not defined. (&lt;Unknown source&gt;#13)
      at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3773)
      at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3751)
      at sun.org.mozilla.javascript.internal.ScriptRuntime.notFoundError(ScriptRuntime.java:3836)
      at sun.org.mozilla.javascript.internal.ScriptRuntime.name(ScriptRuntime.java:1762)
      at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Interpreter.java:1790)
      at sun.org.mozilla.javascript.internal.Interpreter.interpret(Interpreter.java:854)
      at sun.org.mozilla.javascript.internal.InterpretedFunction.call(InterpretedFunction.java:164)
      at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(ContextFactory.java:429)
      at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(RhinoScriptEngine.java:116)
      at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(RhinoScriptEngine.java:109)
      at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(ScriptRuntime.java:3163)
      at sun.org.mozilla.javascript.internal.InterpretedFunction.exec(InterpretedFunction.java:175)
      at sun.org.mozilla.javascript.internal.Context.evaluateReader(Context.java:1159)
      at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:210)
      ... 16 more
  </code></pre>
  
  <p>Do you have any clue of how to solve it?</p>