Hi,
just before you asking me. No we wasn't to isolate the Problem for now.
Working on a complex transaction with database involved, we get the following phenomenon.
declare function m:paths($el as element()) as xs:string* { distinct-values( for $e in $item/descendant::* return string-join($e/ancestor-or-self::*/local-name(.), "/") ) };
This function should produce a list of paths to all child of $el. And it works!
But sometimes we get some strange results. We created new element constructed from others, may existing, elements.
let $sequence-of-elements := collect-some-elements($from-somewhere) let $new-element := element el { $sequence-of-elements } return paths($new-element)
Most of the time we get as expected results like:
el/c1 el/c1/c12 el/c2 el/c2/c21 el/c2/c22 el/..
But sometimes it looks like that parents of the copied elements are not set correctly:
oldParentOfc1/c1 oldParentOfc1/c1/c12 otherOld/ParentOfc2/c2 otherOld/ParentOfc2/c2/c21 otherOld/ParentOfc2/c2/c22 ...
If we do a copy of the result <el> like parse-xml(serialize($new-element))/* and call paths() again, everything looks now as expected.
We call the function what products such results, isolated within a test-script with exact the same inputs. But suddenly the result was correct.
Then we copied the inputs of the function within the integration (parse-xml, serialize). But it failed again.
Also notable is, that the "bad result" is stable. It produces always the same result on same inputs (no random).
So we have no idea to isolate the issue.
Any suggestions?
Best Regards
Jan