How to request data from a lazily-created tree structure ?
Diez B. Roggisch
deets at nospam.web.de
Mon Jun 16 17:16:54 EDT 2008
méchoui schrieb:
> Problem:
>
> - You have tree structure (XML-like) that you don't want to create
> 100% in memory, because it just takes too long (for instance, you need
> a http request to request the information from a slow distant site).
> - But you want to be able to request data from it, such has "give me
> all nodes that are under a "//foo/bar" tree, and have a child with an
> "baz" attribute of value "zzz".
>
> Question :
>
> Do you have any other idea to request data from a lazily-created tree
> structure ?
>
> And does it make sense to create a DOM-like structure and to use a
> generic XPath engine to request the tree ? (and does this generic
> XPath engine exist ?)
>
> The idea is to have the tree structure created on the fly (we are in
> python), only when the XPath engine requests the data. Hopefully the
> XPath engine will not request all the data from the tree (if the
> request is smart enough and does not contain **, for instance).
Generic XPath works only with a DOM(like) structure. How else would you
e.g. evaluate an expression like foo[last()]?
So if you really need lazy evaluation, you will need to specifically
analyze the query of interest and see if it can be coded in a way that
allows to forget as much of the tree as possible, or even better not
query it.
Diez
More information about the Python-list
mailing list