Subject: [xsl] RE: Selecting the first node set From: "Fraser Goffin" <goffinf@xxxxxxxxxxx> Date: Sun, 06 Aug 2006 19:46:43 +0100 |
So, I suggest that the following will get you the first <Value> in the document regardless of the depth of the element:
(//Value)[1]
Hugh explained why your prior attempts don't work ... my wording for this is as follows: //Value[1] won't work because the predicate is bound at the step level so "//" looks through the entire document and "Value[1]" which is an abbreviation for "child::Value[1]" returns the first child named "Value", so the combination returns "the first child named Value at every level of the document".
This is a trick question I have had in my hands-on XSLT training class since 1999
I've also see it at conferences where vendors post it on a white board as a "challenge" to stylesheet writers to determine who knows their XPath and who doesn't.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Selecting text between tw, Petar Tahchiev | Thread | [xsl] Find whether nodeset contains, Phillip B Oldham |
Re: [xsl] Selecting text between tw, Petar Tahchiev | Date | RE: [xsl] Passing an XSLT param to , Michael Kay |
Month |