[xsl] Grouping elements and summing their attribute value into one single element

Subject: [xsl] Grouping elements and summing their attribute value into one single element
From: <michella@xxxxxxx>
Date: Thu, 24 Mar 2005 11:53:50 +0100
Hello,

I'm currently having trouble choosing an efficient way to solve my problem :

Here the XML :

<EintrdgeListe>
	<Eintrag BZ_Abgangsdatum="20050211" BZ_Zeit="0811" BZ_DLA="B1" BZ_Format="NF"
BZ_Verarbeitung="Maschine" BZ_Bundart="999" BZF_Ankunftsdatum="20050211"
BZF_Zeit="1442" BZF_Zustelldatum="20050211" BZF_MengeGezdhlt="58"/>
	<Eintrag BZ_Abgangsdatum="20050211" BZ_Zeit="0835" BZ_DLA="B1" BZ_Format="NF"
BZ_Verarbeitung="Maschine" BZ_Bundart="999" BZF_Ankunftsdatum="20050211"
BZF_Zeit="1442" BZF_Zustelldatum="20050211" BZF_MengeGezdhlt="47"/>
	<Eintrag BZ_Abgangsdatum="20050211" BZ_Zeit="0847" BZ_DLA="B1" BZ_Format="NF"
BZ_Verarbeitung="Maschine" BZ_Bundart="999" BZF_Ankunftsdatum="20050211"
BZF_Zeit="1442" BZF_Zustelldatum="20050211" BZF_MengeGezdhlt="42"/>
...
</EintrdgeListe>

And my problem : Here we have three elements. Their attributes are all
similar, except BZF_MengeGezdhlt (the data) and BZF_Zeit , which is the time
where this data was created. (0835 means 08.35 am.)
Now, I have to compare these datas with other ones, but this comparison
process is only done in segments of round hours (e.g. 08.00 o'clock is all
summed element values between 0800 and 0859).
In the XML sample here, we have three elements that fit the selection criteria
(they have been all created between 0800 and 0859). I must create one single
element (with same caracteristics), but the end value of BZF_MengeGezdhlt
should be (58+47+42 = 147). Then the resulted element will be used for final
1-1 comparison.

==>  <Eintrag BZ_Abgangsdatum="20050211" BZ_Zeit="0800" BZ_DLA="B1"
BZ_Format="NF" BZ_Verarbeitung="Maschine" BZ_Bundart="999"
BZF_Ankunftsdatum="20050211" BZF_Zeit="1442" BZF_Zustelldatum="20050211"
BZF_MengeGezdhlt="142"/>

Any hint would be greatful.

Best regards, and happy easter ;-)

Lawrence Michel

Current Thread