[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Expression Logic Problem

Subject: Re: Expression Logic Problem
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 1 Aug 2002 11:17:32 +0100
re expression of a problem
Hi Charles,

> While I can appreciate esthetics, the two things I am most concerned
> with are correctness and efficiency. My XPath says find a field
> element which is a child of a record element, then get the first
> field element which is a child of the record element (at least
> that's what I think it says, and that appears to be backed up by
> XPath Explorer.) That is the most direct way I can see to get the
> desired element.

If you were looking for a specific field, then you're right, it's a
reasonable path. For example:

  /document/record/field[@id = 100]/../field[1]

I think that's actually better than:

  /document/record/field[@id = 100]/preceding-sibling::field[last()]

even though the latter takes less steps, because when you find the
first child of the parent it only visits two nodes, but when you find
the last preceding sibling it could involve a large number of visits
(depending on how many siblings there were, of course).

But if you're just finding the first field in any record, as you were


then you may as well go straight there:


rather than going down to the record's fields, then up again, then
down again.
> Now as to the efficiency, I have no feelings. I suspect that the
> initial double-slash could slow things down on a large document, and
> I can see that replacing it with an absolute path the the document
> root might be better, but I was hoping for a more practical reaction
> than one concerning its comeliness.

You're absolutely right about the //. Stepping down via the child axis
and the document element will be hugely more efficient.



Jeni Tennison

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.