[xquery-talk] A walk down Sesame St - counting for simpletons

Ihe Onwuka ihe.onwuka at gmail.com
Tue Apr 8 08:23:27 PDT 2014


count(colllection('myColl')//elem tells me how many elems there are in
myColl. Fine

So now I want to be told how many elems are in myColl and myColl2.

Put them in a sequence like so

(collection('myColl')//elem,collection('myColl2')//elem) and then
apply the count method to each element of the sequence n'est pas?

(collection('myColl')//elem,collection('myColl2')//elem)/count(.)

2 collections to give me 2 numbers .C'est domage, Mais non. That only
gives me one number - the count of elems in MyColl.

C'est fait rien methinks (or perhaps doesn't think). 3.0 map operator
to the rescue - let's substitute the / for a !.

Sacre bleu

I now have a stream of N 1's where N is the number of elems in
MyColl............

I have gone back to the more prosaic method of counting each
collection with a comma separator to transform the answer to a
sequence.


More information about the talk mailing list