|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] how to generate an inventory of elements in a list for whole collection?David Epstein davideps at umich.eduThu Aug 6 16:57:21 PDT 2009
Hi everyone, I'm hoping someone here may be able to point me in the right direction. I need to write a query that does the following for each node in the path: 1) extracts a string from a parameter (see example fragment below) 2) splits the string into distinct elements on the semi-colon character 3) keeps a running tally of unique elements for the WHOLE collection 3) keeps a running tally of how many times each unique element occured 4) returns a XML doc in which each element is paired with a number representing the times it occured. I understand how to split a string. I understand how to structure an XML return. But, I don't understand how to create a master list or hash for the whole collection. I think I could do this in Perl or Python. But, I'm new to XQuery. At each step I would need to compare the elements I just extracted to the ones I've already found. Repeat elements would cause the value for that element to increase by one. New elements would be added to the list with a value of 1 (one occurrence so far). Here is what the start of a node looks like. I want the list stored in "subject". <highlight coords="702.25,157.096,1035.829093,157.096,702.25,142.8205" title="example" creationdate="D:20090727164124-04'00'" subject="q;def:environmental management;human-env-interact;heath;env;" page="12" date="D:20090727164241-04'00'" flags="print" When the query is complete, the element "q" may have been encountered 200 times (in 200 nodes) and the element "health" may have been encountered 70 times. Any suggestions would be appreciated. Thank you! -david
|
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
|






