Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xml-dev] java and xpath

From: Liam Quin <liam@--.--->
To: c b <cindyloo_home@-----.--->
Date: 5/1/2007 3:14:00 PM
On Tue, May 01, 2007 at 07:56:57AM -0700, c b wrote:
>   I have a data-oriented XML schema db that contains mostly scheduling
>   information.. I have attempted to use javax.xml.* library to query
>   the db, with abysmal performance. 

>   statements such as
>   xpath.evaluate(doc,"//sdp:service//sdp:trip) or even the pre-compiled version
>   xexpr.evaluate(nodelist)
>    
>   are an order slower than the DOM call getTagByName("trip").

Most libraries have difficulty optimising // like that.
You are saying (in theory),
    go through the entire document, and for each element,
	look through all of its descendants,
	    and for each such descendant node, if it's an sdp::service
		look through all of its descendents
		    and for each such descendant node, if it's an
		    sdp::trip
			add it to the result list

Have you tried, for example,
    /document-element/sdp:service/sdp:trip
instead?

>   I see there are many xpath enabled libraries.. is there one in which
>   xpath utilization is much faster? at least on par with the DOM
>   calls?
Yes.

>   I've looked on the web and it seems that query processing
>   optimizaiton is an academic pursuit of it's own...
Yes, there are conferences for it too.  Just as with SQL optimization,
it's difficult.

>   Should I rather be using DOM's new implementation of XPath ?  should
>   I be using an RDBMS rather than an xml db at all if query
>   performance is going to be so slow?
You might want to try XML Query.

But first write XPath expressions that are as precise as you can.

Given

<students>
  <student>
    <name>Hairy</name>
    <eyes>brown</eyes>
  </student>
  <student>
    <name>Smelly</name>
    <eyes>green</eyes>
  </student>
</student>

there would never be any need to write
    student//name
because name is always a direct child of student, and you don't
see, e.g. student/eyes/name

Similarly, //student is needless, because
    /students/student
will get you there directly.

In XQuery there are implementations that will look at a schema
(using W3C XML Schema) for your data, if you have one, and deduce
this, so that the expressions /students/student and //student would
be equivalent.  Both open source and proprietary implementations
of XQuery do this sort of optimization (and so do some XSLT
implementations, but it sounds like XQuery would be a better fit here)

Liam

-- 
Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin/
http://www.holoweb.net/~liam/ * http://www.fromoldbooks.org/
Using Mandriva Linux, http:///www.mandrivalinux.org/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent