Re: [xsl] XSL hold, compare, and replace param value

Subject: Re: [xsl] XSL hold, compare, and replace param value
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 14 Jul 2006 17:05:44 +0100
Others have given solutions but let me just observe (given a recent
thread about mutable variables) that the solutions follow the natural
human language description rather than a solution that you'd program in
an imperative programming language.

If you were describing the problem to a person you'd say that you want
to group the items by country and put a country heading at the top of
each group.


You wouldn't (or at least I wouldn't) introduce the notion of state and
some temporary variable holding the last seen country and say that for
each item you need to compare the current country with the value of the
variable stored at the last item.

The human-oriented description does not introduce any variables at all,
and the XSLT solutions typically don't use any variables either.
This is almost always the case when someone more familiar with
imperative programming languages has problems with the fact that xsl
variables "don't change". Usually it's not that you don't need to change
the value of a variable, it's that you don't need a variable at all.

David

Current Thread