text() word lists
Hi there, I'm sure this is a faq, and I've checked the faq and archive. I swear I remember someone asking about it, but I couldn't find it, so here goes. I want to take an XML file of unknown elements and create a word frequency list / word list. Now, an entry on sorting in the xslt faq says this is just what xslt is bad at. (And I'm sure there are some that would say 'just go use perl', but let's say I want to do it in xslt(1 or 2). XSLT2 makes the tokenization of strings much easier, so assuming I'm using that, if I have: <foo> <blort> This is a <wibble>Test</wibble>, only a test!</blort> <blort> This really is a <wibble>great big test</wibble>, only a test!</blort> </foo> I don't know that foo|wibble|blort will be the element names. But I want to produce both: a -- 4 test -- 4 only -- 2 is -- 2 this -- 2 big -- 1 great -- 1 really -- 1 Which (unless I've missed something) should be a case-insensitive list grouped by frequency sorted alphabetically within this, and ignoring punctuation. But also: a -- 4 big -- 1 great -- 1 is -- 2 only -- 2 test -- 4 this -- 2 really -- 1 Which is the same list by not grouped by frequency. Suggestions? Solutions? Many thanks for any help, -James --- Dr James Cummings, Oxford Text Archive, University of Oxford James.Cummings at ota.ahds.ac.uk http://users.ox.ac.uk/~jamesc/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format