ok, I tried your proposal...(which doea helps ), but I still have the same issue. I
have debugged it down to:
nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn);
calls
rv = secMan->CheckConnect(nsnull, uri, "XMLDocument", "load");
that calls
nsresult rv = nsScriptSecurityManager::CheckLoadURIFromScript(cx, aTargetURI);
where cx is the current JS Context... created by the xpcshell....
that call:
nsCOMPtr<nsIPrincipal> principal;
if (NS_FAILED(nsScriptSecurityManager::GetSubjectPrincipal(cx,
getter_AddRefs(principal))))
return NS_ERROR_FAILURE;
that calls nsScriptSecurityManager::GetPrincipalAndFrame(cx, result, &fp);
so for me it seems that you need to have your JS context attached to a kind of url,
or frame, and a security manager setup to be able to load some XML from a file. this
will always fails from JS directly from xpcshell.... that's a real shame...
any other ideas ? I am quite frighten about changing any code here.....
JM
nntp://news.mozilla.org/netscape.public.mozilla.xpcom/<[EMAIL PROTECTED]>
Ah, the problem is that xpcshell does not spin up an event queue, so
there is nothing to drive the network-level events. It seems like you
should be seeing some kind of error in this case, but unfortunately that
isn't happening. So, it probably only looks like the load succeeded
when in fact it most likely did not succeed.
If you want to make it work with xpcshell, you can probably do so by
simply creating an event queue like so:
const nsIEventQueueService = Components.interfaces.nsIEventQueueService;
var eqs = Components.classes["@mozilla.org/event-queue-service;1"]
.getService(nsIEventQueueService);
eqs.createMonitoredThreadEventQueue();
Then, after the event queue is setup, using the synchronous load
mechanism should work as expected.
-Darin
jmp wrote:
>Right...
>
> I've got my facts wrong. This code works fine with Mozilla 1.4.2 and 1.7.2.
>
> However, and this is why I got confused: I have put this code into an XPCOM
> Compoment. If the XPCOM component is loaded from a XUL dialog: everything is
> cool... but if this is loaded from a JS started with xpcshell, then it doesn't
> quite work anymore. Actually, the document loading work, but I cannot query
> anything using nsIDOMXPathEvaluator...
>
> any ideas ???
>
> Thanks
>
>
>
> nntp://news.mozilla.org/netscape.public.dev.xml/<[EMAIL PROTECTED]>
>
> Hi,
>
> What is the best/recommended way of loading XML from a cpp mozilla application?
>
> {
> NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID);
> nsCOMPtr<nsIDOMXMLDocument> pXMLDoc;
> do_CreateInstance(kXMLDocumentCID, &rv);
> pXMLDoc->SetAsync( false );
> PRBool retval = false;
> NS_NAMED_LITERAL_STRING(url , "http://mysite/myxml" );
> pXMLDoc->Load( url , &retval );
> }
>
> Seems to work, but then when I use the nsCOMPtr<nsIDOMXPathEvaluator> to query the
> XML node, I always get an empty result set(stepped down to no document owner....)
> So i assume this is not the way to do it anymore (used to work with Mozilla 1.4.2,
> but not with mozilla 1.7.2).
>
> What is the best/recommented practice to do this ?
>
> Thanks
>
> JM
>
>
>
>
>
> [netscape.public.dev.xml]
>_______________________________________________
>Mozilla-xpcom mailing list
>[EMAIL PROTECTED]
>http://mail.mozilla.org/listinfo/mozilla-xpcom
>
>
[netscape.public.mozilla.xpcom]
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom