xsl-list
[Top] [All Lists]

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

2006-07-14 09:06:04

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



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--