Andreas,
You should try to use an ExtensionFunction. What exactly is the issue
with iteration?
- Dmitri
--- "Geerling, Andreas" <[EMAIL PROTECTED]> wrote:
> I am trying to write a function sumBigDecimal() similar to the sum()
> function.
> First I tried to create a ExtensionFunction, but i have the problem
> to iterate the values.
>
> Only with Java, i would do it like this:
>
> public static BigDecimal sumBigDecimal(JXPathContext context,String
> xpath) {
> Object obj = null;
> BigDecimal sum = new BigDecimal("0");
> Iterator iter = context.iterate(xpath);
> while (iter.hasNext()) {
> obj = iter.next();
> if (obj instanceof BigDecimal) {
> sum = sum.add((BigDecimal) obj);
> }
> } return sum;
> }
>
> But I would like to use it "within" JXPath as a Function.
> Examples:
>
> BigDecimal myBetrag = (BigDecimal) context.getValue(
>
>
"myf:sumBigDecimal(positionen[freieAttribute/warengruppe='AA']/vbetrag)");
>
> String artikelbezeichnung = (String) context.getValue(
> "positionen[sumBigDecimal(vbetrag) > $minBetrag]/bezeichnung)");
>
> Can someone help me?
>
> Andreas Geerling
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>