Re: [xsl] RE: XSLT - How to find the last element in a group of nodes inside of a for loop

Subject: Re: [xsl] RE: XSLT - How to find the last element in a group of nodes inside of a for loop
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 17 Jan 2008 14:53:50 -0500
Alice,

At 02:26 PM 1/17/2008, you wrote:
Referring to your question, have you tried using <xsl:value-of select="@zone[last()]">?

That won't work, since selecting @zone is selecting the 'zone' attribute of the context node, of which, if there is any at all, there is (only) one, so either you get the 'zone' attribute or you don't. In no case is it a method of selecting from among a set of 'zone' attributes.


Nor did the OP have 'zone' attributes: they are elements. But "zone[last()]" won't pick what he wants either, since it selects the last of the 'zone' element children of the context (a long way of saying the same thing is "child::zone[position()=last()]", but note that the functions 'position()' and 'last()' return different values when used in a predicate than they do when they are evaluated within the context of a template match. So what will be returned is the last 'zone' child element in document order, not in the sorted order the OP wants.

But don't worry: the question as stated was simple enough, and if Harsh doesn't now have the info he needs, he can post again to clarify.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread