xsl-list
[Top] [All Lists]

Re: [xsl] Working around immutable variables

2018-03-02 15:12:30
1. in XSLT 1.0: http://www.jenitennison.com/xslt/grouping/muenchian.html

2. XSLT 2.0 and above:
  a). https://www.w3.org/TR/xquery-operators/#func-distinct-values
  b). https://www.w3.org/TR/xslt20/#xsl-for-each-group

Cheers,
Dimitre

On Fri, Mar 2, 2018 at 1:04 PM, Jacopille, David djacopille(_at_)mfs(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
Hello,



We have a for-each loop that constructs a table.  The first column is a
region that would normally look like the following – we would like to show
the first region name only to avoid repetition.



US

US

US

US

Europe

Europe

Europe

Asia

Asia



My non-xsl mind wants to use a mutable variable:

initialize a variable $current_region to “”
loop through each row
If current row’s region column COLUMN[@name=”region”] does not equal
$current_region then:

select the region so it shows in the table
reassign $current_region to the string value of the current row’s region
column



Perhaps comparing the current category to the preceding-sibling?



Perhaps a loop on select=”distinct_values… to find region names, enclosing
another loop that goes through each distinct region’s rows?  If position()=1
worked in that context perhaps this would work?



We’re aware of the saxon namespace that allows for the mutable variable
cheat, but would like to avoid this.



I would greatly appreciate your recommendations.



Thank you,

David Jacopille

Boston



MFS Email system made the following annotation
---------------------------------------------------------------------------------------------------------------------------------------
This email communication and any attachments may contain proprietary,
confidential, or privileged information. If you are not the intended
recipient, you are hereby notified that you have received this email in
error and that any review, disclosure, dissemination, distribution or
copying of it or its contents is prohibited. The sender does not waive
confidentiality or any privilege by mistransmission. If you have received
this email in error, please notify the sender immediately, delete this
email, and destroy all copies and any attachments.



-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they
write all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>