[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Expression Logic Problem
Subject: Re: [xsl] Expression Logic Problem From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 1 Aug 2002 11:17:32 +0100 |
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 with: //record/field/../field[1] then you may as well go straight there: /document/record/field[1] 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to test by nodename i, Jeni Tennison | Thread | [xsl] Namespace, aruniima . chakrabar |
[xsl] How to test by nodename if no, René de Vries | Date | [xsl] Namespace, aruniima . chakrabar |
Month |
Keywords