Subject: [xsl] grouping and word counting From: marina <marina777uk@xxxxxxxxx> Date: Sat, 19 Jul 2003 00:58:01 -0700 (PDT) |
Hi, I have an XML document that contains messages sent by people to one another. Many of these messages in the <MESSAGE> tags are repeated as they are sent by one person to many others. XML Snippet: -------------------------------------------------- <LOG> <SENT> <USER> 12345 </USER> <LOCATION> 55555 </LOCATION> <TARGET> 1 </TARGET> <TARGET_LOCATION> 23222 </TARGET_LOCATION> <MESSAGE> hello Fred </MESSAGE> </SENT> <SENT> <USER> 77777 </USER> <LOCATION> 76666 </LOCATION> <TARGET> 3 </TARGET> <TARGET_LOCATION> 34444 </TARGET_LOCATION> <MESSAGE> nice weather </MESSAGE> </SENT> <SENT> <USER> 77777 </USER> <LOCATION> 76666 </LOCATION> <TARGET> 4 </TARGET> <TARGET_LOCATION> 67777 </TARGET_LOCATION> <MESSAGE> nice weather </MESSAGE> </SENT> <SENT> <USER> 33333 </USER> <LOCATION> 12666 </LOCATION> <TARGET> 8 </TARGET> <TARGET_LOCATION> 98765 </TARGET_LOCATION> <MESSAGE> whats the latest news? </MESSAGE> </SENT> <SENT> <USER> 33333 </USER> <LOCATION> 12666 </LOCATION> <TARGET> 9 </TARGET> <TARGET_LOCATION> 46578 </TARGET_LOCATION> <MESSAGE> whats the latest news? </MESSAGE> </SENT> </LOG> -------------------------------------------------- What I need to do is:- 1) Find out how many messages over all were sent to 1, 2, 3 etc people. As a duplicated message will always follow the original, i.e. be the next <MESSAGE> tag of the following sibling node, I'm thinking that the stylesheet would start with the first message and keep comparing siblings until it found one that was different. Then it would just add the previous number of sibling nodes? ( I probably need to use keys?) 2) For each of the total messages per group size, calculate the average number of words. No idea on this one I'm afraid! So the desired output from the snippet above would be: - Group Size Number of Messages Av Number Words 1 1 2 2 2 3 (up to say 20) Many thanks in advance for any help, Marina __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re: (Probably trivial) gr, Stefan Tilkov | Thread | [xsl] Re: grouping and word countin, Dimitre Novatchev |
[xsl] (Probably trivial) grouping p, Stefan Tilkov | Date | [xsl] Re: (Probably trivial) groupi, Dimitre Novatchev |
Month |