select/join using XSL

J

[Jongware]

I have a large table in XML, of the form (simplified)
<item><a>data1</a><b>more 1</b></item>
<item><a>data1</a><b>more 2</b></item>
<item><a>data2</a><b>more 3</b></item>
-- where I want the output to be
"data1: more 1, more 2
data2: more 3"
i.e., all <a> tags with the same contents grouped into one output item. I can
select them iterating over <item>, using sth like
<xsl:variable name="current_item" value="." />
<xsl:variable name="curr_subset" value=item[a=$current_item]" />
(that's OTOH; it looks like this, anyway), so I get subsets consisting of all
<a>'s containing "data1", "data2" etc. However. I get this subset _for each_ of
the <item>'s, so, for the above example, I get it *twice* for "data1".
I sense the logic, and yet it's somehow not what I intended. What am I missing?
(My XSLT proggie misses the 'unique' function, or whatever it is called--that'd
be an answer :)

[Jw]
 
P

Pavel Lepin

I have a large table in XML, of the form (simplified)
<item><a>data1</a><b>more 1</b></item>
<item><a>data1</a><b>more 2</b></item>
<item><a>data2</a><b>more 3</b></item>
-- where I want the output to be
"data1: more 1, more 2
data2: more 3"
i.e., all <a> tags with the same contents grouped into one
output item.

XSLT FAQ. Grouping problems. GIYF.
 
J

[Jongware]

Pavel Lepin said:
XSLT FAQ. Grouping problems. GIYF.

Google *is* my friend, but it's a very reticent one. The XSLT faq on usenet.faqs
is pretty worthless -- it took me a while to sort out the exact terms to look
for, although 'grouping' did find a lot more than my pseudo-SQL notation :)
For future reference: it's called the "Muench method":
<q>The Muenchian technique is a grouping method discovered by Steve Muench</q>
(No apparent relation to the Scream painter.) Anyhoo, thanks for nudging me in
the proper direction; I got it working.

[Jw]
 
A

Arndt Jonasson

For future reference: it's called the "Muench method":
<q>The Muenchian technique is a grouping method discovered by Steve Muench</q>
(No apparent relation to the Scream painter.)

The painter's name is not quite identical, though: it's Munch.
 
J

[Jongware]

Arndt Jonasson said:
The painter's name is not quite identical, though: it's Munch.

Sorry, musta had a bad case of the umlauts. You must be Swedish as well.

.... (silence)

Oops--just joking! -- Norvegian!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top