RE: [xml] Substitution of nested entity references




-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com]
Sent: Wednesday, April 10, 2002 2:12 PM
To: Henke, Markus
Cc: 'xml gnome org'
Subject: Re: [xml] Substitution of nested entity references


On Wed, Apr 10, 2002 at 01:49:00PM +0200, Henke, Markus wrote:
- I've assumed that a xmlEntity have only child nodes with
  type XML_ENTITY_REF_NODE or XML_TEXT_NODE. Is this correct,
  and if not, which additional cases were to take into
  consideration?

  Well an entity content can be any "well balanced chunk", i.e.
the result of the content [43] production:

    http://www.w3.org/TR/REC-xml#NT-content

So we have XML_TEXT_NODE, XML_ENTITY_REF_NODE, XML_ELEMENT_NODE,
XML_CDATA_SECTION_NODE, XML_PI_NODE and XML_COMMENT_NODE.
The first two are already covered.
I guess from the last two we don't want to have any content
when resolving an entity reference?
For XML_ELEMENT_NODE and XML_CDATA_SECTION_NODE we could use
xmlNodeGetContent(), assumed that xmlResolveEntityRef() is
build in to resolve entity references that are contained by
a XML_ELEMENT_NODE?

  I'm getting *REALLY* confused now.

I'm sorry. That wasn't intended.

  What are you trying to achieve ?

I'd thought that was already clarified. We've started that
discussion around
http://mail.gnome.org/archives/xml/2002-February/msg00057.html
It was about resolving a entity reference by collecting the
content of the child nodes of the corresponding entity
declaration. You've mentioned that this has to be recursiv
(due to nested entity references) resp. that the behavior of
xmlNodeGetContent() has to be changed to do so.
xmlNodeGetContent() just return the content of the corresponding
entity declaration. Same thing for xmlGetProp() (and the like)
that doesn't return a full-resolved attribute value if it 
contains nested entity references. You'll get something like
value = "TextText &i_am_a_nested_entity_ref; MoreText".
I've offered to write a routine the recursively resolve
entity references, in
http://mail.gnome.org/archives/xml/2002-March/msg00189.html
i've posted my first attempt (named xmlResolveEntityRef())
together with some open questions. One of them was which
sort of child nodes are to take into consideration for a
XML_ENTITY_DECL.
The question above (the confusing one) is about how to handle
the different node types in a (recursiv) call of
xmlResolveEntityRef() to get the correct content.

 
- To get a usefull result, xmlResolveEntityRef() has to be
included in the libxml2 source, hum, wherever an entity is
resolved :)

   I do NOT understand. Entity resolution is done at parse time.
I was thinking your routine was running on an already built tree.

Yep (in this scenario build with xmlSubstituteEntitiesDefault(0) ).

So what on earth entity resolution has to do with your routine ?

Maybe i've expressed myself unclear. The already built tree contains
XML_ENTITY_REF_NODEs as part of content of element nodes or attribute
values. As above mentioned, e.g. a call to xmlGetProp() on such an
attribute
(e.g. <aElement aAttr="Text &i_contain_an_entity_ref; MoreText" />)
results in something like
value = "Text &i_am_a_nested_entity_ref; MoreText"
which isn't the expected result.
I would provide the routine (xmlResolveEntityRef()) as an approach
to do a correct substitution of nested entity references in libxml2.
 
  I said, I'm getting really confused about what you intend to do.

Again, sorry. I thought was clear since i've the preceding discussion
in mind (my first posting WRT this is more than a month old...)

If you substitute entities you will get text, element, PI and CDATA
nodes as the tree replacement content.

And nested entity references as above mentioned, that's the crux.

So why are you trying to remove them. No really I can't understand.

I wouldn't too, but i don't try to do so.
I want to accumulate the (useful) content of the different node
types (as child nodes of an entity declaration) with regard to the
case where the child node again is an entity reference (and do a
recursive call to xmlResolveEntityRef() in that case).
It's all about to enable routines like xmlGetProp(),
xmlNodeGetContent(), ... to result in a *complete* substitution
of an entity reference. 
 
Daniel

Hope it's clearer this time.
Thanx for your time!

Ciao, Markus



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