List Info

Thread: Inserting document fragment




Inserting document fragment
user name
2006-09-21 09:18:04
Hi,

When I insert a document fragment node
(XML_DOCUMENT_FRAG_NODE) into the 
XML tree (for example using xmlAddChild), the node itself
gets inserted 
instead of its child nodes. This is a bit inconvenient
because I am 
writing a DOM api for a scripting language we're developing
here, and 
the specification 
(http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-B6
3ED1A3) states:

> Furthermore, various operations -- such as inserting
nodes as
> children of another Node -- may take DocumentFragment
objects as
> arguments; this results in all the child nodes of the
> DocumentFragment being moved to the child list of this
node.

I know I can use xmlAddChildList with the children property
of the 
document fragment node, but there are no such functions for 
xmlAddPrevSibling (i.e. xmlAddPrevSiblingList). Is there an
easy way of 
inserting the children of a document fragment instead of the
document 
fragment itself?

Kris Breuker
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Inserting document fragment
user name
2006-09-21 09:44:22
On Thu, Sep 21, 2006 at 11:18:04AM +0200, Kris Breuker
wrote:
> Hi,
> 
> When I insert a document fragment node
(XML_DOCUMENT_FRAG_NODE) into the 
> XML tree (for example using xmlAddChild), the node
itself gets inserted 
> instead of its child nodes. This is a bit inconvenient
because I am 
> writing a DOM api for a scripting language we're
developing here, and 
> the specification 
> (http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-B6
3ED1A3) states:
> 
> > Furthermore, various operations -- such as
inserting nodes as
> > children of another Node -- may take
DocumentFragment objects as
> > arguments; this results in all the child nodes of
the
> > DocumentFragment being moved to the child list of
this node.

  libxml2 don't pretend to implement DOM.
XML_DOCUMENT_FRAG_NODE are
an invention of DOM, they don't mean anything from an XML
core spec 
point of view, best is to not generate them in the first
place.

> 
> I know I can use xmlAddChildList with the children
property of the 
> document fragment node, but there are no such functions
for 
> xmlAddPrevSibling (i.e. xmlAddPrevSiblingList). Is
there an easy way of 
> inserting the children of a document fragment instead
of the document 
> fragment itself?

  If you know how to operate on a doubly linked list see
-> next, -> prev
and on the parent node -> children and -> last. There
is already a awful
lot of entry points in libxml2, I'm not sure I want to add
more when in
general people are already just lost trying to find the
existing entry
points. Either iterate on the list with the existing
functions or do
direct access to list structures.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Inserting document fragment
user name
2006-09-21 09:51:53
Op 21-9-2006 11:44 heeft Daniel Veillard het volgende
geschreven:
> On Thu, Sep 21, 2006 at 11:18:04AM +0200, Kris Breuker
wrote:
> 
>>Hi,
>>
>>When I insert a document fragment node
(XML_DOCUMENT_FRAG_NODE) into the 
>>XML tree (for example using xmlAddChild), the node
itself gets inserted 
>>instead of its child nodes. This is a bit
inconvenient because I am 
>>writing a DOM api for a scripting language we're
developing here, and 
>>the specification 
>>(http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-B6
3ED1A3) states:
>>
>>
>>>Furthermore, various operations -- such as
inserting nodes as
>>>children of another Node -- may take
DocumentFragment objects as
>>>arguments; this results in all the child nodes
of the
>>>DocumentFragment being moved to the child list
of this node.
> 
> 
>   libxml2 don't pretend to implement DOM.
XML_DOCUMENT_FRAG_NODE are
> an invention of DOM, they don't mean anything from an
XML core spec 
> point of view, best is to not generate them in the
first place.
> 
> 
>>I know I can use xmlAddChildList with the children
property of the 
>>document fragment node, but there are no such
functions for 
>>xmlAddPrevSibling (i.e. xmlAddPrevSiblingList). Is
there an easy way of 
>>inserting the children of a document fragment
instead of the document 
>>fragment itself?
> 
> 
>   If you know how to operate on a doubly linked list
see -> next, -> prev
> and on the parent node -> children and -> last.
There is already a awful
> lot of entry points in libxml2, I'm not sure I want to
add more when in
> general people are already just lost trying to find the
existing entry
> points. Either iterate on the list with the existing
functions or do
> direct access to list structures.

Ok, I will look into that then.

Thanks, Kris
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )