Add a limit option to p:count

One of the use case, I find frequently is to have a rough idea of how much
is the sequence long

p:count could help, but to respect the spec, it must read all the sequence
for that

Most of the time, I can content myself with just simple information like :

* is the sequence empty ?
* has the sequence only one document ?
* has the sequence more than one document ?
* has the sequence more than x document ?

For this I propose to have an "limit" option that would be defaulted to -1
(or 0)

-1 (or 0) means give a strict count of how many there are

1 would mean  give 0 as result if empty, 1 if there is a document (which
means it can answer very quickly)

2 would mean give 0 as result if empty, 1 if there is a document and 2 if
there is more than one (would need to buffer only one document to answer)

and so on

One way to do that with todays tool but I don't like  is
to use <p:split-sequence test="position() &lt;= $limit"/> and then do a
<p:count> on the result

1) but it means that p:split-sequence needs to be optimized to know that we
don't use the alternate port and once we reach the $limit we can stop
processing
2) more than that it means you have to buffer one more document than my
proposal

Mohamed

-- 
Innovimax SARL
Consulting, Training & XML Development
9, impasse des Orteaux
75020 Paris
Tel : +33 9 52 475787
Fax : +33 1 4356 1746
http://www.innovimax.fr
RCS Paris 488.018.631
SARL au capital de 10.000 €

Received on Saturday, 3 May 2008 09:53:13 UTC