RE: [xml] SaxParser: getEntity() callback



From: Daniel Veillard [mailto:veillard redhat com] 
On Wed, Oct 22, 2003 at 11:16:03AM +0200, 
Murray Cumming Comneon com wrote:
Has anyone ever successfully used the getEntity() callback? 
It needs 
to return an xmlEntity instance, but I can't imagine that 
anyone could 
create one with all the right voodoo contents: 
http://xmlsoft.org/html/libxml-tree.html#xmlEntity

I can't find any way to get the xmlEntity that would have 
been created 
by libxml automatically if I had set the getEntity() to NULL. That 
might at least be a starting point.

I know this is difficult, but I hope it isn't impossible.

  1/ Look at SAX2.c implementation 

I think this might be easier if that default implementation was publically
accessible. I think that's why it's easier with the DOM Parser. The DOM
Parser lets us resolve the entity reference if we like, or do our own thing.
With the SAX parser it's all or nothing.

I'm not sure exactly what part of SAX2.c would need to be public API.

  2/ Look at entities.c in 2.6.0 for the predefined static entities
  3/ Look at the XML-1.0 spec about the various processing of entities
     http://www.w3.org/TR/REC-xml#entproc
     consider the complexity of the given table
  4/ Consider the fact that libxml2 may either substitute entities or
     keep them in the tree (including in attributes content)

 You will get an idea of what's difficult, that it's not 
impossible (since libxml2 does it !), but that you will have 
to duplicate code behaviour from libxml2 in your SAX handler. 
 If you want proper entities processing the tree or xmlReader 
based approach are definitely simpler since libxml2 take care 
of the complexity.

Thanks. I think I'll just explain the complexity in the libxml++ reference
documentation, and leave it to future generations to make it simpler and/or
provide an example.

Murray Cumming
www.murrayc.com
murrayc usa net





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