You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Cory Isaacson <ci...@capita2.com> on 2000/08/27 01:22:51 UTC

Performance Question

I had a stylesheet using an Xpath statement like:

/root/element1/element2/....

I had to change it to:

//root/element1/element2/...

because the document fragment was now part of another document, and I needed to find the first occurrence of my actual root element.

Is using '//' instead of '/' going to cost a big performance hit?

Thanks,

Cory

Re: Performance Question

Posted by "Cory Isaacson (Compuflex)" <ci...@compuflex.com>.
Chris,

Here is the full problem. My root element is part of my document, which I then send over SOAP to another application. SOAP puts it in the SOAP envelope, and then gives me a pointer to my root element, which comes from the body of the SOAP envelope (several levels down). It would be hard to predict exactly where it is in the hierarchy in the new document, but as I have the pointer to the root element, isn't there some direct way I can get right to that element? If not, I'm going to have to move the element into a new document (which I had several suggestions on but none were very easy and most involved copying the node which seems costly as well).

Any other ideas? My documents are several hundred elements as well, so I need to do something.

Thanks,

Cory
  ----- Original Message ----- 
  From: Chris P. McCabe 
  To: xalan-dev@xml.apache.org 
  Sent: Saturday, August 26, 2000 7:43 PM
  Subject: Re: Performance Question


  Yes, it could be a huge performance hit if your XML is of moderate size or larger.  We were using // in a couple of places in our stylesheets, and I found that 80% of the total processing time for this particular stylesheet was spent looking for the element.  When I replaced it with an absolute path, I got all that time back.  There were a few hundred elements in the XML.  If your XML is only a few elements, it won't make much of a difference. 
    In order to resolve that type of path, it must look at every element in your XML tree because the depth in the hierarchy is not known.  If you know that your 'root' element is always one level down in the hierarchy, but you just don't know its parent, you could do something like /*/root/element1/element2/... instead, and that would not have the same performance hit. 

  Chris 

  Cory Isaacson wrote: 

    I had a stylesheet using an Xpath statement like: /root/element1/element2/.... I had to change it to: //root/element1/element2/... because the document fragment was now part of another document, and I needed to find the first occurrence of my actual root element. Is using '//' instead of '/' going to cost a big performance hit? Thanks, Cory
-- 
Chris P. McCabe -  Senior Software Systems Architect
Choice Hotels International - Information Technology
chris_mccabe@choicehotels.com  602-953-4416
    

Re: Performance Question

Posted by "Chris P. McCabe" <ch...@choicehotels.com>.
Yes, it could be a huge performance hit if your XML is of moderate size
or larger.  We were using // in a couple of places in our stylesheets,
and I found that 80% of the total processing time for this particular
stylesheet was spent looking for the element.  When I replaced it with
an absolute path, I got all that time back.  There were a few hundred
elements in the XML.  If your XML is only a few elements, it won't make
much of a difference.

  In order to resolve that type of path, it must look at every element
in your XML tree because the depth in the hierarchy is not known.  If
you know that your 'root' element is always one level down in the
hierarchy, but you just don't know its parent, you could do something
like /*/root/element1/element2/... instead, and that would not have the
same performance hit.

Chris

Cory Isaacson wrote:

> I had a stylesheet using an Xpath statement like:
> /root/element1/element2/.... I had to change it to:
> //root/element1/element2/... because the document fragment was now
> part of another document, and I needed to find the first occurrence of
> my actual root element. Is using '//' instead of '/' going to cost a
> big performance hit? Thanks, Cory

--
Chris P. McCabe -  Senior Software Systems Architect
Choice Hotels International - Information Technology
chris_mccabe@choicehotels.com  602-953-4416