W3C home > Mailing lists > Public > public-xml-processing-model-wg@w3.org > May 2008

Add a limit option to p:count

From: Innovimax SARL <innovimax@gmail.com>
Date: Sat, 3 May 2008 11:52:37 +0200
Message-ID: <546c6c1c0805030252o28290179s14d8531f2149adf0@mail.gmail.com>
To: "XProc WG" <public-xml-processing-model-wg@w3.org>
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
2) more than that it means you have to buffer one more document than my


Innovimax SARL
Consulting, Training & XML Development
9, impasse des Orteaux
75020 Paris
Tel : +33 9 52 475787
Fax : +33 1 4356 1746
RCS Paris 488.018.631
SARL au capital de 10.000 
Received on Saturday, 3 May 2008 09:53:13 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:32:45 UTC