[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mozilla-layout
Subject:    Re: HTML Parser Questions
From:       Rick Gessner <rickg () netscape ! com>
Date:       1998-09-26 2:21:54
[Download RAW message or body]


Tal Moran wrote:

> I'm trying to use the html parser module of NGLayout as a generic
> push-based parser.
> This means I just want to be able to give it raw buffers whenever they
> become available, without having to create a stream or read from a file.
>
> As far as I can tell, the CScanner class supports this with the Append
> method. However,
> I couldn't find any direct interface to this method from the  nsParser
> class. From what I understand of the code, in order to use the nsParser
> in a push-based manner you have to call its
> Parse(nsIURL*,nsIStreamObserver*,PRBool) method, after which you should
> call the
> OnStartBinding method, then OnDataAvailable every time there's more
> data, and finally OnStopBinding when there's no more data.
> 1. Is this the correct  procedure for push-based parsing?

No. There is another parse method that accepts a string that does what you
want.

> 2. I noticed that Parse(nsIURL*,nsIStreamObserver*,PRBool) pushes a new
> context, however it doesn't seem to ever get popped. Should it be popped
> in OnStopBinding?

The topmost context doesn't get popped. The content will die with the
parser.

> 3. In what scenario(s) do you actually need more than one context?

Planning for the future. : )

> 4. I'm not sure whether this is intentional or not, but none of the
> nsIStreamListener methods in nsParser check if mParserContext is null
> before using it.

Good point. I'll correct it. (Defensive programming is good...)

> 5. What would be the correct method to add pure buffer parsing?
> Preferrably, it shouldn't be dependent on netlib and should be as
> efficient as possible (Creating a pseudo-stream that reads from a buffer
> is not efficient, since the OnDataAvailable method has to allocate a new
> buffer and do an extraneous copy).

See point 1, which I think answers your question.

>
>
> Thanks,
>
> Tal Moran
> (tmoran@netvision.net.il)



["rickg.vcf" (text/x-vcard)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic