Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > I've done a Muenchian grouping, but how can I use it to generate summary info?

Reply
Thread Tools

I've done a Muenchian grouping, but how can I use it to generate summary info?

 
 
lennyw@comcast.net
Guest
Posts: n/a
 
      06-06-2006
Hi

I'm trying to use XSLT to do an xml to xml transformation where the
output xml contains summary data on the information in the input xml.
I've succesfully done a Muenchian grouping of the data from the input
xml file, but I can't see how to operate on the grouped result to
create and output the desired summary data. If someone could give a
reference to an example or provide an actual example I'd really
apprecaite it.

The actual stylesheet for the gouper is shown below. It groups data for
each input "row" element by "optionSymbol". Once the data is fully
grouped, I have data in ascending order of "optionSymbol", with the
same optionSymbols together. Which is a good first step. And it works.

But now what I'd like to do is sum the values of certain fields across
"row" elements, average the values of certain fields across
"row"elements, etc. but do the operations only on row elements sharing
the same "optionSymbol" Once these summary values have been
calculated, I want to output ONE "row" element containg the summary
data and the optionSymbol text for each disticnt optionSymbol in the
grouped list. Sort of like what you'd see someone do in a simple
spreadsheet.

I simply don't see how to accomplish this.

The thing that has me most confused is if there exists an accessible
node list of the grouped data at the start of the inner for loop of the
Muenchian grouper. And if so, how I get at it. If not, is there an
accessible node list of the grouped nodes after the inner for loop
ends? And how to get at it ?

I apologize if this question seems naive, but I've only been doing XSL
for a few weeks, and I'm trying to use it to create real production
code. A tall order (for me at least), but that's what's needed!

I'm wondering if this is even possible with XSLT.

Here is the XSLT for my Muenchian grouper (adapted from the OReilly
book):
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">

<xslutput method="xml" indent="no"/>

<xsl:variable name="nl">
<xsl:text>
</xsl:text>
</xsl:variable>

<!-- Group option symbols -->
<xsl:key name="optionSymbol" match="tr" use="td[20]"/>

<xsl:template match="/">
<xsl:for-each
select="//tr[generate-id(.)=generate-id(key('optionSymbol',
td[20])[1])]">
<xsl:sort select="td[20]"/>
<!-- Now group each row which matches the current optionSymbol -->
<!-- This gives us a full group of rows for each option symbol -->
<xsl:for-each select="key('optionSymbol', td[20])">

<!--SUMMARY SELECTION/ CALCULATION SHOULD HAPPEN HERE-->


</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


Thanks in advance for any help.

Lenny Wintfeld

 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      06-06-2006
On Tue, 06 Jun 2006 21:10:41 +0200,
<> wrote:

> But now what I'd like to do is sum the values of certain fields across
> "row" elements, average the values of certain fields across
> "row"elements, etc. but do the operations only on row elements sharing
> the same "optionSymbol" Once these summary values have been
> calculated, I want to output ONE "row" element containg the summary
> data and the optionSymbol text for each disticnt optionSymbol in the
> grouped list. Sort of like what you'd see someone do in a simple
> spreadsheet.


It sounds like you need something like this:
<xsl:value-of select="sum(key('optionSymbol', td[20])/td[1]) div
count(key('optionSymbol', td[20]))"/>
in stead of that inner <xsl:for-each select="key('optionSymbol',
td[20])"/> loop ...

But it would be easier to provide an answer when you gave a sample xml
input and output...

--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Veni, vidi, wiki (http://www.wikipedia.org)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Muenchian Grouping Method for Multiple Levels reclusive monkey XML 2 08-10-2005 02:04 PM
XSL grouping (Muenchian) Tristan Miller XML 2 01-31-2005 11:59 AM
Re: Can someone explain this snippet? Muenchian sorting. Marrow XML 2 07-07-2003 05:06 PM
Re: Can someone explain this snippet? Muenchian sorting. Colin Mackenzie XML 0 07-03-2003 03:45 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57