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: "Hansen, John" <John.Hansen@xxxxxxxxxx>
Date: Thu, 8 Apr 2004 10:19:45 -0700
You may have missed my follow-up posts on this topic.  Almost
immediately after I posted my question I realized that the solution was
quite simple.  

My friend's task was to take XML containing dates at various nesting
levels, find the earliest date, find the latest date, generate an HTML
table with a column for every calendar date from earliest to latest
(whether or not those dates happen to exist in the XML).  He already has
a fairly-complicated set of templates that he uses to generate the
proper HTML output (one of which takes a start and a stop date as
parameters).  He just couldn't figure out how to obtain both the
earliest and the latest dates from the input XML in order to then call
his named template with those two dates.  

I posted my solution yesterday.  It involved two for-each loops with the
first sorting by date and then calling a template when position()=1 with
the current node as the parameter.  That template contained a for-each
loop sorting by date which called the desired template when
position()=last() with the parameter it received and the current node.

The processing architecture of this particular problem is Internet
Explorer (our web services output XML with stylesheet references which
is processed by the browser).  That makes it kind of difficult to
pipeline transformations.

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?

Current Thread