[Expat-discuss] Nested calls to XML_Parse

Derek Snider derek at bluegenesis.com
Wed Jun 11 17:54:32 EDT 2003


It may not "make sense" to embed a call to XML_Parse, but it certainly
can be useful if you want to have XML elements which generate dynamic
XML content.

I went the route of creating a second parser, but XML_Parse should be
robust enough to properly handle being called by an element handler.  It
already supports appending data to the buffer (note the isFinal flag),
why not inserting data at the current point of parsing?


> -----Original Message-----
> From: Greg Martin [mailto:Greg.Martin at telus.com] 
> Sent: June 11, 2003 3:40 PM
> To: Derek Snider; expat-discuss at libexpat.org
> Subject: RE: [Expat-discuss] Nested calls to XML_Parse
> 
> 
> Expat is a stream oriented parser. It seems to me (as a 
> bystander using the API) that it wouldn't make sense to embed 
> a call to XML_Parse. You're not starting a new document you 
> are simply parsing embedded tags and that's what your 
> callback functions handle. A call to XML_Parse probably 
> resets the state of the parser or the stream position(and 
> hence your loop).  I suppose if the contents of a tag was 
> another xml document you could create a second parser object 
> and call XML_Parse using that parser ... Regards, Greg.
> 
> -----Original Message-----
> From: Derek Snider [mailto:derek at bluegenesis.com]
> Sent: Wednesday, June 11, 2003 11:42 AM
> To: expat-discuss at libexpat.org
> Subject: [Expat-discuss] Nested calls to XML_Parse
> 
> 
> Why do nested calls to XML_Parse (i.e. calling XML_Parse from 
> within an element handler) end up putting the parser into an 
> endless loop?
> 
> I don't mean code-wise why the library acts this way, but why 
> is this the intention?
> 
> Is it not reasonable to want the possibility of XML elements 
> expanding into more XML to be passed to the parser?
> 
> It seems to add a lot of unneccessary overhead to require 
> that nested parsing involve nested creation and freeing of 
> additional parsers (the only way I could get this to work).
> 
> Am I missing something?




More information about the Expat-discuss mailing list