RE: Entities (was [libxml++] libxml++ future)
- From: Dan Dennedy <dan dennedy org>
- To: libxmlpp <libxmlplusplus-general lists sourceforge net>
- Subject: RE: Entities (was [libxml++] libxml++ future)
- Date: Wed, 15 Oct 2003 23:54:11 -0400
On Wed, 2003-10-15 at 09:49, Murray Cumming Comneon com wrote:
> I can't check it in right now but ...
I will want to see this because it probably fills the gap in what I am
working on with the SAX parser and DOM builder.
> I believe I have implemented the entity parsing for xmlpp::DomParser. There
> is
> - a new EntityReference class, derived from Node (I'm not 100% sure that
> makes sense)
> EntityReferences are uses of entities, such as
> &somethingIdeclaredearlier;.
> We might need an EntityDeclaration class (or methods) as well.
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() );
}
> I'm not sure what people might want to do with an EntityRefernce or
> EntityDeclaration when they get it from the parser. I guess they might want
> to just interpet it themselves, based on some application-specific
> information. Or is there some extra information that they might want to get
> from the parser?
My biggest problem at the moment is *adding* an entity reference to the
tree. In DOM Level 2 the standard method is to call
Document.createEntityReference() followed by Node.appendChild().
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.
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.
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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]