[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: accessing last element of node set passed as param
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|