473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output 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

Jun 6 '06 #1
1 1650
On Tue, 06 Jun 2006 21:10:41 +0200, le****@comcast.net
<le****@comcast.net> 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)
Jun 6 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tristan Miller | last post by:
Greetings. I have a question involving sorting and grouping output using XSLT. I am trying to produce a publication list from a BibTeX-like XML file: <bibxml:file...
2
by: reclusive monkey | last post by:
I followed the instructions from the all-knowing Ms. Tennison here; http://www.biglist.com/lists/xsl-list/archives/200101/msg00070.html And it works great for the first two levels. However,...
1
by: rayt | last post by:
I’m relatively new to XSLT and must admit I’m finding it refreshing, but every now and again something comes along which floors me. Maybe it’s the old imperative language background that is hard to...
1
by: mike | last post by:
Hi, I'm trying to apply Muenchian grouping to the XML displayed below but having no success, I'm trying to group on the section element, any pointers would be much appreciated: Thanks, Mike
0
by: asearle | last post by:
Hi everyone, I have a XML file that I need to filter and group. Apparently XSL 2.0 offers some good grouping features but unfortunately (for reasons of compatibility) I think I need to stay with...
1
by: aleksander.hansen | last post by:
Hello, I have xml data that I need to group and sort. I have tried grouping it using the Muenchian Method. Probably not solved the best way, but it works. But I can't get the sorting right. ...
2
by: la.brunning | last post by:
Hello, I am trying to filter a Muenchian grouping I have created. I think I am fairly close, but I am not quite sure where to apply my filter; its been some time since I did any work with XSLT....
1
by: VSS | last post by:
Hello, Under the 'Current Status' footer i have the following control source: =Count(*) This tells me the sub total of rows under each 'current status' grouping. Under the Assigned team...
4
by: VSS | last post by:
Hello, Under the 'Current Status' footer i have the following control source: =Count(*) This tells me the sub total of rows under each 'current status' grouping. Under the Assigned team...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.