On 19/12/2023 09:53, Marco Duiker - LandGoed wrote:
Please help me with the following problem:
I try to construct the current status of a series of objects along the following simple rules:
- the current status of on object with a certain `identificatie` (id) is the newest version of that object
- except when the newest object has the property `<status>beëindigen</status>` then the object stops existing.
I use a fold-left to proces these rules with a simple function implementing those rules. This gives me unexpected results.
I've reduced the problem to a single stand alone query in which the last object (`obj3`) has the property `<status>beëindigen</status>`.
So I would expect this line: `let $stand4 := fold-left(($obj3, $obj2, $obj1), (), function($stand, $obj) { local:stand-totaal($stand, $obj) })` to give me an empty result as `obj3`has the property <status>beëindigen</status> but I am getting `obj1` as demonstrated in the following stand alone query.
When running the stand alone query I would *expect*:
declare function local:stand-totaal (: returns an object by comparing new to old :) (: newest should be returned, except when ow:statusbeëindigen</ow:status> then no object should be returned :) ($new as item()*, $old as item()*) as item()* {
let $new_ids := local:id($new) let $stand_deel1 := for $obj_oud in $old//*:owObject where not(local:id($obj_oud) = $new_ids) return sl:stand{ $obj_oud }</sl:stand> let $stand_deel2 := for $obj_new in $new//*:owObject[not(.//*:status)] return sl:stand{ $obj_new }</sl:stand>
return ($stand_deel1, $stand_deel2) };
From your comment and explanation I kind of would expect a check for that particular value
ow:statusbeëindigen</ow:status>
but that value is not checked for or mentioned at all in the XQuery code.