For selecting nodes with XPath 1.0 only, you need to do a node set comparison: root/feng/heppa@id=/root/foo/bar/@id Of course, this has NxM complexity (as the others XSLT solutions) With XSLT 1.0 you should use keys because there are cross references: xsl:key name="kBarById" select="bar" use="@id.
For selecting nodes with XPath 1.0 only, you need to do a node set comparison: /root/feng/heppa@id=/root/foo/bar/@id Of course, this has NxM complexity (as the others XSLT solutions) With XSLT 1.0 you should use keys because there are cross references.
1 for the key solution! – Dimitre Novatchev Oct 5 '10 at 18:01 +1 for good solution. Of course, this has NxM complexity: that depends on the processor.Key() is a hint to the processor on how to optimize.
Processors can be very smart, such that a stylesheet without key() might be processed as efficiently as with key() (or in other words, a key is inferred). But agreed that an explicit key() solution is more likely to be efficient. – LarsH Oct 6 '10 at 21:37 @LarsH: I think that inferred keys are a shoot in the dark... Node set comparison are more likely supposed to be optimized (breaking the iteration on first success) but it would never be a linear N complexity, I think.
– user357812 Oct 6 '10 at 21:56 @Alejandro: I agree it's a shot in the dark, unless you know details about your XSLT processor... Mr. Kay has written a lot about Saxon optimization, so you can depend on some things. My point though was that in theory, one can't guarantee that the initial XPath expression has NxM complexity, nor that the stylesheet with explicit keys has linear complexity. Those depend on the processor implementation.
– LarsH Oct 7 '10 at 2:09 Good one! Thanks! – Lilleman Oct 23 '10 at 9:42.
I assume you mean /root/foo/bar since /root/foo elements don't have id. You're comparing the @id with itself, so of course it's true for the first node examined. You can use current() to reference the current node in an expression.
Yes, ofc! Thank you for the correction. :) And thanks a lot for the solution!
:D – Lilleman Oct 5 '10 at 13:00.
Another solution is to read the id attribute into a variable. : This might be handier, if your real use case is more complicated and you need to use the value of the id multiple times in this for-each section.
Very good, didn't think of that one. Thank you! – Lilleman Oct 5 '10 at 13:12.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.