Re: [xml] Query about xmlNewReference



On Mon, Jun 23, 2008 at 11:51:59AM +0800, Ashwin wrote:
In the function xmlNewReference for the following bit of code
[...]
Or should the the line be

cur->children = ent->children? 

 No that's fine you want to a pointer to the entity
(see xmllint --debug test/ent1)

Hi,
  I still have a lingering doubt about the above, consider the example of
the attached file. The subtree of the entity reference node for &Fname;
consists of seven children.

This is because the child node of ent ref node &Fname; points to the Entity
Decl node Fname, hence effectively if try to get the child nodes of ent ref
node &Fname; we get 7 children.

Should not the child node of ent-ref node be a text node containing the
replacement text of the entity rather than the entire tree associated with
the corresponding entity declaration?

  Old email, I double-checked
  I still think that's fine, we are marking ent as the last children too

(gdb) n
2577            cur->children = (xmlNodePtr) ent;
(gdb) n
2578            cur->last = (xmlNodePtr) ent;

So yes in a sense we reference a long list, but we provide the
correct boundaries there. When looking at an entity reference children
(i.e. assuming no entity substitution) the current node dow not 'own'
the children, we just indicate (as much as possible) what nodes are
concerned by the entity value, they are the sub-list between children
and last.
For references those pointers have a slightly different semantic.

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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