RE: [xml] xmlNodeGetContent() for XML_ENTITY_REF_NODE




-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com]
Sent: Thursday, February 21, 2002 6:19 PM
To: Henke, Markus
Cc: 'xml gnome org'
Subject: Re: [xml] xmlNodeGetContent() for XML_ENTITY_REF_NODE


On Thu, Feb 21, 2002 at 06:02:54PM +0100, Henke, Markus wrote:
Hello,

with regard to 
http://mail.gnome.org/archives/xml/2001-October/msg00160.html
i'm trying to collect the content of a XML_ELEMENT_NODE without
consider the child-XML_ELEMENT_NODEs.
I'm wondering if it's intended that 'xmlNodeGetContent(myNode)'
generally results 'NULL' if 'myNode' is a XML_ENTITY_REF_NODE?
And if so, what's the appropriate method to get the (expanded)
content of a  XML_ENTITY_REF_NODE?

   Get the ENTITY_DEF by doing an entity lookup for the entity
with that name, concatenate the xmlNodeGetContent() of its 
children.

Yep, works (at least for non-nested entity refs)!


I'm not sure you can get this recursive.


Hum, you mean nested entity references? Weird, i've never
thought about this. My app instantly crashed as i've tested
it. Smell's like a new debugging session... 8]
I'd hoped that i could pilfer at 'xmlGetProp()', but it won't
do a recursiv entity substitution!?
However, i've to do this and i should manage it since cyclic
entity refs are illegal.
BTW, the libxml parser detects cyclic entity
references but it seems that it loops about 40 times? 


Another way would be to change xmlNodeGetContent()
behaviour on entities nodes.

I'll try to code a recursiv entity substitution for
XML_ENTITY_REF_NODEs. If it works for me i'll send
it to the list so you can decide if it makes sense to
include it in xmlNodeGetContent() (and possibly
xmlGetProp()...).


Another point: I've debugged my code to see what happens
and found that a node with type XML_ENTITY_REF_NODE
holds the expanded entity in it's 'content' component,

  Actually it's a pointer to the associated ENTITY_DEF
node content's, the subtree are shared.

I see. Debugging don't show that (at least not obvious).
 

although i've set 'xmlSubstituteEntitiesDefault(0)'.
Is this correct?

  yes, with xmlSubstituteEntitiesDefault(1) you would get the content
directly instead of the reference node.
  xmlSubstituteEntitiesDefault(0) means the tree keeps track of the
entities in the document (including in attribute values !) so it can
save them back. xmlSubstituteEntitiesDefault(1) wipe them out and
substitute them with their content.

Then xmlSubstituteEntitiesDefault(0) is what i need...8)


Daniel


Thanx & Ciao, Markus



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