Load XML from content

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Load XML from content

Neil Deakin
I want to load an XML document from within content, specifically the
template builder. There's already some code there which makes an
absolute url and checks for the same origin and so forth, although it
would be nice to just use a generic version which checks that.

What is the best API to use to start off an asynchronous document load?
I have an nsIDocument for the base url, the string url to load, and all
I need is a notification with the document when it has done loading.

/ Neil
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: Load XML from content

Boris Zbarsky
Neil Deakin wrote:
> What is the best API to use to start off an asynchronous document load?
> I have an nsIDocument for the base url, the string url to load, and all
> I need is a notification with the document when it has done loading.

Hmm... Async load...

Your best bet if you don't want to write new code may be XMLHttpRequest with
some null jscontext pushing first to prevent its normal security checks and
stuff, I guess.  Not sure how well that plays on trunk, really...

We should really have a better API for this (maybe nsAsyncLoadService to
complement nsSyncLoadService?).  If nothing else, XBL could really benefit from
it, I suspect.

-Boris
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: Load XML from content

Boris Zbarsky
In reply to this post by Neil Deakin
Neil Deakin wrote:
> What is the best API to use to start off an asynchronous document load?

Another option, I guess is to use nsIDOMXMLDocument (set async to true and call
load()).  I guess you'd want to watch for the onload event on the document,
then.... or something.  It's hard to get this right in general without leaking;
XBL fails for example.  :(

-Boris
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: Load XML from content

Neil Deakin
Boris Zbarsky wrote:
> Neil Deakin wrote:
>> What is the best API to use to start off an asynchronous document load?
>
> Another option, I guess is to use nsIDOMXMLDocument (set async to true
> and call load()).  I guess you'd want to watch for the onload event on
> the document, then.... or something.  It's hard to get this right in
> general without leaking; XBL fails for example.  :(
>

That's the technique I've been using currently. What will leak?
Something to do with the event listener?

/ Neil
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: Load XML from content

Boris Zbarsky
Neil Deakin wrote:
> That's the technique I've been using currently. What will leak?
> Something to do with the event listener?

If the event listener holds a strong ref to the doc, you have a cycle.
Unfortunately, I'm not sure the onload event always fires (e.g. if the user hits
the stop button on a pageload onload does not fire).  So it's not clear when to
break the cycle...

-Boris
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml