Hi,
<xml/> is an illegal element name in an XML document.
best,
-Rob
On Tue, 2008-07-01 at 22:07 +0100, Kieran Topping wrote:
> Hello,
>
> I am attempting to create an XML object, put it in scope, and then
> execute a script in this scope.
> However, when I run the attached simple java class, I get the following
> exception:
>
> Exception in thread "main" java.lang.IllegalStateException
> at
> org.mozilla.javascript.ScriptRuntime.getTopCallScope(ScriptRuntime.java:2986)
> at
> org.mozilla.javascript.ScriptRuntime.searchDefaultNamespace(ScriptRuntime.java:1145)
> at
> org.mozilla.javascript.xmlimpl.XMLLibImpl.getDefaultNamespace(XMLLibImpl.java:328)
> at
> org.mozilla.javascript.xmlimpl.XMLLibImpl.getDefaultNamespaceURI(XMLLibImpl.java:313)
> at
> org.mozilla.javascript.xmlimpl.XMLLibImpl.parse(XMLLibImpl.java:405)
> at
> org.mozilla.javascript.xmlimpl.XMLLibImpl.ecmaToXml(XMLLibImpl.java:438)
> at
> org.mozilla.javascript.xmlimpl.XMLObjectImpl.ecmaToXml(XMLObjectImpl.java:800)
> at org.mozilla.javascript.xmlimpl.XML.jsConstructor(XML.java:217)
> at
> org.mozilla.javascript.xmlimpl.XMLObjectImpl.execIdCall(XMLObjectImpl.java:591)
> at
> org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:127)
> at
> org.mozilla.javascript.BaseFunction.construct(BaseFunction.java:328)
> at org.mozilla.javascript.Context.newObject(Context.java:1406)
> at AddXmlToScope.main(AddXmlToScope.java:10)
>
> When parsing xml, XMLLibImpl checks to see whether there is a "default
> namespace" set up. In order to do this,
> ScriptRuntime.searchDefaultNamespace() attempts to examine
> Context.currentActivationCall and Context.topCallScope. However, because
> the XML object is being created outside of a script, these values are
> both null. This results in the IllegalStateException being thrown, as
> detailed above.
>
> Does anyone know whether this is this a bug, or is it me attempting to
> do something that I'm not really allowed to?
>
> Or is there a step that I'm missing in my java?
>
> Many thanks in advance,
>
> Kieran
>
>
> plain text document attachment (AddXmlToScope.java)
> import org.mozilla.javascript.*;
> public class AddXmlToScope {
> public static void main (String [] argv)
> throws Exception
> {
> Context cx = Context.enter();
> try {
> Scriptable scope = cx.initStandardObjects();
> // Create an XML object.
> Object xml = cx.newObject(scope, "XML", new Object [] {"<xml/>"});
> // Put the XML object in scope.
> ScriptableObject.putProperty(scope, "xml", xml);
> // Run a script in this scope. The script will have access
> // to the "xml" property.
> Object result = cx.evaluateString(scope, "var x = xml.name();",
> "<cmd>", 1, null);
> } finally {
> Context.exit();
> }
> }
> }
> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino