Talk:XQuery/Tag Cloud

I hope this is the way to discuss coding practices ;-)

In the keyword counting function we have:

let $term-count := count(for $word in $wordlist where $word = string($term) return $word)

The explicit atomisation with string isn't needed here - so ..

let $term-count := count(for $word in $wordlist where $word = $term return $word)

Also generalised = is not needed here since neither operands is a sequence

let $term-count := count(for $word in $wordlist where $word eq $term return $word)

In general I think its good to encourage the use of XPath predicates where possible - they are generally faster than FLWOR expressions and clearer.

So finally I would suggest

let $term-count := count($wordlist[. eq $term])

Although this formulation does require an explanation of. but XQuery presumes a knowledge of XPath ChrisWallace 06:06, 23 August 2007 (UTC)

I've also reduced the functionality of the word-count function - ordering the items by the count is an additional task unrelated to the counting, and when the map is generated, the ordering needs to be different (alphabetical). I've also chanced the input to the whole list because that seems more consistent with the return and changed the term format itself so that the count is added to the term as an attribute.

Maybe I'm being a bit too enthusistic here ??

ChrisWallace 07:30, 23 August 2007 (UTC)