## Re: [xsl] Calculating groups of repeating elements

 Subject: Re: [xsl] Calculating groups of repeating elements From: "G. Ken Holman" Date: Thu, 11 Dec 2008 08:41:25 -0500
At 2008-12-10 18:42 -0600, Quinn Dombrowski wrote:
Thanks for looking at this! Sorry for not being as clear as I could've been with what I'm looking for. For the example data set, I'm trying to automatically generate an output something like this:

```Aa + C + Qqq: 2 places (1, 3)
Aa + C: 3 places (1, 2, 3)
Aa + Zz: 2 places (2, 3)
C + Qqq: 2 places (1, 3)```

So it lists all the groups of 2+ words that appear together in 2+ places. This list is sorted by length of the group (3 words is the maximum number of words that occurs in 2+ places in the sample data), but it'd be nice to also be able to sort by number of places:

```Aa + C: 3 places (1, 2, 3)
Aa + Zz: 2 places (2, 3)
etc.
```

Sorry, that would be beyond my volunteer allocation for this morning ... too much going on right now.

I was using intersects to get places with Aa AND C AND Qqq (<xsl:value-of select="count(atlas/place/place_number[../words/word='Aa'] intersect atlas/place/place_number[../words/word='C'])"/>), but got overwhelmed by the number of ways I'd have to plug in all the different words to go through the data exhaustively-- the real data has 250+ places and 75+ words.

But for you and the archive, be aware that your concept of intersect above wouldn't help in the case of XSLT 2.0:

\$a intersect \$b

```   returns those tree nodes in node set \$a that are the same tree nodes
found in node set \$b ... not by value, but the nodes themselves.```

For this reason an "Aa" node in place 1 would not be recognized as being the same as the "Aa" node in place 2 and would not be returned in an intersection.

I hope this steers you away from an unsuccessful approach.

. . . . . . . . . Ken

```--
Upcoming XSLT/XSL-FO, UBL and code list hands-on training classes:
:  Sydney, AU 2009-01/02; Brussels, BE 2009-03; Prague, CZ 2009-03
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video