RE: [xsl] Getting the first and last nodes of a sorted nodeset

Subject: RE: [xsl] Getting the first and last nodes of a sorted nodeset
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 08 Apr 2004 13:26:35 -0400
Hi John,

It's good to know you're so far ahead with this. Sorry if the posts crosses: lists do that sometimes.

At 01:19 PM 4/8/2004, you wrote:
How do you "Bind the result of your sort to a variable" when (so far as
I am aware) you can only sort output elements from within a for-each or
apply-templates by using the xsl:sort element?

<xsl:variable name="sorted-result"> <xsl:apply-templates> <xsl:sort/> </xsl:apply-templates> </xsl:variable>

The thing is, in XSLT 1.0 this variable is now a Result Tree Fragment, a datatype that can be copied to output and that can be operated on as a string, but that can't be operated on as a node set. As you can imagine, the latter feature would be (is) extremely powerful -- and is what the node-set() extension function is for. (So exsl:node-set($sorted-result) turns this RTF into a node set you can apply templates to.) In XSLT 2.0, it's a node set already when it's created, so you can reprocess $sorted-result freely, no differently from your source document.

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