RE: Entities (was [libxml++] libxml++ future)



> From: Dan Dennedy [mailto:dan dennedy org] 
> Perhaps, but I added to be used in a sax entity declaration 
> callback: void Document::declare_entity(const std::string& 
> name, int type,
> 	 const std::string& publicId, const std::string& systemId,
> 	 const std::string& content)
> {
>  xmlAddDocEntity( _impl, (const xmlChar*) name.c_str(), type, 
>    (const xmlChar*) publicId.c_str(), (const xmlChar*) 
> systemId.c_str(),
>    (const xmlChar*) content.c_str() );
> }

Perfect, but I would call it set_entity_declaration(), which is more like
our current method names. 

> Note, in reference to your other message. the docs on 
> createEntityReference state: In addition, if the referenced 
> entity is known, the child list of the EntityReference node 
> is made the same as that of the corresponding Entity node.

Hmm, libxml does that too. I can not imagine why the child list is reused
for this, particularly when there can only be on child. I have added
EntityReference::get_resolved_text(), which seems to do the job. Maybe we
should have EntityDeclaration EntityReference::get_resolved_entity(), if I
can figure out what information in _xmlEntity is useful.

> xmlsoft's entities page writes:
> WARNING: handling entities on top of the libxml2 SAX 
> interface is difficult!!! If you plan to use non-predefined 
> entities in your documents, then the learning curve to handle 
> then using the SAX API may be long. 
> 
> When I presented my problem to Daniel Veillard on IRC, he 
> quickly backed me up into a situation where I was lacking 
> enough understanding and analysis of the situation, 
> complexities, and entities spec. I have since done some 
> further analysis.

Yes, it might be difficult, but if it can be done then we can do it and hide
the complexities.

I added an entity declaration and an entity reference to
examples/sax_parser/example.xml and I was surprised to see that if causes an
"entity not declared" error.

> Besides adding a reference to the tree, the other problem is 
> that the entityReference callback never seems to get called 
> in order to even add the reference. Even when the parser 
> context.replaceEntities = 0, it is not called, rather it is 
> encoded as &ref;. With replaceEntities = 1, the callback 
> getEntity is used and expects an entity pointer, which it 
> uses to do the substitution. However, if I have context 
> "foo&ref;bar" I would like it to call characters(), 
> entityReference(), characters() in order to build a child 
> node list of the content.
> 
> I'll be reviewing libxml2 source now.

I'll also be trying to investigate the SAX+entities problem, but I'll try to
check in my DOM stuff first, so I don't get too out-of-sync. I'll try to do
that this evening, but it might be tomorrow.

Murray Cumming
www.murrayc.com
murrayc usa net




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