Subject: Re: [xsl] Accessing the Nth Occurrence of an Element From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Tue, 16 Sep 2008 10:13:11 +0100 |
2008/9/16 Michael Kay <mike@xxxxxxxxxxxx>: > >> I want to get the name of the fifth monkey (Phil). I thought >> this would do it: >> >> ---------------------------------- >> <xsl:template match="forest"> >> <xsl:text>The fifth monkey's name is: >> </xsl:text><xsl:value-of select="//monkey[5]/@name"/> </xsl:template> >> ---------------------------------- >> >> But this doesn't seem to work. > > This question was last asked (and answered) just 9 hours before your post, > and before that about a week ago. > > Hope you'll stick around on the list for a bit now. Read what comes, you can > learn a lot from it, and avoid the embarrassment of asking questions that > have been answered so recently. It seems a common requirement these days :) Perhaps all the spec, text books and examples should be changed to say: "To do a complete scan of the document for foo elements use /descendant::foo" because: a) it would avoid the confusion b) the -or-self part of the // axis is pointless when starting at the root The descendant-or-self axis (//) should only really be used when starting from an element somewhere in the tree, and even then with caution. -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Accessing the Nth Occurre, Michael Kay | Thread | Re: [xsl] Accessing the Nth Occurre, David Carlisle |
Re: [xsl] Date YYYYMMDD format XSLT, David Carlisle | Date | Re: [xsl] Date YYYYMMDD format XSLT, Florent Georges |
Month |