Re: [xml] lazy libxml

On Mon, Jun 19, 2006 at 01:50:42PM +0100, Nic James Ferrier wrote:
I want a lazy implementation of libxml for my XRT project.

I am collecting my thoughts on how to build lazyness into libxml2.

If anyone has any views on how to do it, or has already done any work
on it then please contact me, or make suggestions on this thread.

For those of you who don't know... lazy xml is the introduction of
delayed computation of XML trees inside the dom. This means that you
can have a part of the tree that is not known until the tree is
serialized or until nodes within the tree are required.

For example, pseudo-code:

   DOM x = new DOM()
   El  a = x.new_element_child("a")
   El a_b = a.new_element_child(lazy_element("b"))

at this point a_b is not computed, it is present in the tree and it's
type is known but the content, it's length and all the other details
are hidden from view, indeed, they do not yet exist.

If we now do:

   print x.content()

then that causes element a_b to be serialized and thus the computation
that produces the tree must be run and we get the correct output.

So, really, lazy XML is just a way of introducing a sub-type into the
libxml2 type definitions to indicate whether an object is computed or
not. A function pointer will have to be stored with the object to
provide the implementation of the node.

This is pretty simple to do at the C level but it gets more
complicated if nodes are implemented in a higher level language,
Python say.

  The problem is that libxml2 core won't be aware of that subtype.
And adding a node type to libxml2 is not something I would do lightly.
I don't really understand what it is aiming at honnestly, nor the extend
of your question. You can always add up a function in the _private field
of a node, but that will only be interpreted by non-libxml2 code by


Daniel Veillard      | Red Hat
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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