473,611 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "optionSymb ol". Once the data is fully
grouped, I have data in ascending order of "optionSymb ol", 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"elemen ts, etc. but do the operations only on row elements sharing
the same "optionSymb ol" 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:styleshe et 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="optionSym bol" match="tr" use="td[20]"/>

<xsl:template match="/">
<xsl:for-each
select="//tr[generate-id(.)=generate-id(key('optionS ymbol',
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('op tionSymbol', 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 1679
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"elemen ts, etc. but do the operations only on row elements sharing
the same "optionSymb ol" 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('opti onSymbol', td[20]))"/>
in stead of that inner <xsl:for-each select="key('op tionSymbol',
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
2729
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 xmlns:bibxml="http://bibtexml.sf.net/"> <bibxml:entry id="foo01"> <bibxml:article> <bibxml:title>Foo</bibxml:title>
2
1962
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, when I tried to apply it to three levels, the third level just doesn't show. I am sure its something obvious but I just can't spot it. Can anyone see where I have gone wrong? Thanks in advance. Sample from XML file;
1
2571
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 shake. This is an example of a dark cloud in my brave new declarative world. Clearing duplication is bread and butter but in XSLT it’s not. The old preceding axis method is both too slow and destined to failure. The Muenchian method, although sublime...
1
1321
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
1492
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 XSL 1.0. I have found that by using a 'key' I can get my XSL to group the data in my XML file (see example below) but am not sure how to apply a variable to filter to this grouping. I have experimented with a hard-coded filter (e.g. for a...
1
1515
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. Here's my XML: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="channel.xslt"?> <SearchResults> <SearchHit>
2
1518
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. An example of my XML; <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="Structure.xsl" type="text/xsl"?> <dataroot xmlns:od="urn:schemas-microsoft-com:officedata"> <CostCentre>
1
1321
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 member footer, I have the same as the above control source. This tells me how many rows in total each assigned team member has.
4
1318
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 member footer, I have the same as the above control source. This tells me how many rows in total each assigned team member has.
0
8097
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8240
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8411
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7038
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6072
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4042
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4108
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1692
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.