Re: Expression Logic 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 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 with: //record/field/../field then you may as well go straight there: /document/record/field 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. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format