Re: [xml] Beginner's question about xPath



Hi,

On Thu, 2005-06-30 at 15:52 -0400, Liam R. E. Quin wrote:
On Wed, 2005-06-29 at 15:39 -0400, ABeylin axsone com wrote:

I cannot figure out how to use xPath without loading the entire XML into
memory.

This is an implementation-specific question, and for libxml2 the answer
is usually that you will need the whole document in memory.

If this is a problem (e.g. very large documents) there are other
approaches, especially with XPath 2.0 -- XSLT 2.0 and XQuery which both
use XPath 2.0 can operate over indexed collections of documents,
although there are not yet many implementations of that feature, and
none I think using libxml2.

The problem is that XPath expressions can easily be written that rely
on the entire document, e.g. count(//*) or section[position() = last()]
or using the ancestor axis to navigate around.  A lot of research has
been done on optimising XPath, some of it in the database community,
especially in conjunction with XQuery (www.w3.org/XML/Query).

Hope this helps although it might not be very encouraging!

Liam

For people eager to dive into implementing streaming XPath for Libxml2:
I found [1], a Java implementation for a subset of XPath, including
predicates, to be quite informative for me. But just googling for
"streaming XPath" will get you there anyway...

[1] http://www.cs.umd.edu/projects/xsq/

Regards,

Kasimier



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