You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Ramon F Herrera <ra...@patriot.net> on 2010/10/08 17:01:49 UTC

XPath based on SAX?

Newbie alert...

After a LOT of searching around (programming languages, libraries, 
toolkits, etc.) I have concluded that XPath is the best approach for my 
application. I found an implementation and my app is running fine. The 
only problem is that the app is rather slow, and I foresee the need for 
speed.

See my imports below. The reason for the sluggish performance is that my 
XPath is based on DOM, and for every element retrieved the whole tree 
must be re-evaluated. Needless to say, that is very inefficient.

Is there any XPath implementation based on SAX out there? Frankly, I 
don't even know where to start. Pointers would be very much appreciated.

TIA,

-Ramon

ps: I only do retrieves, my XML files are large and read-only.

------------------------------

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;




---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: XPath based on SAX?

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
DOM is just one possible representation. There is no constraint on the JAXP
interface (javax.xml.xpath.*) that the representation of the document needs
to be a DOM or that when you pass in an InputSource to this API that it
actually a builds a DOM under the covers, though that's likely what the
implementation in the JDK does. There may be alternative implementations
out there which perform better (faster / lower memory requirements) but
that's a question best suited for another mailing list as this doesn't
really have anything to do with Xerces.

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Ramon F Herrera <ra...@patriot.net> wrote on 10/08/2010 11:01:49 AM:

> Newbie alert...
>
> After a LOT of searching around (programming languages, libraries,
> toolkits, etc.) I have concluded that XPath is the best approach for my
> application. I found an implementation and my app is running fine. The
> only problem is that the app is rather slow, and I foresee the need for
> speed.
>
> See my imports below. The reason for the sluggish performance is that my
> XPath is based on DOM, and for every element retrieved the whole tree
> must be re-evaluated. Needless to say, that is very inefficient.
>
> Is there any XPath implementation based on SAX out there? Frankly, I
> don't even know where to start. Pointers would be very much appreciated.
>
> TIA,
>
> -Ramon
>
> ps: I only do retrieves, my XML files are large and read-only.
>
> ------------------------------
>
> import javax.xml.xpath.XPath;
> import javax.xml.xpath.XPathConstants;
> import javax.xml.xpath.XPathExpressionException;
> import javax.xml.xpath.XPathFactory;
>
> import org.w3c.dom.Node;
> import org.w3c.dom.NodeList;
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Re: XPath based on SAX?

Posted by Ramon F Herrera <ra...@patriot.net>.
On 10/8/2010 10:01 AM, Ramon F Herrera wrote:
>
> Newbie alert...
>
> After a LOT of searching around (programming languages, libraries,
> toolkits, etc.) I have concluded that XPath is the best approach for my
> application. I found an implementation and my app is running fine. The
> only problem is that the app is rather slow, and I foresee the need for
> speed.
>
> See my imports below. The reason for the sluggish performance is that my
> XPath is based on DOM, and for every element retrieved the whole tree
> must be re-evaluated. Needless to say, that is very inefficient.
>
> Is there any XPath implementation based on SAX out there? Frankly, I
> don't even know where to start. Pointers would be very much appreciated.
>
> TIA,
>
> -Ramon
>
> ps: I only do retrieves, my XML files are large and read-only.
>
> ------------------------------
>
> import javax.xml.xpath.XPath;
> import javax.xml.xpath.XPathConstants;
> import javax.xml.xpath.XPathExpressionException;
> import javax.xml.xpath.XPathFactory;
>
> import org.w3c.dom.Node;
> import org.w3c.dom.NodeList;

I am also interested in having XPath/DOM:

(1) Read the whole XML tree, and keep in memory. (initialization stage)
(2) Search the tree, as needed.

(In fact, this sounds even better than SAX, if there is such thing ;-)

-RFH



---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: XPath based on SAX?

Posted by Olivier Rossel <ol...@gmail.com>.
*** 1- TRICKY option:
I have had a LOT of success by using the dom4j + detach() feature, to
selectively
garbage collect some parts of the DOM tree as soon as I know my set of XPath
no longer need them.

cf. http://dom4j.sourceforge.net/dom4j-1.6.1/faq.html#large-doc

*** 2- SIMPLE option:
the other option is probably to try BaseX, which is tremendously
efficient in Read-Only environment
(and open-source).

cf. http://www.inf.uni-konstanz.de/dbis/basex/

BTW, if you need some consultancy for any of those options, I might be of help.
Feel free to contact me privately.

My humble 2 cents.



On Fri, Oct 8, 2010 at 5:01 PM, Ramon F Herrera <ra...@patriot.net> wrote:
>
> Newbie alert...
>
> After a LOT of searching around (programming languages, libraries, toolkits,
> etc.) I have concluded that XPath is the best approach for my application. I
> found an implementation and my app is running fine. The only problem is that
> the app is rather slow, and I foresee the need for speed.
>
> See my imports below. The reason for the sluggish performance is that my
> XPath is based on DOM, and for every element retrieved the whole tree must
> be re-evaluated. Needless to say, that is very inefficient.
>
> Is there any XPath implementation based on SAX out there? Frankly, I don't
> even know where to start. Pointers would be very much appreciated.
>
> TIA,
>
> -Ramon
>
> ps: I only do retrieves, my XML files are large and read-only.
>
> ------------------------------
>
> import javax.xml.xpath.XPath;
> import javax.xml.xpath.XPathConstants;
> import javax.xml.xpath.XPathExpressionException;
> import javax.xml.xpath.XPathFactory;
>
> import org.w3c.dom.Node;
> import org.w3c.dom.NodeList;
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org