Re: [xml] XPath with SAX

On Thu, Mar 13, 2008 at 10:56:38PM +0100, Frantisek ZACEK wrote:

I need to handle XPath in a application to select some specific nodes
from an XML tree.

The problem is, that the files involved might be quite large (>1GB) so
DOM parsing is not an option.

  Then you made a mistake allowing XPath to be used to query the files.
Basically someone did a design decision without understanding what it
meant, yes that's painful, there is only one solution to avoid this kind
of problem: learning before designing and implementing.

Now, libxml2 handles XPath with DOM, and from what I read in the
archives of this very mailing list, XPath support requires to know the
whole tree.
Why is that ? I mean; I did read the W3 recommandation about XPath,
and I still don't get it. It should be possible to support XPath with
a SAX parser, ... I mean, .. why not ? or at least an XPath support
that only needs a schema definition...

  Asking the question seems to indicate you either:
    - think only at the XPath queries *you* are interested into
    - don't understand yet the full expressiveness of XPath
in the first case, you ask the wrong question, in the second case I
suggest you re-read the XPath spec. BTW XPath 1.0 is unrelated to schemas,
but if you are interested in the topic i suggest you read the paper of
Layaïda and Co in PLDI07

Still, it is true that all uses I have found of XPath seemed to use
DOM which is unconceivable for too large files.

  Again i think you miss a lot of the expressiveness power of XPath when
making this assertion e.g.:
Evaluating an XPath is in gneral not possible in a single pass.
For single pass reduced lookup with a tiny support of XPath, there is
support in libxml2
and the xmlReader also has the possibility to use XPath on subset of
the tree


Red Hat Virtualization group
Daniel Veillard      | virtualization library
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]