Re: [xml] Allocating entities dynamically, without pre-existing DTD while using SAX



On Wed, Feb 19, 2003 at 07:08:28PM +0100, Marek Habersack wrote:
On Wed, Feb 19, 2003 at 12:47:05PM -0500, Daniel Veillard scribbled:
On Wed, Feb 19, 2003 at 12:58:13AM +0100, Marek Habersack wrote:
 1. use the getEntity() handler in the handler struct and allocate the
    entities there by calling xmlAddDocEntity or xmlAddDtdEntity. 

  it looks like the solution which will "make it work" the most easilly
BUT you must be aware that the markup templates won't be XML then !
Yes - that will be one of the "modes" only, though. The normal mode will
enforce full XML compliance. The problem I have with this way of providing
the entities that both of the functions mentioned above will bail out if
their 'doc' argument is NULL. I save the parser context in the user_data
passed to the callbacks and tried to use its 'myDoc' member to pass to the
above APIs - but it seems that at the time the callback is called, myDoc in
xmlParserCtxt is NULL. That means the entity will not get added to the
document. Is there any (sane) way around it?

  Hum, the document builder is done *on top* of SAX. I don't think you
can expect anything about myDoc when using SAX. You create and maintain
the document if you need one.

  this is actually the cleanest solution because your templates are
well formed XML now ! But this may cost a bit more at run-time I agree.
And the problem with it is that HTTP is not designed to preserve state - I
can imagine many race conditions with that approach in this application...

  Well don't use HTTP for the DOCTYPE. Any URL based identifier will do,
and provide your own implementation of those.

Basically, as I see it, I need xmlAddEntity not being static, I suppose :)
It seems, at first sight, I can just copy that function to my code and use
it internally to register entities. That breaks all the rules, but oh
well...

  No use xmlAddDocEntity on a document you maintain and associated to the
request processed.

Daniel


-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]