I am looking for a possibility to perform complex calculations for a binding. The following instance is given:
<root>
<appointments>
<appointment><date>2012-01-01</date></appointment>
<appointment><date>2012-01-03</date></appointment>
</appointments>
<weeks />
</root>
The weeks
node depends on the appointment
nodes:
$weeks = 0
$week_begin = xs:date("1970-01-01")
for $appointment in //appointments/appoinment
if # Check if $appointment is in new week
$weeks = $weeks + 1
$week_begin = # Do some more calculationx
My problem is that I don't know where to "put" those calculations. As you can see we need a loop with variables that can store some information between loop cycles. Therefore, I have evaluated the following options:
- xforms:variable in combination with xforms:repeat => xforms:variable inside a repeat can't write to the "outside" scope
- xforms:setvalue in combination with an extra instance that holds temporary variables and xforms:repeat
- xforms:bind with calculate attribute => for loops in xpath are possible, but no variables
Any advice how to approach this problem? Thank you!