current() or . not working on calculation (bind)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

current() or . not working on calculation (bind)

Roxana
This post was updated on .
I have a bind (xf:decimal type) and a calculate on it, like this:
<xf:bind id=&quot;my-ref-bind&quot; ref=&quot;my-ref&quot;
type=&quot;xf:decimal&quot; ...
calculate=&quot;if(instance('my_instance')/my-date[@q=current()/@q]) then .
else xs:decimal('0')&quot; ... />
and it doesn't return . (or current()) value.

I've put the same calculation on the form field and it is working.
My form field is like this:
<xf:output
value=if(instance('my_instance')/my-date[@q=current()/@q]) then . else
xs:decimal('0')"/>

I've also tried to return a custom value instead of . (current() value) and
it is working:
calculate="if(instance('my_instance')/my-date[@q=current()/@q]) then
xs:decimal('1') else xs:decimal('0')"

Can someone suggest a solution for this? How can I return the current node
value if a condition is met on 'calculate' of a bind?

Thanks!
Roxana


--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orbeon+unsubscribe@googlegroups.com.
To post to this group, send email to orbeon@googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: current() or . not working on calculation (bind)

Alessandro  Vernet
Administrator
Hi Roxana,

So the expression in your calculate is:

if (instance('my_instance')/my-date[@q=current()/@q])
  then .
  else xs:decimal('0')

And you're saying that the `.` part isn't working. What do you mean by "not
working"? You're trying to keep the value as-is in some cases, and change it
to "0" in others. What happens is the value isn't kept?

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: current() or . not working on calculation (bind)

Roxana
Hi Alessandro,

Yes, that's what I'm saying. The '.' part isn't working, because is not
returning the current value.
The '.' is returning 0 instead of the value from the instance.

So yes, I'm trying to keep the value as-is in some cases, and change it to
"0" in others. And the value isn't kept.

Thanks,
Roxana

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: current() or . not working on calculation (bind)

Alessandro  Vernet
Administrator
Roxana,

And you were saying that if you replace `.` by `xs:decimal('1')`, then the
value becomes `1` (instead of `0`), so it seems the test is working. Could
you try replacing `.` by `text()` and see if it makes a difference?

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet