Monthly Archives: August 2014

Why JavaEE ?

java_ee
Why JavaEE is so popular? Not because it is the super useful, just this is implementation of all incoming business requirements for a time. This is so called template patterns for business, nothing more: not technical brilliance, not ideological concern.

Here is high availability, high scalability, high reliability platform for building business infrastructure.
The time from first release is a proof.
Use java!

Floating point operations in XPath

xpath
You may need to perform arithmetic operation with XPath-expression like sum, etc. But Saxon parser cast all floating point values to DOUBLE by default (as Java).
If you have next xml:

<root>
    <value>1.555</value>
    <value>1</value>
    <value>-1</value>
</root>

So, for sum you use next XPath expression:

sum(/root/value)

And in result you’ll have NOT 1.555, but 1.4999999754 for example.
This is normal java behavior! Don’t panic!
Just use some trick:

sum(/root/value/xs:decimal(.))

And it gives you 1.555 in result.

As you see, adding /xs:decimal(.) solves the problem with data losses.