[Expat-discuss] Re: isFinal parameter

Carlos Pereira carlos at pehoe.civil.ist.utl.pt
Thu Mar 13 22:07:36 EST 2003


>>> Carlos Pereira writes:
>>>  > Both XML_Parse and XML_ParseBuffer have a isFinal parameter
>>>  > that tells Expat whether this is the last block or not.
>>> ...
>>>  > 3) run XML_Parse always with isFinal parameter set to FALSE.
>>>  > This is easier but it really looks completely wrong.
>> 
>>> This is entirely reasonable, and quite common.  Since this is easier
>>> to handle consistently and keeps the code calling into Expat simpler,
>>> that's a good way to do it.  I certainly use this in the Python
>>> bindings.
>> 
>> Thanks a lot, this helps me a lot, I was under the impression
>> that Expat would take special precautions for the last block,
>> but I can see now that it shouldn't really matter.

>Oh, sure there is a difference between isFinal == 0 and isFinal == 1.
>With isFinal == 0, the parser don't complain, if the block to parse
>ends in the middle of markup, or without all levels closed etc. It
>does, if isFinal == 1.

>Therefor, it may be wise, to call XML_Parse() with a 0 bytes long
>block (this is legal) and isFinal == 1, after you have noticed the end
>of the input in the wrapper code around. Otherwise, you may no
>detected, if the input ended premature.

That is very clever, many, many thanks for clarifying this point.
I just implemented your expert advice. The picture is now clear.

Thank you both, Fred and Rolf, for helping me.

Carlos



More information about the Expat-discuss mailing list