>Does this make sense for a count function, though? I did not get from the
>spec that all functions returned doubles. It would seem to me a count should
>be a whole number and the framework is capable of this.
>
>What am I missing in understanding this?
>

It makes sense for a count function in a language like XPath that 
only has doubles. It's important for Jaxen to follow this, because 
the result of the count() function may be fed into a different XPath 
function that would give different results depending on whether it 
got a double or an int. For example, imagine dividing the number of 
cookie elements by the number of person elements to determine how 
many cookies there are per person. In XPath terms this is,

count(//cookie) div count(//person)

This is a reasonable thing to do in XPath, and it returns double 
which may involve a fractional number of cookies per person. However, 
if Jaxen were to return an int from count, then it would give very 
different results when evaluating this expression. For instance if 
there are ten cookies and four people, then XPath's answer is 2.5, 
but Jaxen's would be 2. If there were five cookies and ten people, 
then XPath's answer would be 0.5 but Jaxen's would be 0.

There are a lot of other tricky cases like this. Since Jaxen's 
striving to provide a generic XPath API, rather than a generic 
arithmetic API, the sensible thing to do is follow the XPath rules 
for arithmetic and numbers.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | [EMAIL PROTECTED] | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
+----------------------------------+---------------------------------+

_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to