Subject: Re: [xsl] accessing last element of node set passed as parameter From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 21 May 2002 15:22:36 +0100 |
I think you need to show how you are setting your parameter. You say $result is <BAR i=1/><BAR i=2/><BAR i=3/> but is it a node set consisting of three nodes or is it what you'd get from applying xx:node-set() to <xsl;variable name="result"> <BAR i="1"/><BAR i="2"/><BAR i="3"/> </xsl;variable> which is a node-set consisting of a single node (a root node0 which has three children. In the former to get <BAR i="3"/> 9if taht was last in doc order) you would go $result[last()] but if you do that on the second case you would get the same as $result as taking teh last element from a set of one doesn't do anything. You say This also seemed to work, judging by the fact that <xsl:copy-of select="($result/BAR)[last()]" /> and <xsl:copy-of select="$result[last()]" /> produced equivalent (looking) output. But they can not have done. If $result holds a root node then $result/BAR selects all the BAR children of that node and ($result/BAR)[last()] selects the last of those children. But if $result contains three BAR nodes then $result/BAR selects all the BAR children of each element of $result, and that is empty so ($result/BAR)[last()] is similarly empty. > but using J's solution: > <xsl:variable name="prior" select="$result[last()]" /> > Is there a "root" element here that J's solution creates? It seems most likely that there was a root node in $result, and so teh above sets prior to be teh same as result and <xsl:value-of select="$prior/TEXT/@i" /> will give you the first i attribute of a TEXT child of result. David _____________________________________________________________________ This message has been checked for all known viruses by Star Internet delivered through the MessageLabs Virus Scanning Service. For further information visit http://www.star.net.uk/stats.asp or alternatively call Star Internet for details on the Virus Scanning Service. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] accessing last element of, paul morgan | Thread | Re: [xsl] accessing last element of, paul morgan |
[xsl] Grouping question, Spectron Internation | Date | [xsl] Parsing a List, kenneth . howlin |
Month |